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 |
|---|---|---|---|---|---|---|
thejamesthomas/javabank | javabank-core/src/main/java/org/mbtest/javabank/fluent/ResponseBuilder.java | // Path: javabank-core/src/main/java/org/mbtest/javabank/http/responses/Response.java
// public abstract class Response extends HashMap {
//
// public JSONObject getJSON() {
// return new JSONObject(this);
// }
//
// public String toString() {
// return getJSON().toJSONString();
// }
// }
| import org.mbtest.javabank.http.responses.Response; | package org.mbtest.javabank.fluent;
public class ResponseBuilder implements FluentBuilder {
private StubBuilder parent;
private ResponseTypeBuilder builder;
protected ResponseBuilder(StubBuilder stubBuilder) {
this.parent = stubBuilder;
}
public IsBuilder is() {
builder = new IsBuilder(this);
return (IsBuilder) builder;
}
public InjectBuilder inject() {
builder = new InjectBuilder(this);
return (InjectBuilder) builder;
}
@Override
public StubBuilder end() {
return parent;
}
| // Path: javabank-core/src/main/java/org/mbtest/javabank/http/responses/Response.java
// public abstract class Response extends HashMap {
//
// public JSONObject getJSON() {
// return new JSONObject(this);
// }
//
// public String toString() {
// return getJSON().toJSONString();
// }
// }
// Path: javabank-core/src/main/java/org/mbtest/javabank/fluent/ResponseBuilder.java
import org.mbtest.javabank.http.responses.Response;
package org.mbtest.javabank.fluent;
public class ResponseBuilder implements FluentBuilder {
private StubBuilder parent;
private ResponseTypeBuilder builder;
protected ResponseBuilder(StubBuilder stubBuilder) {
this.parent = stubBuilder;
}
public IsBuilder is() {
builder = new IsBuilder(this);
return (IsBuilder) builder;
}
public InjectBuilder inject() {
builder = new InjectBuilder(this);
return (InjectBuilder) builder;
}
@Override
public StubBuilder end() {
return parent;
}
| protected Response build() { |
thejamesthomas/javabank | javabank-core/src/main/java/org/mbtest/javabank/http/imposters/Imposter.java | // Path: javabank-core/src/main/java/org/mbtest/javabank/http/core/Stub.java
// public class Stub extends HashMap {
//
// private static final String RESPONSES = "responses";
// private static final String PREDICATES = "predicates";
//
// public Stub() {
// this.put(RESPONSES, newArrayList());
// this.put(PREDICATES, newArrayList());
// }
//
// public Stub withResponse(Is response) {
// getResponses().clear();
// getResponses().add(response);
//
// return this;
// }
//
// public Stub addResponse(Response response) {
// getResponses().add(response);
//
// return this;
// }
//
// public Stub addPredicates(List<Predicate> predicates) {
// getPredicates().addAll(predicates);
// return this;
// }
//
// public List<Response> getResponses() {
// return (List<Response>) this.get(RESPONSES);
// }
//
// public List<Predicate> getPredicates() {
// return (List<Predicate>) this.get(PREDICATES);
// }
//
// public HashMap getResponse(int index) {
// return getResponses().get(index);
// }
//
// public Predicate getPredicate(int index) {
// return getPredicates().get(index);
// }
// }
| import org.json.simple.JSONObject;
import org.mbtest.javabank.http.core.Stub;
import java.util.HashMap;
import java.util.List;
import static com.google.common.collect.Lists.newArrayList; | package org.mbtest.javabank.http.imposters;
public class Imposter extends HashMap {
private static final String PORT = "port";
private static final String PROTOCOL = "protocol";
private static final String STUBS = "stubs";
public Imposter() {
this.put(PROTOCOL, "http");
this.put(STUBS, newArrayList());
}
public static Imposter fromJSON(JSONObject json) {
Imposter imposter = new Imposter();
imposter.putAll(json);
return imposter;
}
public static Imposter anImposter() {
return new Imposter();
}
public Imposter onPort(int port) {
this.put(PORT, port);
return this;
}
| // Path: javabank-core/src/main/java/org/mbtest/javabank/http/core/Stub.java
// public class Stub extends HashMap {
//
// private static final String RESPONSES = "responses";
// private static final String PREDICATES = "predicates";
//
// public Stub() {
// this.put(RESPONSES, newArrayList());
// this.put(PREDICATES, newArrayList());
// }
//
// public Stub withResponse(Is response) {
// getResponses().clear();
// getResponses().add(response);
//
// return this;
// }
//
// public Stub addResponse(Response response) {
// getResponses().add(response);
//
// return this;
// }
//
// public Stub addPredicates(List<Predicate> predicates) {
// getPredicates().addAll(predicates);
// return this;
// }
//
// public List<Response> getResponses() {
// return (List<Response>) this.get(RESPONSES);
// }
//
// public List<Predicate> getPredicates() {
// return (List<Predicate>) this.get(PREDICATES);
// }
//
// public HashMap getResponse(int index) {
// return getResponses().get(index);
// }
//
// public Predicate getPredicate(int index) {
// return getPredicates().get(index);
// }
// }
// Path: javabank-core/src/main/java/org/mbtest/javabank/http/imposters/Imposter.java
import org.json.simple.JSONObject;
import org.mbtest.javabank.http.core.Stub;
import java.util.HashMap;
import java.util.List;
import static com.google.common.collect.Lists.newArrayList;
package org.mbtest.javabank.http.imposters;
public class Imposter extends HashMap {
private static final String PORT = "port";
private static final String PROTOCOL = "protocol";
private static final String STUBS = "stubs";
public Imposter() {
this.put(PROTOCOL, "http");
this.put(STUBS, newArrayList());
}
public static Imposter fromJSON(JSONObject json) {
Imposter imposter = new Imposter();
imposter.putAll(json);
return imposter;
}
public static Imposter anImposter() {
return new Imposter();
}
public Imposter onPort(int port) {
this.put(PORT, port);
return this;
}
| public Imposter addStub(Stub stub) { |
thejamesthomas/javabank | javabank-core/src/main/java/org/mbtest/javabank/fluent/PredicateValueBuilder.java | // Path: javabank-core/src/main/java/org/mbtest/javabank/http/predicates/Predicate.java
// public class Predicate extends HashMap {
// private static final String PATH = "path";
// private static final String METHOD = "method";
// private static final String QUERY = "query";
// private static final String HEADERS = "headers";
// private static final String REQUEST_FROM = "requestFrom";
// private static final String BODY = "body";
//
// private Map data;
// private PredicateType type;
//
// public Predicate(PredicateType type) {
// this.type = type;
// data = newHashMap();
// this.put(type.getValue(), data);
// }
//
// private Predicate addEntry(String key, String value) {
// data.put(key, value);
// return this;
// }
//
// private Predicate addEntry(String key, Map map) {
// data.put(key, map);
// return this;
// }
//
// private Predicate addMapEntry(String key, String name, String value) {
// if(!data.containsKey(key)) {
// data.put(key, newHashMap());
// }
//
// Map entryMap = (Map) data.get(key);
// entryMap.put(name, value);
//
// return this;
// }
//
// private Object getEntry(String key) {
// return this.data.get(key);
// }
//
// @Override
// public String toString() {
// return toJSON().toJSONString();
// }
//
// private JSONObject toJSON() {
// return new JSONObject(this);
// }
//
// public String getType() {
// return type.getValue();
// }
//
// public Predicate withPath(String path) {
// addEntry(PATH, path);
// return this;
// }
//
// public Predicate withMethod(String method) {
// addEntry(METHOD, method);
// return this;
// }
//
// public Predicate withQueryParameters(Map<String, String> parameters) {
// addEntry(QUERY, parameters);
// return this;
// }
//
// public Predicate addQueryParameter(String name, String value) {
// addMapEntry(QUERY, name, value);
// return this;
// }
//
// public Predicate addHeader(String name, String value) {
// addMapEntry(HEADERS, name, value);
// return this;
// }
//
// public Predicate withRequestFrom(String host, String port) {
// addEntry(REQUEST_FROM, host + ":" + port);
// return this;
// }
//
// public Predicate withBody(String body) {
// addEntry(BODY, body);
// return this;
// }
//
// public String getPath() {
// return (String) getEntry(PATH);
// }
//
// public String getMethod() {
// return (String) getEntry(METHOD);
// }
//
// public String getRequestFrom() {
// return (String) getEntry(REQUEST_FROM);
// }
//
// public String getBody() {
// return (String) getEntry(BODY);
// }
//
// public Map<String, String> getQueryParameters() {
// return (Map<String, String>) getEntry(QUERY);
// }
//
// public String getQueryParameter(String parameter) {
// return getQueryParameters().get(parameter);
// }
//
// public Map<String, String> getHeaders() {
// return (Map<String, String>) getEntry(HEADERS);
// }
//
// public String getHeader(String name) {
// return getHeaders().get(name);
// }
// }
//
// Path: javabank-core/src/main/java/org/mbtest/javabank/http/predicates/PredicateType.java
// public enum PredicateType {
// EQUALS("equals"),
// DEEP_EQUALS("deepEquals"),
// CONTAINS("contains"),
// STARTS_WITH("startsWith"),
// ENDS_WITH("endsWith"),
// MATCHES("matches"),
// EXISTS("exists"),
// NOT("not"),
// OR("or"),
// AND("and"),
// INJECT("inject");
//
// @Getter
// private String value;
//
// PredicateType(String value) {
//
// this.value = value;
// }
// }
| import org.mbtest.javabank.http.predicates.Predicate;
import org.mbtest.javabank.http.predicates.PredicateType; | package org.mbtest.javabank.fluent;
public class PredicateValueBuilder implements FluentBuilder {
private final Predicate predicate;
private PredicateTypeBuilder parent;
| // Path: javabank-core/src/main/java/org/mbtest/javabank/http/predicates/Predicate.java
// public class Predicate extends HashMap {
// private static final String PATH = "path";
// private static final String METHOD = "method";
// private static final String QUERY = "query";
// private static final String HEADERS = "headers";
// private static final String REQUEST_FROM = "requestFrom";
// private static final String BODY = "body";
//
// private Map data;
// private PredicateType type;
//
// public Predicate(PredicateType type) {
// this.type = type;
// data = newHashMap();
// this.put(type.getValue(), data);
// }
//
// private Predicate addEntry(String key, String value) {
// data.put(key, value);
// return this;
// }
//
// private Predicate addEntry(String key, Map map) {
// data.put(key, map);
// return this;
// }
//
// private Predicate addMapEntry(String key, String name, String value) {
// if(!data.containsKey(key)) {
// data.put(key, newHashMap());
// }
//
// Map entryMap = (Map) data.get(key);
// entryMap.put(name, value);
//
// return this;
// }
//
// private Object getEntry(String key) {
// return this.data.get(key);
// }
//
// @Override
// public String toString() {
// return toJSON().toJSONString();
// }
//
// private JSONObject toJSON() {
// return new JSONObject(this);
// }
//
// public String getType() {
// return type.getValue();
// }
//
// public Predicate withPath(String path) {
// addEntry(PATH, path);
// return this;
// }
//
// public Predicate withMethod(String method) {
// addEntry(METHOD, method);
// return this;
// }
//
// public Predicate withQueryParameters(Map<String, String> parameters) {
// addEntry(QUERY, parameters);
// return this;
// }
//
// public Predicate addQueryParameter(String name, String value) {
// addMapEntry(QUERY, name, value);
// return this;
// }
//
// public Predicate addHeader(String name, String value) {
// addMapEntry(HEADERS, name, value);
// return this;
// }
//
// public Predicate withRequestFrom(String host, String port) {
// addEntry(REQUEST_FROM, host + ":" + port);
// return this;
// }
//
// public Predicate withBody(String body) {
// addEntry(BODY, body);
// return this;
// }
//
// public String getPath() {
// return (String) getEntry(PATH);
// }
//
// public String getMethod() {
// return (String) getEntry(METHOD);
// }
//
// public String getRequestFrom() {
// return (String) getEntry(REQUEST_FROM);
// }
//
// public String getBody() {
// return (String) getEntry(BODY);
// }
//
// public Map<String, String> getQueryParameters() {
// return (Map<String, String>) getEntry(QUERY);
// }
//
// public String getQueryParameter(String parameter) {
// return getQueryParameters().get(parameter);
// }
//
// public Map<String, String> getHeaders() {
// return (Map<String, String>) getEntry(HEADERS);
// }
//
// public String getHeader(String name) {
// return getHeaders().get(name);
// }
// }
//
// Path: javabank-core/src/main/java/org/mbtest/javabank/http/predicates/PredicateType.java
// public enum PredicateType {
// EQUALS("equals"),
// DEEP_EQUALS("deepEquals"),
// CONTAINS("contains"),
// STARTS_WITH("startsWith"),
// ENDS_WITH("endsWith"),
// MATCHES("matches"),
// EXISTS("exists"),
// NOT("not"),
// OR("or"),
// AND("and"),
// INJECT("inject");
//
// @Getter
// private String value;
//
// PredicateType(String value) {
//
// this.value = value;
// }
// }
// Path: javabank-core/src/main/java/org/mbtest/javabank/fluent/PredicateValueBuilder.java
import org.mbtest.javabank.http.predicates.Predicate;
import org.mbtest.javabank.http.predicates.PredicateType;
package org.mbtest.javabank.fluent;
public class PredicateValueBuilder implements FluentBuilder {
private final Predicate predicate;
private PredicateTypeBuilder parent;
| public PredicateValueBuilder(PredicateTypeBuilder predicateTypeBuilder, PredicateType type) { |
thejamesthomas/javabank | javabank-core/src/test/java/org/mbtest/javabank/http/core/StubTest.java | // Path: javabank-core/src/main/java/org/mbtest/javabank/http/responses/Is.java
// public class Is extends Response {
// private static final String IS = "is";
// private static final String HEADERS = "headers";
// private static final String BODY = "body";
// private static final String STATUS_CODE = "statusCode";
// public static final String MODE = "_mode";
//
// private final Map<String, Object> data;
// private Map<String, String> headers;
//
// public Is() {
// headers = newHashMap();
// headers.put(HttpHeaders.CONNECTION, "close");
//
// this.data = newHashMap();
// this.data.put(STATUS_CODE, 200);
// this.data.put(HEADERS, headers);
//
// this.put(IS, data);
// withStatusCode(HttpStatus.SC_OK);
// withBody("");
// }
//
// public Is withStatusCode(int statusCode) {
// this.data.put("statusCode", statusCode);
// return this;
// }
//
// public Is withHeader(String name, String value) {
// this.headers.clear();
// addHeader(name, value);
// return this;
// }
//
// public Is addHeader(String name, String value) {
// this.headers.put(name, value);
// return this;
// }
//
// public Is withBody(String body) {
// this.data.put(BODY, body);
// return this;
// }
//
// public Is withMode(String mode){
// if(!Objects.isNull(mode)) {
// this.data.put(MODE, mode);
// }
// return this;
// }
//
// public Is withHeaders(Map<String, String> headers) {
// this.headers = headers;
// this.data.put(HEADERS, headers); // issue #5
// return this;
// }
//
// public int getStatusCode() {
// return Integer.valueOf(String.valueOf(this.data.get(STATUS_CODE)));
// }
//
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// public String getBody() {
// return (String) this.data.get(BODY);
// }
//
// public String getMode() {
// return (String) this.data.get(MODE);
// }
// }
| import org.junit.Test;
import org.mbtest.javabank.http.responses.Is;
import static org.assertj.core.api.Assertions.assertThat; | package org.mbtest.javabank.http.core;
public class StubTest {
@Test
public void shouldAddAResponse() {
Stub stub = new Stub() | // Path: javabank-core/src/main/java/org/mbtest/javabank/http/responses/Is.java
// public class Is extends Response {
// private static final String IS = "is";
// private static final String HEADERS = "headers";
// private static final String BODY = "body";
// private static final String STATUS_CODE = "statusCode";
// public static final String MODE = "_mode";
//
// private final Map<String, Object> data;
// private Map<String, String> headers;
//
// public Is() {
// headers = newHashMap();
// headers.put(HttpHeaders.CONNECTION, "close");
//
// this.data = newHashMap();
// this.data.put(STATUS_CODE, 200);
// this.data.put(HEADERS, headers);
//
// this.put(IS, data);
// withStatusCode(HttpStatus.SC_OK);
// withBody("");
// }
//
// public Is withStatusCode(int statusCode) {
// this.data.put("statusCode", statusCode);
// return this;
// }
//
// public Is withHeader(String name, String value) {
// this.headers.clear();
// addHeader(name, value);
// return this;
// }
//
// public Is addHeader(String name, String value) {
// this.headers.put(name, value);
// return this;
// }
//
// public Is withBody(String body) {
// this.data.put(BODY, body);
// return this;
// }
//
// public Is withMode(String mode){
// if(!Objects.isNull(mode)) {
// this.data.put(MODE, mode);
// }
// return this;
// }
//
// public Is withHeaders(Map<String, String> headers) {
// this.headers = headers;
// this.data.put(HEADERS, headers); // issue #5
// return this;
// }
//
// public int getStatusCode() {
// return Integer.valueOf(String.valueOf(this.data.get(STATUS_CODE)));
// }
//
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// public String getBody() {
// return (String) this.data.get(BODY);
// }
//
// public String getMode() {
// return (String) this.data.get(MODE);
// }
// }
// Path: javabank-core/src/test/java/org/mbtest/javabank/http/core/StubTest.java
import org.junit.Test;
import org.mbtest.javabank.http.responses.Is;
import static org.assertj.core.api.Assertions.assertThat;
package org.mbtest.javabank.http.core;
public class StubTest {
@Test
public void shouldAddAResponse() {
Stub stub = new Stub() | .withResponse(new Is()); |
thejamesthomas/javabank | javabank-core/src/main/java/org/mbtest/javabank/fluent/InjectBuilder.java | // Path: javabank-core/src/main/java/org/mbtest/javabank/http/responses/Inject.java
// public class Inject extends Response {
// private static final String INJECT = "inject";
//
// public Inject() {
// this.put(INJECT, "");
// }
//
// public Inject withFunction(String function) {
// this.put(INJECT, function);
// return this;
// }
// }
| import org.mbtest.javabank.http.responses.Inject; | package org.mbtest.javabank.fluent;
public class InjectBuilder extends ResponseTypeBuilder {
private String function = "";
public InjectBuilder(ResponseBuilder responseBuilder) {
super(responseBuilder);
}
public InjectBuilder function(String function) {
this.function = function;
return this;
}
@Override | // Path: javabank-core/src/main/java/org/mbtest/javabank/http/responses/Inject.java
// public class Inject extends Response {
// private static final String INJECT = "inject";
//
// public Inject() {
// this.put(INJECT, "");
// }
//
// public Inject withFunction(String function) {
// this.put(INJECT, function);
// return this;
// }
// }
// Path: javabank-core/src/main/java/org/mbtest/javabank/fluent/InjectBuilder.java
import org.mbtest.javabank.http.responses.Inject;
package org.mbtest.javabank.fluent;
public class InjectBuilder extends ResponseTypeBuilder {
private String function = "";
public InjectBuilder(ResponseBuilder responseBuilder) {
super(responseBuilder);
}
public InjectBuilder function(String function) {
this.function = function;
return this;
}
@Override | protected Inject build() { |
thejamesthomas/javabank | javabank-client/src/test/java/org/mbtest/javabank/ClientTest.java | // Path: javabank-core/src/main/java/org/mbtest/javabank/fluent/ImposterBuilder.java
// public class ImposterBuilder {
// private int port;
// private List<StubBuilder> stubBuilders = newArrayList();
//
// public static ImposterBuilder anImposter() {
// return new ImposterBuilder();
// }
//
// public ImposterBuilder onPort(int port) {
// this.port = port;
// return this;
// }
//
// public StubBuilder stub() {
// StubBuilder child = new StubBuilder(this);
// stubBuilders.add(child);
// return child;
// }
//
// public Imposter build() {
// Imposter imposter = new Imposter().onPort(port);
// for (StubBuilder stubBuilder : stubBuilders) {
// imposter.addStub(stubBuilder.build());
// }
// return imposter;
// }
// }
//
// Path: javabank-core/src/main/java/org/mbtest/javabank/http/imposters/Imposter.java
// public class Imposter extends HashMap {
// private static final String PORT = "port";
// private static final String PROTOCOL = "protocol";
// private static final String STUBS = "stubs";
//
// public Imposter() {
// this.put(PROTOCOL, "http");
// this.put(STUBS, newArrayList());
// }
//
// public static Imposter fromJSON(JSONObject json) {
// Imposter imposter = new Imposter();
// imposter.putAll(json);
//
// return imposter;
// }
//
// public static Imposter anImposter() {
// return new Imposter();
// }
//
// public Imposter onPort(int port) {
// this.put(PORT, port);
// return this;
// }
//
// public Imposter addStub(Stub stub) {
// getStubs().add(stub);
// return this;
// }
//
// public Imposter withStub(Stub stub) {
// this.remove(STUBS);
// this.put(STUBS, newArrayList());
// addStub(stub);
// return this;
// }
//
// public List<Stub> getStubs() {
// return ((List) get(STUBS));
// }
//
// public Stub getStub(int index) {
// return getStubs().get(index);
// }
//
// public JSONObject toJSON() {
// return new JSONObject(this);
// }
//
// public String toString() {
// return toJSON().toJSONString();
// }
//
// public int getPort() {
// return Integer.valueOf(String.valueOf(get(PORT)));
// }
// }
| import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Fail.fail;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.simple.parser.ParseException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mbtest.javabank.fluent.ImposterBuilder;
import org.mbtest.javabank.http.imposters.Imposter;
import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import com.mashape.unirest.request.GetRequest;
import com.mashape.unirest.request.HttpRequestWithBody;
import com.mashape.unirest.request.body.RequestBodyEntity; | private HttpRequestWithBody requestWithBody;
@Mock
private RequestBodyEntity requestBodyEntity;
@Mock
JsonNode value;
@Before
public void setup() {
PowerMockito.mockStatic(Unirest.class);
PowerMockito.mockStatic(ImposterParser.class);
}
@Test
public void shouldUseDefaultBaseUrlForDefaultConstructor() {
assertThat(client.getBaseUrl()).isEqualTo(Client.DEFAULT_BASE_URL);
}
@Test
public void shouldVerifyMountebankIsRunning() throws UnirestException {
when(Unirest.get(Client.DEFAULT_BASE_URL)).thenReturn(getRequest);
when(getRequest.asJson()).thenReturn(httpResponse);
when(httpResponse.getStatus()).thenReturn(Integer.valueOf(200));
assertThat(client.isMountebankRunning()).isEqualTo(true);
}
@Test
public void shouldCreateAnImposter() throws UnirestException { | // Path: javabank-core/src/main/java/org/mbtest/javabank/fluent/ImposterBuilder.java
// public class ImposterBuilder {
// private int port;
// private List<StubBuilder> stubBuilders = newArrayList();
//
// public static ImposterBuilder anImposter() {
// return new ImposterBuilder();
// }
//
// public ImposterBuilder onPort(int port) {
// this.port = port;
// return this;
// }
//
// public StubBuilder stub() {
// StubBuilder child = new StubBuilder(this);
// stubBuilders.add(child);
// return child;
// }
//
// public Imposter build() {
// Imposter imposter = new Imposter().onPort(port);
// for (StubBuilder stubBuilder : stubBuilders) {
// imposter.addStub(stubBuilder.build());
// }
// return imposter;
// }
// }
//
// Path: javabank-core/src/main/java/org/mbtest/javabank/http/imposters/Imposter.java
// public class Imposter extends HashMap {
// private static final String PORT = "port";
// private static final String PROTOCOL = "protocol";
// private static final String STUBS = "stubs";
//
// public Imposter() {
// this.put(PROTOCOL, "http");
// this.put(STUBS, newArrayList());
// }
//
// public static Imposter fromJSON(JSONObject json) {
// Imposter imposter = new Imposter();
// imposter.putAll(json);
//
// return imposter;
// }
//
// public static Imposter anImposter() {
// return new Imposter();
// }
//
// public Imposter onPort(int port) {
// this.put(PORT, port);
// return this;
// }
//
// public Imposter addStub(Stub stub) {
// getStubs().add(stub);
// return this;
// }
//
// public Imposter withStub(Stub stub) {
// this.remove(STUBS);
// this.put(STUBS, newArrayList());
// addStub(stub);
// return this;
// }
//
// public List<Stub> getStubs() {
// return ((List) get(STUBS));
// }
//
// public Stub getStub(int index) {
// return getStubs().get(index);
// }
//
// public JSONObject toJSON() {
// return new JSONObject(this);
// }
//
// public String toString() {
// return toJSON().toJSONString();
// }
//
// public int getPort() {
// return Integer.valueOf(String.valueOf(get(PORT)));
// }
// }
// Path: javabank-client/src/test/java/org/mbtest/javabank/ClientTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Fail.fail;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.simple.parser.ParseException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mbtest.javabank.fluent.ImposterBuilder;
import org.mbtest.javabank.http.imposters.Imposter;
import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import com.mashape.unirest.request.GetRequest;
import com.mashape.unirest.request.HttpRequestWithBody;
import com.mashape.unirest.request.body.RequestBodyEntity;
private HttpRequestWithBody requestWithBody;
@Mock
private RequestBodyEntity requestBodyEntity;
@Mock
JsonNode value;
@Before
public void setup() {
PowerMockito.mockStatic(Unirest.class);
PowerMockito.mockStatic(ImposterParser.class);
}
@Test
public void shouldUseDefaultBaseUrlForDefaultConstructor() {
assertThat(client.getBaseUrl()).isEqualTo(Client.DEFAULT_BASE_URL);
}
@Test
public void shouldVerifyMountebankIsRunning() throws UnirestException {
when(Unirest.get(Client.DEFAULT_BASE_URL)).thenReturn(getRequest);
when(getRequest.asJson()).thenReturn(httpResponse);
when(httpResponse.getStatus()).thenReturn(Integer.valueOf(200));
assertThat(client.isMountebankRunning()).isEqualTo(true);
}
@Test
public void shouldCreateAnImposter() throws UnirestException { | Imposter imposter = new Imposter(); |
thejamesthomas/javabank | javabank-client/src/test/java/org/mbtest/javabank/ClientTest.java | // Path: javabank-core/src/main/java/org/mbtest/javabank/fluent/ImposterBuilder.java
// public class ImposterBuilder {
// private int port;
// private List<StubBuilder> stubBuilders = newArrayList();
//
// public static ImposterBuilder anImposter() {
// return new ImposterBuilder();
// }
//
// public ImposterBuilder onPort(int port) {
// this.port = port;
// return this;
// }
//
// public StubBuilder stub() {
// StubBuilder child = new StubBuilder(this);
// stubBuilders.add(child);
// return child;
// }
//
// public Imposter build() {
// Imposter imposter = new Imposter().onPort(port);
// for (StubBuilder stubBuilder : stubBuilders) {
// imposter.addStub(stubBuilder.build());
// }
// return imposter;
// }
// }
//
// Path: javabank-core/src/main/java/org/mbtest/javabank/http/imposters/Imposter.java
// public class Imposter extends HashMap {
// private static final String PORT = "port";
// private static final String PROTOCOL = "protocol";
// private static final String STUBS = "stubs";
//
// public Imposter() {
// this.put(PROTOCOL, "http");
// this.put(STUBS, newArrayList());
// }
//
// public static Imposter fromJSON(JSONObject json) {
// Imposter imposter = new Imposter();
// imposter.putAll(json);
//
// return imposter;
// }
//
// public static Imposter anImposter() {
// return new Imposter();
// }
//
// public Imposter onPort(int port) {
// this.put(PORT, port);
// return this;
// }
//
// public Imposter addStub(Stub stub) {
// getStubs().add(stub);
// return this;
// }
//
// public Imposter withStub(Stub stub) {
// this.remove(STUBS);
// this.put(STUBS, newArrayList());
// addStub(stub);
// return this;
// }
//
// public List<Stub> getStubs() {
// return ((List) get(STUBS));
// }
//
// public Stub getStub(int index) {
// return getStubs().get(index);
// }
//
// public JSONObject toJSON() {
// return new JSONObject(this);
// }
//
// public String toString() {
// return toJSON().toJSONString();
// }
//
// public int getPort() {
// return Integer.valueOf(String.valueOf(get(PORT)));
// }
// }
| import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Fail.fail;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.simple.parser.ParseException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mbtest.javabank.fluent.ImposterBuilder;
import org.mbtest.javabank.http.imposters.Imposter;
import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import com.mashape.unirest.request.GetRequest;
import com.mashape.unirest.request.HttpRequestWithBody;
import com.mashape.unirest.request.body.RequestBodyEntity; | }
@Test
public void shouldCountTheNumberOfImposters() throws UnirestException {
JsonNode jsonNode = mock(JsonNode.class);
JSONObject jsonObject = mock(JSONObject.class);
JSONArray jsonArray = mock(JSONArray.class);
when(Unirest.get(Client.DEFAULT_BASE_URL + "/imposters")).thenReturn(getRequest);
when(getRequest.asJson()).thenReturn(httpResponse);
when(httpResponse.getBody()).thenReturn(jsonNode);
when(jsonNode.getObject()).thenReturn(jsonObject);
when(jsonObject.get("imposters")).thenReturn(jsonArray);
when(jsonArray.length()).thenReturn(Integer.valueOf(3));
assertThat(client.getImposterCount()).isEqualTo(3);
}
@Test
public void shouldDeleteAllImposters() throws UnirestException {
when(Unirest.delete(Client.DEFAULT_BASE_URL + "/imposters")).thenReturn(requestWithBody);
when(requestWithBody.asJson()).thenReturn(httpResponse);
when(httpResponse.getStatus()).thenReturn(Integer.valueOf(200));
assertThat(client.deleteAllImposters()).isEqualTo(200);
}
@Test
public void shouldGetAnImposter() throws ParseException, UnirestException {
int port = 5757;
String jsonString = "test string"; | // Path: javabank-core/src/main/java/org/mbtest/javabank/fluent/ImposterBuilder.java
// public class ImposterBuilder {
// private int port;
// private List<StubBuilder> stubBuilders = newArrayList();
//
// public static ImposterBuilder anImposter() {
// return new ImposterBuilder();
// }
//
// public ImposterBuilder onPort(int port) {
// this.port = port;
// return this;
// }
//
// public StubBuilder stub() {
// StubBuilder child = new StubBuilder(this);
// stubBuilders.add(child);
// return child;
// }
//
// public Imposter build() {
// Imposter imposter = new Imposter().onPort(port);
// for (StubBuilder stubBuilder : stubBuilders) {
// imposter.addStub(stubBuilder.build());
// }
// return imposter;
// }
// }
//
// Path: javabank-core/src/main/java/org/mbtest/javabank/http/imposters/Imposter.java
// public class Imposter extends HashMap {
// private static final String PORT = "port";
// private static final String PROTOCOL = "protocol";
// private static final String STUBS = "stubs";
//
// public Imposter() {
// this.put(PROTOCOL, "http");
// this.put(STUBS, newArrayList());
// }
//
// public static Imposter fromJSON(JSONObject json) {
// Imposter imposter = new Imposter();
// imposter.putAll(json);
//
// return imposter;
// }
//
// public static Imposter anImposter() {
// return new Imposter();
// }
//
// public Imposter onPort(int port) {
// this.put(PORT, port);
// return this;
// }
//
// public Imposter addStub(Stub stub) {
// getStubs().add(stub);
// return this;
// }
//
// public Imposter withStub(Stub stub) {
// this.remove(STUBS);
// this.put(STUBS, newArrayList());
// addStub(stub);
// return this;
// }
//
// public List<Stub> getStubs() {
// return ((List) get(STUBS));
// }
//
// public Stub getStub(int index) {
// return getStubs().get(index);
// }
//
// public JSONObject toJSON() {
// return new JSONObject(this);
// }
//
// public String toString() {
// return toJSON().toJSONString();
// }
//
// public int getPort() {
// return Integer.valueOf(String.valueOf(get(PORT)));
// }
// }
// Path: javabank-client/src/test/java/org/mbtest/javabank/ClientTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Fail.fail;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.simple.parser.ParseException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mbtest.javabank.fluent.ImposterBuilder;
import org.mbtest.javabank.http.imposters.Imposter;
import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import com.mashape.unirest.request.GetRequest;
import com.mashape.unirest.request.HttpRequestWithBody;
import com.mashape.unirest.request.body.RequestBodyEntity;
}
@Test
public void shouldCountTheNumberOfImposters() throws UnirestException {
JsonNode jsonNode = mock(JsonNode.class);
JSONObject jsonObject = mock(JSONObject.class);
JSONArray jsonArray = mock(JSONArray.class);
when(Unirest.get(Client.DEFAULT_BASE_URL + "/imposters")).thenReturn(getRequest);
when(getRequest.asJson()).thenReturn(httpResponse);
when(httpResponse.getBody()).thenReturn(jsonNode);
when(jsonNode.getObject()).thenReturn(jsonObject);
when(jsonObject.get("imposters")).thenReturn(jsonArray);
when(jsonArray.length()).thenReturn(Integer.valueOf(3));
assertThat(client.getImposterCount()).isEqualTo(3);
}
@Test
public void shouldDeleteAllImposters() throws UnirestException {
when(Unirest.delete(Client.DEFAULT_BASE_URL + "/imposters")).thenReturn(requestWithBody);
when(requestWithBody.asJson()).thenReturn(httpResponse);
when(httpResponse.getStatus()).thenReturn(Integer.valueOf(200));
assertThat(client.deleteAllImposters()).isEqualTo(200);
}
@Test
public void shouldGetAnImposter() throws ParseException, UnirestException {
int port = 5757;
String jsonString = "test string"; | Imposter expectedImposter = new ImposterBuilder().onPort(5757).build(); |
thejamesthomas/javabank | javabank-core/src/main/java/org/mbtest/javabank/fluent/ResponseTypeBuilder.java | // Path: javabank-core/src/main/java/org/mbtest/javabank/http/responses/Response.java
// public abstract class Response extends HashMap {
//
// public JSONObject getJSON() {
// return new JSONObject(this);
// }
//
// public String toString() {
// return getJSON().toJSONString();
// }
// }
| import org.mbtest.javabank.http.responses.Response; | package org.mbtest.javabank.fluent;
public abstract class ResponseTypeBuilder implements FluentBuilder {
private ResponseBuilder parent;
protected ResponseTypeBuilder(ResponseBuilder parent) {
this.parent = parent;
}
@Override
public ResponseBuilder end() {
return parent;
}
| // Path: javabank-core/src/main/java/org/mbtest/javabank/http/responses/Response.java
// public abstract class Response extends HashMap {
//
// public JSONObject getJSON() {
// return new JSONObject(this);
// }
//
// public String toString() {
// return getJSON().toJSONString();
// }
// }
// Path: javabank-core/src/main/java/org/mbtest/javabank/fluent/ResponseTypeBuilder.java
import org.mbtest.javabank.http.responses.Response;
package org.mbtest.javabank.fluent;
public abstract class ResponseTypeBuilder implements FluentBuilder {
private ResponseBuilder parent;
protected ResponseTypeBuilder(ResponseBuilder parent) {
this.parent = parent;
}
@Override
public ResponseBuilder end() {
return parent;
}
| abstract protected Response build(); |
thejamesthomas/javabank | javabank-core/src/main/java/org/mbtest/javabank/fluent/IsBuilder.java | // Path: javabank-core/src/main/java/org/mbtest/javabank/http/responses/Is.java
// public class Is extends Response {
// private static final String IS = "is";
// private static final String HEADERS = "headers";
// private static final String BODY = "body";
// private static final String STATUS_CODE = "statusCode";
// public static final String MODE = "_mode";
//
// private final Map<String, Object> data;
// private Map<String, String> headers;
//
// public Is() {
// headers = newHashMap();
// headers.put(HttpHeaders.CONNECTION, "close");
//
// this.data = newHashMap();
// this.data.put(STATUS_CODE, 200);
// this.data.put(HEADERS, headers);
//
// this.put(IS, data);
// withStatusCode(HttpStatus.SC_OK);
// withBody("");
// }
//
// public Is withStatusCode(int statusCode) {
// this.data.put("statusCode", statusCode);
// return this;
// }
//
// public Is withHeader(String name, String value) {
// this.headers.clear();
// addHeader(name, value);
// return this;
// }
//
// public Is addHeader(String name, String value) {
// this.headers.put(name, value);
// return this;
// }
//
// public Is withBody(String body) {
// this.data.put(BODY, body);
// return this;
// }
//
// public Is withMode(String mode){
// if(!Objects.isNull(mode)) {
// this.data.put(MODE, mode);
// }
// return this;
// }
//
// public Is withHeaders(Map<String, String> headers) {
// this.headers = headers;
// this.data.put(HEADERS, headers); // issue #5
// return this;
// }
//
// public int getStatusCode() {
// return Integer.valueOf(String.valueOf(this.data.get(STATUS_CODE)));
// }
//
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// public String getBody() {
// return (String) this.data.get(BODY);
// }
//
// public String getMode() {
// return (String) this.data.get(MODE);
// }
// }
| import org.mbtest.javabank.http.responses.Is;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap; | public IsBuilder(ResponseBuilder responseBuilder) {
super(responseBuilder);
}
public IsBuilder statusCode(int statusCode) {
this.statusCode = statusCode;
return this;
}
public IsBuilder header(String name, String value) {
headers.put(name, value);
return this;
}
public IsBuilder body(String body) {
this.body = body;
return this;
}
public IsBuilder body(File body) {
this.bodyFile = body;
return this;
}
public IsBuilder mode(String mode){
this.mode = mode;
return this;
}
@Override | // Path: javabank-core/src/main/java/org/mbtest/javabank/http/responses/Is.java
// public class Is extends Response {
// private static final String IS = "is";
// private static final String HEADERS = "headers";
// private static final String BODY = "body";
// private static final String STATUS_CODE = "statusCode";
// public static final String MODE = "_mode";
//
// private final Map<String, Object> data;
// private Map<String, String> headers;
//
// public Is() {
// headers = newHashMap();
// headers.put(HttpHeaders.CONNECTION, "close");
//
// this.data = newHashMap();
// this.data.put(STATUS_CODE, 200);
// this.data.put(HEADERS, headers);
//
// this.put(IS, data);
// withStatusCode(HttpStatus.SC_OK);
// withBody("");
// }
//
// public Is withStatusCode(int statusCode) {
// this.data.put("statusCode", statusCode);
// return this;
// }
//
// public Is withHeader(String name, String value) {
// this.headers.clear();
// addHeader(name, value);
// return this;
// }
//
// public Is addHeader(String name, String value) {
// this.headers.put(name, value);
// return this;
// }
//
// public Is withBody(String body) {
// this.data.put(BODY, body);
// return this;
// }
//
// public Is withMode(String mode){
// if(!Objects.isNull(mode)) {
// this.data.put(MODE, mode);
// }
// return this;
// }
//
// public Is withHeaders(Map<String, String> headers) {
// this.headers = headers;
// this.data.put(HEADERS, headers); // issue #5
// return this;
// }
//
// public int getStatusCode() {
// return Integer.valueOf(String.valueOf(this.data.get(STATUS_CODE)));
// }
//
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// public String getBody() {
// return (String) this.data.get(BODY);
// }
//
// public String getMode() {
// return (String) this.data.get(MODE);
// }
// }
// Path: javabank-core/src/main/java/org/mbtest/javabank/fluent/IsBuilder.java
import org.mbtest.javabank.http.responses.Is;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
public IsBuilder(ResponseBuilder responseBuilder) {
super(responseBuilder);
}
public IsBuilder statusCode(int statusCode) {
this.statusCode = statusCode;
return this;
}
public IsBuilder header(String name, String value) {
headers.put(name, value);
return this;
}
public IsBuilder body(String body) {
this.body = body;
return this;
}
public IsBuilder body(File body) {
this.bodyFile = body;
return this;
}
public IsBuilder mode(String mode){
this.mode = mode;
return this;
}
@Override | protected Is build() { |
KMax/cqels | src/main/java/org/deri/cqels/engine/GroupRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterOnQueryIter.java
// public class MappingIterOnQueryIter extends MappingIter {
// QueryIterator queryItr;
// public MappingIterOnQueryIter(ExecContext context, QueryIterator queryItr) {
// super(context);
// this.queryItr = queryItr;
// }
//
// @Override
// protected void closeIterator() {
// queryItr.close();
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return queryItr.hasNext();
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if(!queryItr.hasNext()) {
// return null;
// }
// return new Binding2Mapping(context, queryItr.next()) ;
// }
//
// @Override
// protected void requestCancel() {
// queryItr.cancel();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterOnQueryIter;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.QueryIterOnMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpGroup;
import com.hp.hpl.jena.sparql.core.VarExprList;
import com.hp.hpl.jena.sparql.engine.iterator.QueryIterGroup;
import com.hp.hpl.jena.sparql.expr.ExprAggregator; | package org.deri.cqels.engine;
/**
* This class implements the router with group-by operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class GroupRouter extends OpRouter1 {
private final VarExprList groupVars;
private final List<ExprAggregator> aggregators;
public GroupRouter(ExecContext context, OpGroup op, OpRouter sub) {
super(context, op, sub);
this.groupVars = ((OpGroup) op).getGroupVars();
this.aggregators = ((OpGroup) op).getAggregators();
}
@Override | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterOnQueryIter.java
// public class MappingIterOnQueryIter extends MappingIter {
// QueryIterator queryItr;
// public MappingIterOnQueryIter(ExecContext context, QueryIterator queryItr) {
// super(context);
// this.queryItr = queryItr;
// }
//
// @Override
// protected void closeIterator() {
// queryItr.close();
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return queryItr.hasNext();
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if(!queryItr.hasNext()) {
// return null;
// }
// return new Binding2Mapping(context, queryItr.next()) ;
// }
//
// @Override
// protected void requestCancel() {
// queryItr.cancel();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/GroupRouter.java
import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterOnQueryIter;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.QueryIterOnMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpGroup;
import com.hp.hpl.jena.sparql.core.VarExprList;
import com.hp.hpl.jena.sparql.engine.iterator.QueryIterGroup;
import com.hp.hpl.jena.sparql.expr.ExprAggregator;
package org.deri.cqels.engine;
/**
* This class implements the router with group-by operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class GroupRouter extends OpRouter1 {
private final VarExprList groupVars;
private final List<ExprAggregator> aggregators;
public GroupRouter(ExecContext context, OpGroup op, OpRouter sub) {
super(context, op, sub);
this.groupVars = ((OpGroup) op).getGroupVars();
this.aggregators = ((OpGroup) op).getAggregators();
}
@Override | public void route(Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/GroupRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterOnQueryIter.java
// public class MappingIterOnQueryIter extends MappingIter {
// QueryIterator queryItr;
// public MappingIterOnQueryIter(ExecContext context, QueryIterator queryItr) {
// super(context);
// this.queryItr = queryItr;
// }
//
// @Override
// protected void closeIterator() {
// queryItr.close();
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return queryItr.hasNext();
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if(!queryItr.hasNext()) {
// return null;
// }
// return new Binding2Mapping(context, queryItr.next()) ;
// }
//
// @Override
// protected void requestCancel() {
// queryItr.cancel();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterOnQueryIter;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.QueryIterOnMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpGroup;
import com.hp.hpl.jena.sparql.core.VarExprList;
import com.hp.hpl.jena.sparql.engine.iterator.QueryIterGroup;
import com.hp.hpl.jena.sparql.expr.ExprAggregator; | package org.deri.cqels.engine;
/**
* This class implements the router with group-by operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class GroupRouter extends OpRouter1 {
private final VarExprList groupVars;
private final List<ExprAggregator> aggregators;
public GroupRouter(ExecContext context, OpGroup op, OpRouter sub) {
super(context, op, sub);
this.groupVars = ((OpGroup) op).getGroupVars();
this.aggregators = ((OpGroup) op).getAggregators();
}
@Override
public void route(Mapping mapping) { | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterOnQueryIter.java
// public class MappingIterOnQueryIter extends MappingIter {
// QueryIterator queryItr;
// public MappingIterOnQueryIter(ExecContext context, QueryIterator queryItr) {
// super(context);
// this.queryItr = queryItr;
// }
//
// @Override
// protected void closeIterator() {
// queryItr.close();
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return queryItr.hasNext();
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if(!queryItr.hasNext()) {
// return null;
// }
// return new Binding2Mapping(context, queryItr.next()) ;
// }
//
// @Override
// protected void requestCancel() {
// queryItr.cancel();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/GroupRouter.java
import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterOnQueryIter;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.QueryIterOnMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpGroup;
import com.hp.hpl.jena.sparql.core.VarExprList;
import com.hp.hpl.jena.sparql.engine.iterator.QueryIterGroup;
import com.hp.hpl.jena.sparql.expr.ExprAggregator;
package org.deri.cqels.engine;
/**
* This class implements the router with group-by operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class GroupRouter extends OpRouter1 {
private final VarExprList groupVars;
private final List<ExprAggregator> aggregators;
public GroupRouter(ExecContext context, OpGroup op, OpRouter sub) {
super(context, op, sub);
this.groupVars = ((OpGroup) op).getGroupVars();
this.aggregators = ((OpGroup) op).getAggregators();
}
@Override
public void route(Mapping mapping) { | ProjectMapping project = new ProjectMapping( |
KMax/cqels | src/main/java/org/deri/cqels/engine/GroupRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterOnQueryIter.java
// public class MappingIterOnQueryIter extends MappingIter {
// QueryIterator queryItr;
// public MappingIterOnQueryIter(ExecContext context, QueryIterator queryItr) {
// super(context);
// this.queryItr = queryItr;
// }
//
// @Override
// protected void closeIterator() {
// queryItr.close();
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return queryItr.hasNext();
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if(!queryItr.hasNext()) {
// return null;
// }
// return new Binding2Mapping(context, queryItr.next()) ;
// }
//
// @Override
// protected void requestCancel() {
// queryItr.cancel();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterOnQueryIter;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.QueryIterOnMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpGroup;
import com.hp.hpl.jena.sparql.core.VarExprList;
import com.hp.hpl.jena.sparql.engine.iterator.QueryIterGroup;
import com.hp.hpl.jena.sparql.expr.ExprAggregator; | package org.deri.cqels.engine;
/**
* This class implements the router with group-by operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class GroupRouter extends OpRouter1 {
private final VarExprList groupVars;
private final List<ExprAggregator> aggregators;
public GroupRouter(ExecContext context, OpGroup op, OpRouter sub) {
super(context, op, sub);
this.groupVars = ((OpGroup) op).getGroupVars();
this.aggregators = ((OpGroup) op).getAggregators();
}
@Override
public void route(Mapping mapping) {
ProjectMapping project = new ProjectMapping(
context, mapping, groupVars.getVars()); | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterOnQueryIter.java
// public class MappingIterOnQueryIter extends MappingIter {
// QueryIterator queryItr;
// public MappingIterOnQueryIter(ExecContext context, QueryIterator queryItr) {
// super(context);
// this.queryItr = queryItr;
// }
//
// @Override
// protected void closeIterator() {
// queryItr.close();
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return queryItr.hasNext();
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if(!queryItr.hasNext()) {
// return null;
// }
// return new Binding2Mapping(context, queryItr.next()) ;
// }
//
// @Override
// protected void requestCancel() {
// queryItr.cancel();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/GroupRouter.java
import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterOnQueryIter;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.QueryIterOnMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpGroup;
import com.hp.hpl.jena.sparql.core.VarExprList;
import com.hp.hpl.jena.sparql.engine.iterator.QueryIterGroup;
import com.hp.hpl.jena.sparql.expr.ExprAggregator;
package org.deri.cqels.engine;
/**
* This class implements the router with group-by operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class GroupRouter extends OpRouter1 {
private final VarExprList groupVars;
private final List<ExprAggregator> aggregators;
public GroupRouter(ExecContext context, OpGroup op, OpRouter sub) {
super(context, op, sub);
this.groupVars = ((OpGroup) op).getGroupVars();
this.aggregators = ((OpGroup) op).getAggregators();
}
@Override
public void route(Mapping mapping) {
ProjectMapping project = new ProjectMapping(
context, mapping, groupVars.getVars()); | MappingIterator itr = calc(mapping.from().searchBuff4Match(project)); |
KMax/cqels | src/main/java/org/deri/cqels/engine/GroupRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterOnQueryIter.java
// public class MappingIterOnQueryIter extends MappingIter {
// QueryIterator queryItr;
// public MappingIterOnQueryIter(ExecContext context, QueryIterator queryItr) {
// super(context);
// this.queryItr = queryItr;
// }
//
// @Override
// protected void closeIterator() {
// queryItr.close();
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return queryItr.hasNext();
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if(!queryItr.hasNext()) {
// return null;
// }
// return new Binding2Mapping(context, queryItr.next()) ;
// }
//
// @Override
// protected void requestCancel() {
// queryItr.cancel();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterOnQueryIter;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.QueryIterOnMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpGroup;
import com.hp.hpl.jena.sparql.core.VarExprList;
import com.hp.hpl.jena.sparql.engine.iterator.QueryIterGroup;
import com.hp.hpl.jena.sparql.expr.ExprAggregator; | package org.deri.cqels.engine;
/**
* This class implements the router with group-by operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class GroupRouter extends OpRouter1 {
private final VarExprList groupVars;
private final List<ExprAggregator> aggregators;
public GroupRouter(ExecContext context, OpGroup op, OpRouter sub) {
super(context, op, sub);
this.groupVars = ((OpGroup) op).getGroupVars();
this.aggregators = ((OpGroup) op).getAggregators();
}
@Override
public void route(Mapping mapping) {
ProjectMapping project = new ProjectMapping(
context, mapping, groupVars.getVars());
MappingIterator itr = calc(mapping.from().searchBuff4Match(project));
while (itr.hasNext()) {
Mapping _mapping = itr.next();
_route(_mapping);
}
itr.close();
}
@Override
public MappingIterator searchBuff4Match(Mapping mapping) {
return calc(sub().searchBuff4Match(mapping));
}
private MappingIterator calc(MappingIterator itr) {
QueryIterGroup groupItrGroup = new QueryIterGroup(
new QueryIterOnMappingIter(context, itr),
groupVars, aggregators, context.getARQExCtx()); | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterOnQueryIter.java
// public class MappingIterOnQueryIter extends MappingIter {
// QueryIterator queryItr;
// public MappingIterOnQueryIter(ExecContext context, QueryIterator queryItr) {
// super(context);
// this.queryItr = queryItr;
// }
//
// @Override
// protected void closeIterator() {
// queryItr.close();
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return queryItr.hasNext();
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if(!queryItr.hasNext()) {
// return null;
// }
// return new Binding2Mapping(context, queryItr.next()) ;
// }
//
// @Override
// protected void requestCancel() {
// queryItr.cancel();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/GroupRouter.java
import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterOnQueryIter;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.QueryIterOnMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpGroup;
import com.hp.hpl.jena.sparql.core.VarExprList;
import com.hp.hpl.jena.sparql.engine.iterator.QueryIterGroup;
import com.hp.hpl.jena.sparql.expr.ExprAggregator;
package org.deri.cqels.engine;
/**
* This class implements the router with group-by operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class GroupRouter extends OpRouter1 {
private final VarExprList groupVars;
private final List<ExprAggregator> aggregators;
public GroupRouter(ExecContext context, OpGroup op, OpRouter sub) {
super(context, op, sub);
this.groupVars = ((OpGroup) op).getGroupVars();
this.aggregators = ((OpGroup) op).getAggregators();
}
@Override
public void route(Mapping mapping) {
ProjectMapping project = new ProjectMapping(
context, mapping, groupVars.getVars());
MappingIterator itr = calc(mapping.from().searchBuff4Match(project));
while (itr.hasNext()) {
Mapping _mapping = itr.next();
_route(_mapping);
}
itr.close();
}
@Override
public MappingIterator searchBuff4Match(Mapping mapping) {
return calc(sub().searchBuff4Match(mapping));
}
private MappingIterator calc(MappingIterator itr) {
QueryIterGroup groupItrGroup = new QueryIterGroup(
new QueryIterOnMappingIter(context, itr),
groupVars, aggregators, context.getARQExCtx()); | return new MappingIterOnQueryIter(context, groupItrGroup); |
KMax/cqels | src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
| import org.deri.cqels.data.Mapping; | package org.deri.cqels.engine.iterator;
public class NullMappingIter extends MappingIter {
private static NullMappingIter instance;
public NullMappingIter() {
super(null);
}
public static NullMappingIter instance() {
if(instance==null) instance=new NullMappingIter();
return instance;
}
@Override
protected void closeIterator() {
// TODO Auto-generated method stub
}
@Override
protected boolean hasNextMapping() {
// TODO Auto-generated method stub
return false;
}
@Override | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
import org.deri.cqels.data.Mapping;
package org.deri.cqels.engine.iterator;
public class NullMappingIter extends MappingIter {
private static NullMappingIter instance;
public NullMappingIter() {
super(null);
}
public static NullMappingIter instance() {
if(instance==null) instance=new NullMappingIter();
return instance;
}
@Override
protected void closeIterator() {
// TODO Auto-generated method stub
}
@Override
protected boolean hasNextMapping() {
// TODO Auto-generated method stub
return false;
}
@Override | protected Mapping moveToNextMapping() { |
KMax/cqels | src/main/java/org/deri/cqels/engine/JoinRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterMatch.java
// public class MappingIterMatch extends MappingIterProcessBinding {
// Mapping mapping;
// public MappingIterMatch(ExecContext context, MappingIterator mIter, Mapping mapping) {
// super(mIter, context);
// this.mapping = mapping;
// }
//
// @Override
// public Mapping accept(Mapping mapping) {
// //System.out.println("compa "+ mapping +" "+this.mapping.isCompatible(mapping) +" "+ this.mapping );
// if(this.mapping.isCompatible(mapping)) {
// return new MappingWrapped(context, mapping, this.mapping);
// }
// //TODO : check order of MappingWrapper initialization new MappingWrapped(context, this.mapping, mapping);
// return null;
// }
//
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingNestedLoopEqJoin.java
// public class MappingNestedLoopEqJoin extends MappingIter {
// private MappingIterator curItr,leftItr;
// private Mapping nextMapping;
// OpRouter leftRouter, rightRouter;
// public MappingNestedLoopEqJoin(ExecContext context, OpRouter leftRouter,
// OpRouter rightRouter) {
// super(context);
// this.leftRouter = leftRouter;
// leftItr = leftRouter.getBuff();
// this.rightRouter = rightRouter;
// //System.out.println("MappingNestedLoopEqJoin");
// }
//
// @Override
// protected void closeIterator() {
// leftItr.close();
// if(curItr != null) {
// curItr.close();
// }
// }
//
// @Override
// protected boolean hasNextMapping() {
// if(isFinished()) {
// return false;
// }
// if(nextMapping != null) {
// return true;
// }
// nextMapping = move2Next();
// return nextMapping != null;
// }
//
// //Move to next Mapping
// private Mapping move2Next() {
// //System.out.println("move cursor "+Thread.currentThread());
// while(true) {
// if(curItr != null) {
// if(curItr.hasNext()) {
// return curItr.nextMapping();
// }
// curItr.close();
// curItr = null;
// }
// curItr = eqJoinWorker();
// if(curItr == null) {
// return null;
// }
// //System.out.println("loop move2Next");
// }
// }
//
// private MappingIterator eqJoinWorker() {
// if(leftItr == null || !leftItr.hasNext()) {
// return null;//NullMappingIter.instance();
// }
// //System.out.println("call for another filter ");
// return rightRouter.searchBuff4Match(leftItr.next());
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if ( nextMapping == null ) {
// throw new ARQInternalErrorException("moveToNextMapping: slot empty but hasNext was true)") ;
// }
// Mapping m = nextMapping;
// nextMapping = move2Next();
// return m;
// }
//
// @Override
// protected void requestCancel() {
// performRequestCancel(leftItr);
// if(curItr != null) {
// performRequestCancel(curItr);
// }
// }
//
//
// }
| import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterMatch;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.MappingNestedLoopEqJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpJoin; | package org.deri.cqels.engine;
/**
* This class implements a binary router processing the join operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter2
*/
public class JoinRouter extends OpRouter2 {
public JoinRouter(ExecContext context, OpJoin op,
OpRouter left, OpRouter right) {
super(context, op, left, right);
}
@Override | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterMatch.java
// public class MappingIterMatch extends MappingIterProcessBinding {
// Mapping mapping;
// public MappingIterMatch(ExecContext context, MappingIterator mIter, Mapping mapping) {
// super(mIter, context);
// this.mapping = mapping;
// }
//
// @Override
// public Mapping accept(Mapping mapping) {
// //System.out.println("compa "+ mapping +" "+this.mapping.isCompatible(mapping) +" "+ this.mapping );
// if(this.mapping.isCompatible(mapping)) {
// return new MappingWrapped(context, mapping, this.mapping);
// }
// //TODO : check order of MappingWrapper initialization new MappingWrapped(context, this.mapping, mapping);
// return null;
// }
//
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingNestedLoopEqJoin.java
// public class MappingNestedLoopEqJoin extends MappingIter {
// private MappingIterator curItr,leftItr;
// private Mapping nextMapping;
// OpRouter leftRouter, rightRouter;
// public MappingNestedLoopEqJoin(ExecContext context, OpRouter leftRouter,
// OpRouter rightRouter) {
// super(context);
// this.leftRouter = leftRouter;
// leftItr = leftRouter.getBuff();
// this.rightRouter = rightRouter;
// //System.out.println("MappingNestedLoopEqJoin");
// }
//
// @Override
// protected void closeIterator() {
// leftItr.close();
// if(curItr != null) {
// curItr.close();
// }
// }
//
// @Override
// protected boolean hasNextMapping() {
// if(isFinished()) {
// return false;
// }
// if(nextMapping != null) {
// return true;
// }
// nextMapping = move2Next();
// return nextMapping != null;
// }
//
// //Move to next Mapping
// private Mapping move2Next() {
// //System.out.println("move cursor "+Thread.currentThread());
// while(true) {
// if(curItr != null) {
// if(curItr.hasNext()) {
// return curItr.nextMapping();
// }
// curItr.close();
// curItr = null;
// }
// curItr = eqJoinWorker();
// if(curItr == null) {
// return null;
// }
// //System.out.println("loop move2Next");
// }
// }
//
// private MappingIterator eqJoinWorker() {
// if(leftItr == null || !leftItr.hasNext()) {
// return null;//NullMappingIter.instance();
// }
// //System.out.println("call for another filter ");
// return rightRouter.searchBuff4Match(leftItr.next());
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if ( nextMapping == null ) {
// throw new ARQInternalErrorException("moveToNextMapping: slot empty but hasNext was true)") ;
// }
// Mapping m = nextMapping;
// nextMapping = move2Next();
// return m;
// }
//
// @Override
// protected void requestCancel() {
// performRequestCancel(leftItr);
// if(curItr != null) {
// performRequestCancel(curItr);
// }
// }
//
//
// }
// Path: src/main/java/org/deri/cqels/engine/JoinRouter.java
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterMatch;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.MappingNestedLoopEqJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpJoin;
package org.deri.cqels.engine;
/**
* This class implements a binary router processing the join operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter2
*/
public class JoinRouter extends OpRouter2 {
public JoinRouter(ExecContext context, OpJoin op,
OpRouter left, OpRouter right) {
super(context, op, left, right);
}
@Override | public void route(Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/JoinRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterMatch.java
// public class MappingIterMatch extends MappingIterProcessBinding {
// Mapping mapping;
// public MappingIterMatch(ExecContext context, MappingIterator mIter, Mapping mapping) {
// super(mIter, context);
// this.mapping = mapping;
// }
//
// @Override
// public Mapping accept(Mapping mapping) {
// //System.out.println("compa "+ mapping +" "+this.mapping.isCompatible(mapping) +" "+ this.mapping );
// if(this.mapping.isCompatible(mapping)) {
// return new MappingWrapped(context, mapping, this.mapping);
// }
// //TODO : check order of MappingWrapper initialization new MappingWrapped(context, this.mapping, mapping);
// return null;
// }
//
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingNestedLoopEqJoin.java
// public class MappingNestedLoopEqJoin extends MappingIter {
// private MappingIterator curItr,leftItr;
// private Mapping nextMapping;
// OpRouter leftRouter, rightRouter;
// public MappingNestedLoopEqJoin(ExecContext context, OpRouter leftRouter,
// OpRouter rightRouter) {
// super(context);
// this.leftRouter = leftRouter;
// leftItr = leftRouter.getBuff();
// this.rightRouter = rightRouter;
// //System.out.println("MappingNestedLoopEqJoin");
// }
//
// @Override
// protected void closeIterator() {
// leftItr.close();
// if(curItr != null) {
// curItr.close();
// }
// }
//
// @Override
// protected boolean hasNextMapping() {
// if(isFinished()) {
// return false;
// }
// if(nextMapping != null) {
// return true;
// }
// nextMapping = move2Next();
// return nextMapping != null;
// }
//
// //Move to next Mapping
// private Mapping move2Next() {
// //System.out.println("move cursor "+Thread.currentThread());
// while(true) {
// if(curItr != null) {
// if(curItr.hasNext()) {
// return curItr.nextMapping();
// }
// curItr.close();
// curItr = null;
// }
// curItr = eqJoinWorker();
// if(curItr == null) {
// return null;
// }
// //System.out.println("loop move2Next");
// }
// }
//
// private MappingIterator eqJoinWorker() {
// if(leftItr == null || !leftItr.hasNext()) {
// return null;//NullMappingIter.instance();
// }
// //System.out.println("call for another filter ");
// return rightRouter.searchBuff4Match(leftItr.next());
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if ( nextMapping == null ) {
// throw new ARQInternalErrorException("moveToNextMapping: slot empty but hasNext was true)") ;
// }
// Mapping m = nextMapping;
// nextMapping = move2Next();
// return m;
// }
//
// @Override
// protected void requestCancel() {
// performRequestCancel(leftItr);
// if(curItr != null) {
// performRequestCancel(curItr);
// }
// }
//
//
// }
| import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterMatch;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.MappingNestedLoopEqJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpJoin; | package org.deri.cqels.engine;
/**
* This class implements a binary router processing the join operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter2
*/
public class JoinRouter extends OpRouter2 {
public JoinRouter(ExecContext context, OpJoin op,
OpRouter left, OpRouter right) {
super(context, op, left, right);
}
@Override
public void route(Mapping mapping) {
OpRouter childR = getOtherChildRouter(mapping);
/*if(childR instanceof BDBGraphPatternRouter) {
(new RoutingRunner(mapping.getCtx(), childR.searchBuff4Match(mapping),this)).start();
return ;
}*/ | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterMatch.java
// public class MappingIterMatch extends MappingIterProcessBinding {
// Mapping mapping;
// public MappingIterMatch(ExecContext context, MappingIterator mIter, Mapping mapping) {
// super(mIter, context);
// this.mapping = mapping;
// }
//
// @Override
// public Mapping accept(Mapping mapping) {
// //System.out.println("compa "+ mapping +" "+this.mapping.isCompatible(mapping) +" "+ this.mapping );
// if(this.mapping.isCompatible(mapping)) {
// return new MappingWrapped(context, mapping, this.mapping);
// }
// //TODO : check order of MappingWrapper initialization new MappingWrapped(context, this.mapping, mapping);
// return null;
// }
//
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingNestedLoopEqJoin.java
// public class MappingNestedLoopEqJoin extends MappingIter {
// private MappingIterator curItr,leftItr;
// private Mapping nextMapping;
// OpRouter leftRouter, rightRouter;
// public MappingNestedLoopEqJoin(ExecContext context, OpRouter leftRouter,
// OpRouter rightRouter) {
// super(context);
// this.leftRouter = leftRouter;
// leftItr = leftRouter.getBuff();
// this.rightRouter = rightRouter;
// //System.out.println("MappingNestedLoopEqJoin");
// }
//
// @Override
// protected void closeIterator() {
// leftItr.close();
// if(curItr != null) {
// curItr.close();
// }
// }
//
// @Override
// protected boolean hasNextMapping() {
// if(isFinished()) {
// return false;
// }
// if(nextMapping != null) {
// return true;
// }
// nextMapping = move2Next();
// return nextMapping != null;
// }
//
// //Move to next Mapping
// private Mapping move2Next() {
// //System.out.println("move cursor "+Thread.currentThread());
// while(true) {
// if(curItr != null) {
// if(curItr.hasNext()) {
// return curItr.nextMapping();
// }
// curItr.close();
// curItr = null;
// }
// curItr = eqJoinWorker();
// if(curItr == null) {
// return null;
// }
// //System.out.println("loop move2Next");
// }
// }
//
// private MappingIterator eqJoinWorker() {
// if(leftItr == null || !leftItr.hasNext()) {
// return null;//NullMappingIter.instance();
// }
// //System.out.println("call for another filter ");
// return rightRouter.searchBuff4Match(leftItr.next());
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if ( nextMapping == null ) {
// throw new ARQInternalErrorException("moveToNextMapping: slot empty but hasNext was true)") ;
// }
// Mapping m = nextMapping;
// nextMapping = move2Next();
// return m;
// }
//
// @Override
// protected void requestCancel() {
// performRequestCancel(leftItr);
// if(curItr != null) {
// performRequestCancel(curItr);
// }
// }
//
//
// }
// Path: src/main/java/org/deri/cqels/engine/JoinRouter.java
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterMatch;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.MappingNestedLoopEqJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpJoin;
package org.deri.cqels.engine;
/**
* This class implements a binary router processing the join operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter2
*/
public class JoinRouter extends OpRouter2 {
public JoinRouter(ExecContext context, OpJoin op,
OpRouter left, OpRouter right) {
super(context, op, left, right);
}
@Override
public void route(Mapping mapping) {
OpRouter childR = getOtherChildRouter(mapping);
/*if(childR instanceof BDBGraphPatternRouter) {
(new RoutingRunner(mapping.getCtx(), childR.searchBuff4Match(mapping),this)).start();
return ;
}*/ | MappingIterator itr = childR.searchBuff4Match(mapping); |
KMax/cqels | src/main/java/org/deri/cqels/engine/JoinRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterMatch.java
// public class MappingIterMatch extends MappingIterProcessBinding {
// Mapping mapping;
// public MappingIterMatch(ExecContext context, MappingIterator mIter, Mapping mapping) {
// super(mIter, context);
// this.mapping = mapping;
// }
//
// @Override
// public Mapping accept(Mapping mapping) {
// //System.out.println("compa "+ mapping +" "+this.mapping.isCompatible(mapping) +" "+ this.mapping );
// if(this.mapping.isCompatible(mapping)) {
// return new MappingWrapped(context, mapping, this.mapping);
// }
// //TODO : check order of MappingWrapper initialization new MappingWrapped(context, this.mapping, mapping);
// return null;
// }
//
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingNestedLoopEqJoin.java
// public class MappingNestedLoopEqJoin extends MappingIter {
// private MappingIterator curItr,leftItr;
// private Mapping nextMapping;
// OpRouter leftRouter, rightRouter;
// public MappingNestedLoopEqJoin(ExecContext context, OpRouter leftRouter,
// OpRouter rightRouter) {
// super(context);
// this.leftRouter = leftRouter;
// leftItr = leftRouter.getBuff();
// this.rightRouter = rightRouter;
// //System.out.println("MappingNestedLoopEqJoin");
// }
//
// @Override
// protected void closeIterator() {
// leftItr.close();
// if(curItr != null) {
// curItr.close();
// }
// }
//
// @Override
// protected boolean hasNextMapping() {
// if(isFinished()) {
// return false;
// }
// if(nextMapping != null) {
// return true;
// }
// nextMapping = move2Next();
// return nextMapping != null;
// }
//
// //Move to next Mapping
// private Mapping move2Next() {
// //System.out.println("move cursor "+Thread.currentThread());
// while(true) {
// if(curItr != null) {
// if(curItr.hasNext()) {
// return curItr.nextMapping();
// }
// curItr.close();
// curItr = null;
// }
// curItr = eqJoinWorker();
// if(curItr == null) {
// return null;
// }
// //System.out.println("loop move2Next");
// }
// }
//
// private MappingIterator eqJoinWorker() {
// if(leftItr == null || !leftItr.hasNext()) {
// return null;//NullMappingIter.instance();
// }
// //System.out.println("call for another filter ");
// return rightRouter.searchBuff4Match(leftItr.next());
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if ( nextMapping == null ) {
// throw new ARQInternalErrorException("moveToNextMapping: slot empty but hasNext was true)") ;
// }
// Mapping m = nextMapping;
// nextMapping = move2Next();
// return m;
// }
//
// @Override
// protected void requestCancel() {
// performRequestCancel(leftItr);
// if(curItr != null) {
// performRequestCancel(curItr);
// }
// }
//
//
// }
| import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterMatch;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.MappingNestedLoopEqJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpJoin; | return ;
}*/
MappingIterator itr = childR.searchBuff4Match(mapping);
while (itr.hasNext()) {
Mapping _mapping = itr.next();
_route(_mapping);
}
itr.close();
}
public OpRouter getOtherChildRouter(Mapping mapping) {
if (left().getId() == mapping.from().getId()) {
return right();
}
return left();
}
@Override
public MappingIterator getBuff() {
OpRouter lR = left();
OpRouter rR = right();
//TODO: choose sort-merge join order
if (lR instanceof IndexedTripleRouter) {
new MappingNestedLoopEqJoin(context, rR, lR);
}
return new MappingNestedLoopEqJoin(context, lR, rR);
}
@Override
public MappingIterator searchBuff4Match(Mapping mapping) { | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterMatch.java
// public class MappingIterMatch extends MappingIterProcessBinding {
// Mapping mapping;
// public MappingIterMatch(ExecContext context, MappingIterator mIter, Mapping mapping) {
// super(mIter, context);
// this.mapping = mapping;
// }
//
// @Override
// public Mapping accept(Mapping mapping) {
// //System.out.println("compa "+ mapping +" "+this.mapping.isCompatible(mapping) +" "+ this.mapping );
// if(this.mapping.isCompatible(mapping)) {
// return new MappingWrapped(context, mapping, this.mapping);
// }
// //TODO : check order of MappingWrapper initialization new MappingWrapped(context, this.mapping, mapping);
// return null;
// }
//
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingNestedLoopEqJoin.java
// public class MappingNestedLoopEqJoin extends MappingIter {
// private MappingIterator curItr,leftItr;
// private Mapping nextMapping;
// OpRouter leftRouter, rightRouter;
// public MappingNestedLoopEqJoin(ExecContext context, OpRouter leftRouter,
// OpRouter rightRouter) {
// super(context);
// this.leftRouter = leftRouter;
// leftItr = leftRouter.getBuff();
// this.rightRouter = rightRouter;
// //System.out.println("MappingNestedLoopEqJoin");
// }
//
// @Override
// protected void closeIterator() {
// leftItr.close();
// if(curItr != null) {
// curItr.close();
// }
// }
//
// @Override
// protected boolean hasNextMapping() {
// if(isFinished()) {
// return false;
// }
// if(nextMapping != null) {
// return true;
// }
// nextMapping = move2Next();
// return nextMapping != null;
// }
//
// //Move to next Mapping
// private Mapping move2Next() {
// //System.out.println("move cursor "+Thread.currentThread());
// while(true) {
// if(curItr != null) {
// if(curItr.hasNext()) {
// return curItr.nextMapping();
// }
// curItr.close();
// curItr = null;
// }
// curItr = eqJoinWorker();
// if(curItr == null) {
// return null;
// }
// //System.out.println("loop move2Next");
// }
// }
//
// private MappingIterator eqJoinWorker() {
// if(leftItr == null || !leftItr.hasNext()) {
// return null;//NullMappingIter.instance();
// }
// //System.out.println("call for another filter ");
// return rightRouter.searchBuff4Match(leftItr.next());
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// if ( nextMapping == null ) {
// throw new ARQInternalErrorException("moveToNextMapping: slot empty but hasNext was true)") ;
// }
// Mapping m = nextMapping;
// nextMapping = move2Next();
// return m;
// }
//
// @Override
// protected void requestCancel() {
// performRequestCancel(leftItr);
// if(curItr != null) {
// performRequestCancel(curItr);
// }
// }
//
//
// }
// Path: src/main/java/org/deri/cqels/engine/JoinRouter.java
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterMatch;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.MappingNestedLoopEqJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpJoin;
return ;
}*/
MappingIterator itr = childR.searchBuff4Match(mapping);
while (itr.hasNext()) {
Mapping _mapping = itr.next();
_route(_mapping);
}
itr.close();
}
public OpRouter getOtherChildRouter(Mapping mapping) {
if (left().getId() == mapping.from().getId()) {
return right();
}
return left();
}
@Override
public MappingIterator getBuff() {
OpRouter lR = left();
OpRouter rR = right();
//TODO: choose sort-merge join order
if (lR instanceof IndexedTripleRouter) {
new MappingNestedLoopEqJoin(context, rR, lR);
}
return new MappingNestedLoopEqJoin(context, lR, rR);
}
@Override
public MappingIterator searchBuff4Match(Mapping mapping) { | return new MappingIterMatch(context, getBuff(), mapping); |
KMax/cqels | src/main/java/org/deri/cqels/engine/ContinuousConstruct.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
| import java.util.ArrayList;
import org.deri.cqels.data.Mapping;
import com.hp.hpl.jena.query.Query; | package org.deri.cqels.engine;
/**
* This class acts as a router standing in the root of the tree if the query is
* a construct-type
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter
* @see OpRouterBase
*/
public class ContinuousConstruct extends OpRouter1 {
private final Query query;
private final ArrayList<ConstructListener> listeners;
public ContinuousConstruct(ExecContext context, Query query,
OpRouter subRouter) {
super(context, subRouter.getOp(), subRouter);
this.query = query;
this.listeners = new ArrayList<ConstructListener>();
}
@Override | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
// Path: src/main/java/org/deri/cqels/engine/ContinuousConstruct.java
import java.util.ArrayList;
import org.deri.cqels.data.Mapping;
import com.hp.hpl.jena.query.Query;
package org.deri.cqels.engine;
/**
* This class acts as a router standing in the root of the tree if the query is
* a construct-type
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter
* @see OpRouterBase
*/
public class ContinuousConstruct extends OpRouter1 {
private final Query query;
private final ArrayList<ConstructListener> listeners;
public ContinuousConstruct(ExecContext context, Query query,
OpRouter subRouter) {
super(context, subRouter.getOp(), subRouter);
this.query = query;
this.listeners = new ArrayList<ConstructListener>();
}
@Override | public void route(Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/OpRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import com.hp.hpl.jena.sparql.algebra.Op; | package org.deri.cqels.engine;
/**
*This interface contains the behaviours of a router which is responsible to receive a mapping and route it
*to the higher node in the router-node tree
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public interface OpRouter {
/**
* Each specific router contains an operator what is parsed from the query
* This method will get that op out
*/
public Op getOp();
/**
* Each specific router contains a data buffer in the form of mappings
* This method will get that data buffer out
*/ | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/OpRouter.java
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import com.hp.hpl.jena.sparql.algebra.Op;
package org.deri.cqels.engine;
/**
*This interface contains the behaviours of a router which is responsible to receive a mapping and route it
*to the higher node in the router-node tree
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public interface OpRouter {
/**
* Each specific router contains an operator what is parsed from the query
* This method will get that op out
*/
public Op getOp();
/**
* Each specific router contains a data buffer in the form of mappings
* This method will get that data buffer out
*/ | public MappingIterator getBuff(); |
KMax/cqels | src/main/java/org/deri/cqels/engine/OpRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import com.hp.hpl.jena.sparql.algebra.Op; | package org.deri.cqels.engine;
/**
*This interface contains the behaviours of a router which is responsible to receive a mapping and route it
*to the higher node in the router-node tree
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public interface OpRouter {
/**
* Each specific router contains an operator what is parsed from the query
* This method will get that op out
*/
public Op getOp();
/**
* Each specific router contains a data buffer in the form of mappings
* This method will get that data buffer out
*/
public MappingIterator getBuff();
/**
* This method tries to search in the data mapping buffer whether there is any
* mapping that matches the specified mapping.
* @param mapping the specified mapping
* @return a mapping iterator of matched mappings in buffer
*/ | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/OpRouter.java
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import com.hp.hpl.jena.sparql.algebra.Op;
package org.deri.cqels.engine;
/**
*This interface contains the behaviours of a router which is responsible to receive a mapping and route it
*to the higher node in the router-node tree
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public interface OpRouter {
/**
* Each specific router contains an operator what is parsed from the query
* This method will get that op out
*/
public Op getOp();
/**
* Each specific router contains a data buffer in the form of mappings
* This method will get that data buffer out
*/
public MappingIterator getBuff();
/**
* This method tries to search in the data mapping buffer whether there is any
* mapping that matches the specified mapping.
* @param mapping the specified mapping
* @return a mapping iterator of matched mappings in buffer
*/ | public MappingIterator searchBuff4Match(Mapping mapping); |
KMax/cqels | src/main/java/org/deri/cqels/engine/ExecContext.java | // Path: src/main/java/org/deri/cqels/lang/cqels/ParserCQELS.java
// public class ParserCQELS extends SPARQLParser {
//
// public static final Syntax syntaxCQELS_01 = Syntax.make("http://deri.org/2011/05/query/CQELS_01");
//
// private interface Action {
//
// void exec(CQELSParser parser) throws Exception;
// }
//
// @Override
// protected Query parse$(final Query query, String queryString) {
// query.setSyntax(syntaxCQELS_01);
//
// Action action = new Action() {
// @Override
// public void exec(CQELSParser parser) throws Exception {
// parser.QueryUnit();
// }
// };
//
// perform(query, queryString, action);
// validateParsedQuery(query);
// return query;
// }
//
// public static Element parseElement(String string) {
// final Query query = new Query();
// Action action = new Action() {
// @Override
// public void exec(CQELSParser parser) throws Exception {
// Element el = parser.GroupGraphPattern();
// query.setQueryPattern(el);
// }
// };
// perform(query, string, action);
// return query.getQueryPattern();
// }
//
// public static Template parseTemplate(String string) {
// final Query query = new Query();
// Action action = new Action() {
// @Override
// public void exec(CQELSParser parser) throws Exception {
// Template t = parser.ConstructTemplate();
// query.setConstructTemplate(t);
// }
// };
// perform(query, string, action);
// return query.getConstructTemplate();
// }
//
// // All throwable handling.
// private static void perform(Query query, String string, Action action) {
// Reader in = new StringReader(string);
// CQELSParser parser = new CQELSParser(in);
//
// try {
// query.setStrict(true);
// parser.setQuery(query);
// action.exec(parser);
// } catch (com.hp.hpl.jena.sparql.lang.arq.ParseException ex) {
// throw new QueryParseException(ex.getMessage(),
// ex.currentToken.beginLine,
// ex.currentToken.beginColumn
// );
// } catch (com.hp.hpl.jena.sparql.lang.arq.TokenMgrError tErr) {
// // Last valid token : not the same as token error message - but this should not happen
// int col = parser.token.endColumn;
// int line = parser.token.endLine;
// throw new QueryParseException(tErr.getMessage(), line, col);
// } catch (QueryException ex) {
// throw ex;
// } catch (JenaException ex) {
// throw new QueryException(ex.getMessage(), ex);
// } catch (Error err) {
// // The token stream can throw errors.
// throw new QueryParseException(err.getMessage(), err, -1, -1);
// } catch (Throwable th) {
// Log.warn(ParserSPARQL11.class, "Unexpected throwable: ", th);
// throw new QueryException(th.getMessage(), th);
// }
// }
// }
| import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.sparql.algebra.Algebra;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.core.DatasetGraph;
import com.hp.hpl.jena.sparql.engine.ExecutionContext;
import com.hp.hpl.jena.sparql.engine.QueryIterator;
import com.hp.hpl.jena.tdb.TDBFactory;
import com.hp.hpl.jena.tdb.base.file.FileFactory;
import com.hp.hpl.jena.tdb.base.file.FileSet;
import com.hp.hpl.jena.tdb.base.file.Location;
import com.hp.hpl.jena.tdb.index.IndexFactory;
import com.hp.hpl.jena.tdb.solver.OpExecutorTDB1;
import com.hp.hpl.jena.tdb.store.DatasetGraphTDB;
import com.hp.hpl.jena.tdb.store.bulkloader.BulkLoader;
import com.hp.hpl.jena.tdb.store.nodetable.NodeTable;
import com.hp.hpl.jena.tdb.store.nodetable.NodeTableNative;
import com.hp.hpl.jena.tdb.sys.SystemTDB;
import com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Properties;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.deri.cqels.lang.cqels.ParserCQELS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | * @return cache configuration
*/
public Properties cacheConfig() {
return this.config;
}
/**
* @param idx
* @return router
*/
public void router(int idx, OpRouter router) {
this.routers.put(Integer.valueOf(idx), router);
}
/**
* @param idx
* @return router
*/
public OpRouter router(int idx) {
return this.routers.get(Integer.valueOf(idx));
}
/**
* register a select query
*
* @param queryStr query string
* @return this method return an instance of ContinuousSelect interface
*/
public ContinuousSelect registerSelect(String queryStr) {
Query query = new Query(); | // Path: src/main/java/org/deri/cqels/lang/cqels/ParserCQELS.java
// public class ParserCQELS extends SPARQLParser {
//
// public static final Syntax syntaxCQELS_01 = Syntax.make("http://deri.org/2011/05/query/CQELS_01");
//
// private interface Action {
//
// void exec(CQELSParser parser) throws Exception;
// }
//
// @Override
// protected Query parse$(final Query query, String queryString) {
// query.setSyntax(syntaxCQELS_01);
//
// Action action = new Action() {
// @Override
// public void exec(CQELSParser parser) throws Exception {
// parser.QueryUnit();
// }
// };
//
// perform(query, queryString, action);
// validateParsedQuery(query);
// return query;
// }
//
// public static Element parseElement(String string) {
// final Query query = new Query();
// Action action = new Action() {
// @Override
// public void exec(CQELSParser parser) throws Exception {
// Element el = parser.GroupGraphPattern();
// query.setQueryPattern(el);
// }
// };
// perform(query, string, action);
// return query.getQueryPattern();
// }
//
// public static Template parseTemplate(String string) {
// final Query query = new Query();
// Action action = new Action() {
// @Override
// public void exec(CQELSParser parser) throws Exception {
// Template t = parser.ConstructTemplate();
// query.setConstructTemplate(t);
// }
// };
// perform(query, string, action);
// return query.getConstructTemplate();
// }
//
// // All throwable handling.
// private static void perform(Query query, String string, Action action) {
// Reader in = new StringReader(string);
// CQELSParser parser = new CQELSParser(in);
//
// try {
// query.setStrict(true);
// parser.setQuery(query);
// action.exec(parser);
// } catch (com.hp.hpl.jena.sparql.lang.arq.ParseException ex) {
// throw new QueryParseException(ex.getMessage(),
// ex.currentToken.beginLine,
// ex.currentToken.beginColumn
// );
// } catch (com.hp.hpl.jena.sparql.lang.arq.TokenMgrError tErr) {
// // Last valid token : not the same as token error message - but this should not happen
// int col = parser.token.endColumn;
// int line = parser.token.endLine;
// throw new QueryParseException(tErr.getMessage(), line, col);
// } catch (QueryException ex) {
// throw ex;
// } catch (JenaException ex) {
// throw new QueryException(ex.getMessage(), ex);
// } catch (Error err) {
// // The token stream can throw errors.
// throw new QueryParseException(err.getMessage(), err, -1, -1);
// } catch (Throwable th) {
// Log.warn(ParserSPARQL11.class, "Unexpected throwable: ", th);
// throw new QueryException(th.getMessage(), th);
// }
// }
// }
// Path: src/main/java/org/deri/cqels/engine/ExecContext.java
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.sparql.algebra.Algebra;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.core.DatasetGraph;
import com.hp.hpl.jena.sparql.engine.ExecutionContext;
import com.hp.hpl.jena.sparql.engine.QueryIterator;
import com.hp.hpl.jena.tdb.TDBFactory;
import com.hp.hpl.jena.tdb.base.file.FileFactory;
import com.hp.hpl.jena.tdb.base.file.FileSet;
import com.hp.hpl.jena.tdb.base.file.Location;
import com.hp.hpl.jena.tdb.index.IndexFactory;
import com.hp.hpl.jena.tdb.solver.OpExecutorTDB1;
import com.hp.hpl.jena.tdb.store.DatasetGraphTDB;
import com.hp.hpl.jena.tdb.store.bulkloader.BulkLoader;
import com.hp.hpl.jena.tdb.store.nodetable.NodeTable;
import com.hp.hpl.jena.tdb.store.nodetable.NodeTableNative;
import com.hp.hpl.jena.tdb.sys.SystemTDB;
import com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Properties;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.deri.cqels.lang.cqels.ParserCQELS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @return cache configuration
*/
public Properties cacheConfig() {
return this.config;
}
/**
* @param idx
* @return router
*/
public void router(int idx, OpRouter router) {
this.routers.put(Integer.valueOf(idx), router);
}
/**
* @param idx
* @return router
*/
public OpRouter router(int idx) {
return this.routers.get(Integer.valueOf(idx));
}
/**
* register a select query
*
* @param queryStr query string
* @return this method return an instance of ContinuousSelect interface
*/
public ContinuousSelect registerSelect(String queryStr) {
Query query = new Query(); | ParserCQELS parser = new ParserCQELS(); |
KMax/cqels | src/main/java/org/deri/cqels/engine/ConstructListener.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
| import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.deri.cqels.data.Mapping;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.graph.TripleIterator;
import com.hp.hpl.jena.sparql.core.BasicPattern;
import com.hp.hpl.jena.sparql.syntax.Template; | package org.deri.cqels.engine;
/**
* This class processes the mapping result for the CONSTRUCT-type query form
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see ContinuousListenerBase
*/
public abstract class ConstructListener implements ContinuousListener {
String uri;
Template template;
ExecContext context;
public static int count = 0;
public ConstructListener(ExecContext context, String streamURI) {
this.uri = streamURI;
this.context = context;
}
public ConstructListener(ExecContext context) {
this.context = context;
}
public void setTemplate(Template t) {
template = t;
}
| // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
// Path: src/main/java/org/deri/cqels/engine/ConstructListener.java
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.deri.cqels.data.Mapping;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.graph.TripleIterator;
import com.hp.hpl.jena.sparql.core.BasicPattern;
import com.hp.hpl.jena.sparql.syntax.Template;
package org.deri.cqels.engine;
/**
* This class processes the mapping result for the CONSTRUCT-type query form
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see ContinuousListenerBase
*/
public abstract class ConstructListener implements ContinuousListener {
String uri;
Template template;
ExecContext context;
public static int count = 0;
public ConstructListener(ExecContext context, String streamURI) {
this.uri = streamURI;
this.context = context;
}
public ConstructListener(ExecContext context) {
this.context = context;
}
public void setTemplate(Template t) {
template = t;
}
| public void update(Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/HeuristicRoutingPolicy.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/ElementStreamGraph.java
// public class ElementStreamGraph extends ElementNamedGraph {
// private Window window;
// public ElementStreamGraph(Node n, Window w, Element el) {
// super(n, el);
// window = w;
// }
//
// public Window getWindow() { return window; }
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/OpStream.java
// public class OpStream extends OpQuadPattern {
// Window window;
// public OpStream(Node node,BasicPattern pattern, Window window) {
// super(node, pattern);
// this.window=window;
// }
//
// public OpStream(Node node, Triple triple, Window window) {
// this(node, BasicPattern.wrap(Arrays.asList(triple)), window);
// }
// public Window getWindow() {
// return window;
// }
// /*
// public void vars(Set<Var> acc){
// addVar(acc,getGraphNode());
// addVarsFromTriple(acc, ((OpTriple)getSubOp()).getTriple());
// }
//
// private static void addVarsFromTriple(Collection<Var> acc, Triple t)
// {
// addVar(acc, t.getSubject()) ;
// addVar(acc, t.getPredicate()) ;
// addVar(acc, t.getObject()) ;
// }
// private static void addVar(Collection<Var> acc, Node n)
// {
// if ( n == null )
// return ;
//
// if ( n.isVariable() )
// acc.add(Var.alloc(n)) ;
// }*/
//
// }
| import com.espertech.esper.client.EPStatement;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.algebra.OpVars;
import com.hp.hpl.jena.sparql.algebra.op.OpDistinct;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.algebra.op.OpFilter;
import com.hp.hpl.jena.sparql.algebra.op.OpJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Quad;
import com.hp.hpl.jena.sparql.core.TriplePath;
import com.hp.hpl.jena.sparql.core.Var;
import com.hp.hpl.jena.sparql.expr.Expr;
import com.hp.hpl.jena.sparql.expr.ExprAggregator;
import com.hp.hpl.jena.sparql.syntax.Element;
import com.hp.hpl.jena.sparql.syntax.ElementBind;
import com.hp.hpl.jena.sparql.syntax.ElementFilter;
import com.hp.hpl.jena.sparql.syntax.ElementGroup;
import com.hp.hpl.jena.sparql.syntax.ElementNamedGraph;
import com.hp.hpl.jena.sparql.syntax.ElementPathBlock;
import com.hp.hpl.jena.sparql.syntax.ElementTriplesBlock;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.jena.atlas.lib.SetUtils;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.lang.cqels.ElementStreamGraph;
import org.deri.cqels.lang.cqels.OpStream; | package org.deri.cqels.engine;
/**
* This class uses heuristic approach to build an execution plan
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public class HeuristicRoutingPolicy extends RoutingPolicyBase {
public HeuristicRoutingPolicy(ExecContext context) {
super(context);
this.compiler = new LogicCompiler();
this.compiler.set(this);
}
/**
* Creating the policy to route the mapping data
*
* @param query
* @return a router representing a tree of operators
*/
@Override
public OpRouter generateRoutingPolicy(Query query) {
ElementGroup group = (ElementGroup) query.getQueryPattern();
/* devide operators into three groups */
ArrayList<ElementFilter> filters = new ArrayList<ElementFilter>();
ArrayList<ElementBind> binds = new ArrayList<ElementBind>(); | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/ElementStreamGraph.java
// public class ElementStreamGraph extends ElementNamedGraph {
// private Window window;
// public ElementStreamGraph(Node n, Window w, Element el) {
// super(n, el);
// window = w;
// }
//
// public Window getWindow() { return window; }
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/OpStream.java
// public class OpStream extends OpQuadPattern {
// Window window;
// public OpStream(Node node,BasicPattern pattern, Window window) {
// super(node, pattern);
// this.window=window;
// }
//
// public OpStream(Node node, Triple triple, Window window) {
// this(node, BasicPattern.wrap(Arrays.asList(triple)), window);
// }
// public Window getWindow() {
// return window;
// }
// /*
// public void vars(Set<Var> acc){
// addVar(acc,getGraphNode());
// addVarsFromTriple(acc, ((OpTriple)getSubOp()).getTriple());
// }
//
// private static void addVarsFromTriple(Collection<Var> acc, Triple t)
// {
// addVar(acc, t.getSubject()) ;
// addVar(acc, t.getPredicate()) ;
// addVar(acc, t.getObject()) ;
// }
// private static void addVar(Collection<Var> acc, Node n)
// {
// if ( n == null )
// return ;
//
// if ( n.isVariable() )
// acc.add(Var.alloc(n)) ;
// }*/
//
// }
// Path: src/main/java/org/deri/cqels/engine/HeuristicRoutingPolicy.java
import com.espertech.esper.client.EPStatement;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.algebra.OpVars;
import com.hp.hpl.jena.sparql.algebra.op.OpDistinct;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.algebra.op.OpFilter;
import com.hp.hpl.jena.sparql.algebra.op.OpJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Quad;
import com.hp.hpl.jena.sparql.core.TriplePath;
import com.hp.hpl.jena.sparql.core.Var;
import com.hp.hpl.jena.sparql.expr.Expr;
import com.hp.hpl.jena.sparql.expr.ExprAggregator;
import com.hp.hpl.jena.sparql.syntax.Element;
import com.hp.hpl.jena.sparql.syntax.ElementBind;
import com.hp.hpl.jena.sparql.syntax.ElementFilter;
import com.hp.hpl.jena.sparql.syntax.ElementGroup;
import com.hp.hpl.jena.sparql.syntax.ElementNamedGraph;
import com.hp.hpl.jena.sparql.syntax.ElementPathBlock;
import com.hp.hpl.jena.sparql.syntax.ElementTriplesBlock;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.jena.atlas.lib.SetUtils;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.lang.cqels.ElementStreamGraph;
import org.deri.cqels.lang.cqels.OpStream;
package org.deri.cqels.engine;
/**
* This class uses heuristic approach to build an execution plan
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public class HeuristicRoutingPolicy extends RoutingPolicyBase {
public HeuristicRoutingPolicy(ExecContext context) {
super(context);
this.compiler = new LogicCompiler();
this.compiler.set(this);
}
/**
* Creating the policy to route the mapping data
*
* @param query
* @return a router representing a tree of operators
*/
@Override
public OpRouter generateRoutingPolicy(Query query) {
ElementGroup group = (ElementGroup) query.getQueryPattern();
/* devide operators into three groups */
ArrayList<ElementFilter> filters = new ArrayList<ElementFilter>();
ArrayList<ElementBind> binds = new ArrayList<ElementBind>(); | ArrayList<OpStream> streamOps = new ArrayList<OpStream>(); |
KMax/cqels | src/main/java/org/deri/cqels/engine/HeuristicRoutingPolicy.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/ElementStreamGraph.java
// public class ElementStreamGraph extends ElementNamedGraph {
// private Window window;
// public ElementStreamGraph(Node n, Window w, Element el) {
// super(n, el);
// window = w;
// }
//
// public Window getWindow() { return window; }
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/OpStream.java
// public class OpStream extends OpQuadPattern {
// Window window;
// public OpStream(Node node,BasicPattern pattern, Window window) {
// super(node, pattern);
// this.window=window;
// }
//
// public OpStream(Node node, Triple triple, Window window) {
// this(node, BasicPattern.wrap(Arrays.asList(triple)), window);
// }
// public Window getWindow() {
// return window;
// }
// /*
// public void vars(Set<Var> acc){
// addVar(acc,getGraphNode());
// addVarsFromTriple(acc, ((OpTriple)getSubOp()).getTriple());
// }
//
// private static void addVarsFromTriple(Collection<Var> acc, Triple t)
// {
// addVar(acc, t.getSubject()) ;
// addVar(acc, t.getPredicate()) ;
// addVar(acc, t.getObject()) ;
// }
// private static void addVar(Collection<Var> acc, Node n)
// {
// if ( n == null )
// return ;
//
// if ( n.isVariable() )
// acc.add(Var.alloc(n)) ;
// }*/
//
// }
| import com.espertech.esper.client.EPStatement;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.algebra.OpVars;
import com.hp.hpl.jena.sparql.algebra.op.OpDistinct;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.algebra.op.OpFilter;
import com.hp.hpl.jena.sparql.algebra.op.OpJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Quad;
import com.hp.hpl.jena.sparql.core.TriplePath;
import com.hp.hpl.jena.sparql.core.Var;
import com.hp.hpl.jena.sparql.expr.Expr;
import com.hp.hpl.jena.sparql.expr.ExprAggregator;
import com.hp.hpl.jena.sparql.syntax.Element;
import com.hp.hpl.jena.sparql.syntax.ElementBind;
import com.hp.hpl.jena.sparql.syntax.ElementFilter;
import com.hp.hpl.jena.sparql.syntax.ElementGroup;
import com.hp.hpl.jena.sparql.syntax.ElementNamedGraph;
import com.hp.hpl.jena.sparql.syntax.ElementPathBlock;
import com.hp.hpl.jena.sparql.syntax.ElementTriplesBlock;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.jena.atlas.lib.SetUtils;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.lang.cqels.ElementStreamGraph;
import org.deri.cqels.lang.cqels.OpStream; | package org.deri.cqels.engine;
/**
* This class uses heuristic approach to build an execution plan
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public class HeuristicRoutingPolicy extends RoutingPolicyBase {
public HeuristicRoutingPolicy(ExecContext context) {
super(context);
this.compiler = new LogicCompiler();
this.compiler.set(this);
}
/**
* Creating the policy to route the mapping data
*
* @param query
* @return a router representing a tree of operators
*/
@Override
public OpRouter generateRoutingPolicy(Query query) {
ElementGroup group = (ElementGroup) query.getQueryPattern();
/* devide operators into three groups */
ArrayList<ElementFilter> filters = new ArrayList<ElementFilter>();
ArrayList<ElementBind> binds = new ArrayList<ElementBind>();
ArrayList<OpStream> streamOps = new ArrayList<OpStream>();
ArrayList<ElementNamedGraph> graphOps = new ArrayList<ElementNamedGraph>();
ArrayList<Op> others = new ArrayList<Op>();
for (Element el : group.getElements()) {
if (el instanceof ElementFilter) {
filters.add((ElementFilter) el);
continue;
}
if (el instanceof ElementBind) {
binds.add((ElementBind) el);
continue;
} | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/ElementStreamGraph.java
// public class ElementStreamGraph extends ElementNamedGraph {
// private Window window;
// public ElementStreamGraph(Node n, Window w, Element el) {
// super(n, el);
// window = w;
// }
//
// public Window getWindow() { return window; }
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/OpStream.java
// public class OpStream extends OpQuadPattern {
// Window window;
// public OpStream(Node node,BasicPattern pattern, Window window) {
// super(node, pattern);
// this.window=window;
// }
//
// public OpStream(Node node, Triple triple, Window window) {
// this(node, BasicPattern.wrap(Arrays.asList(triple)), window);
// }
// public Window getWindow() {
// return window;
// }
// /*
// public void vars(Set<Var> acc){
// addVar(acc,getGraphNode());
// addVarsFromTriple(acc, ((OpTriple)getSubOp()).getTriple());
// }
//
// private static void addVarsFromTriple(Collection<Var> acc, Triple t)
// {
// addVar(acc, t.getSubject()) ;
// addVar(acc, t.getPredicate()) ;
// addVar(acc, t.getObject()) ;
// }
// private static void addVar(Collection<Var> acc, Node n)
// {
// if ( n == null )
// return ;
//
// if ( n.isVariable() )
// acc.add(Var.alloc(n)) ;
// }*/
//
// }
// Path: src/main/java/org/deri/cqels/engine/HeuristicRoutingPolicy.java
import com.espertech.esper.client.EPStatement;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.algebra.OpVars;
import com.hp.hpl.jena.sparql.algebra.op.OpDistinct;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.algebra.op.OpFilter;
import com.hp.hpl.jena.sparql.algebra.op.OpJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Quad;
import com.hp.hpl.jena.sparql.core.TriplePath;
import com.hp.hpl.jena.sparql.core.Var;
import com.hp.hpl.jena.sparql.expr.Expr;
import com.hp.hpl.jena.sparql.expr.ExprAggregator;
import com.hp.hpl.jena.sparql.syntax.Element;
import com.hp.hpl.jena.sparql.syntax.ElementBind;
import com.hp.hpl.jena.sparql.syntax.ElementFilter;
import com.hp.hpl.jena.sparql.syntax.ElementGroup;
import com.hp.hpl.jena.sparql.syntax.ElementNamedGraph;
import com.hp.hpl.jena.sparql.syntax.ElementPathBlock;
import com.hp.hpl.jena.sparql.syntax.ElementTriplesBlock;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.jena.atlas.lib.SetUtils;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.lang.cqels.ElementStreamGraph;
import org.deri.cqels.lang.cqels.OpStream;
package org.deri.cqels.engine;
/**
* This class uses heuristic approach to build an execution plan
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public class HeuristicRoutingPolicy extends RoutingPolicyBase {
public HeuristicRoutingPolicy(ExecContext context) {
super(context);
this.compiler = new LogicCompiler();
this.compiler.set(this);
}
/**
* Creating the policy to route the mapping data
*
* @param query
* @return a router representing a tree of operators
*/
@Override
public OpRouter generateRoutingPolicy(Query query) {
ElementGroup group = (ElementGroup) query.getQueryPattern();
/* devide operators into three groups */
ArrayList<ElementFilter> filters = new ArrayList<ElementFilter>();
ArrayList<ElementBind> binds = new ArrayList<ElementBind>();
ArrayList<OpStream> streamOps = new ArrayList<OpStream>();
ArrayList<ElementNamedGraph> graphOps = new ArrayList<ElementNamedGraph>();
ArrayList<Op> others = new ArrayList<Op>();
for (Element el : group.getElements()) {
if (el instanceof ElementFilter) {
filters.add((ElementFilter) el);
continue;
}
if (el instanceof ElementBind) {
binds.add((ElementBind) el);
continue;
} | if (el instanceof ElementStreamGraph) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/HeuristicRoutingPolicy.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/ElementStreamGraph.java
// public class ElementStreamGraph extends ElementNamedGraph {
// private Window window;
// public ElementStreamGraph(Node n, Window w, Element el) {
// super(n, el);
// window = w;
// }
//
// public Window getWindow() { return window; }
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/OpStream.java
// public class OpStream extends OpQuadPattern {
// Window window;
// public OpStream(Node node,BasicPattern pattern, Window window) {
// super(node, pattern);
// this.window=window;
// }
//
// public OpStream(Node node, Triple triple, Window window) {
// this(node, BasicPattern.wrap(Arrays.asList(triple)), window);
// }
// public Window getWindow() {
// return window;
// }
// /*
// public void vars(Set<Var> acc){
// addVar(acc,getGraphNode());
// addVarsFromTriple(acc, ((OpTriple)getSubOp()).getTriple());
// }
//
// private static void addVarsFromTriple(Collection<Var> acc, Triple t)
// {
// addVar(acc, t.getSubject()) ;
// addVar(acc, t.getPredicate()) ;
// addVar(acc, t.getObject()) ;
// }
// private static void addVar(Collection<Var> acc, Node n)
// {
// if ( n == null )
// return ;
//
// if ( n.isVariable() )
// acc.add(Var.alloc(n)) ;
// }*/
//
// }
| import com.espertech.esper.client.EPStatement;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.algebra.OpVars;
import com.hp.hpl.jena.sparql.algebra.op.OpDistinct;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.algebra.op.OpFilter;
import com.hp.hpl.jena.sparql.algebra.op.OpJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Quad;
import com.hp.hpl.jena.sparql.core.TriplePath;
import com.hp.hpl.jena.sparql.core.Var;
import com.hp.hpl.jena.sparql.expr.Expr;
import com.hp.hpl.jena.sparql.expr.ExprAggregator;
import com.hp.hpl.jena.sparql.syntax.Element;
import com.hp.hpl.jena.sparql.syntax.ElementBind;
import com.hp.hpl.jena.sparql.syntax.ElementFilter;
import com.hp.hpl.jena.sparql.syntax.ElementGroup;
import com.hp.hpl.jena.sparql.syntax.ElementNamedGraph;
import com.hp.hpl.jena.sparql.syntax.ElementPathBlock;
import com.hp.hpl.jena.sparql.syntax.ElementTriplesBlock;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.jena.atlas.lib.SetUtils;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.lang.cqels.ElementStreamGraph;
import org.deri.cqels.lang.cqels.OpStream; | //return compileModifiers(query, througRouter);
return compiler.compileModifiers(query, througRouter);
}
/**
* create the relationship between 2 router nodes. This version uses hash
* table to identify which router will be the next for the mapping to go
*
* @param from the departing router
* @param newRouter the arriving router
* @return the arriving router
*/
@Override
public OpRouter addRouter(OpRouter from, OpRouter newRouter) {
next.put(from.getId(), newRouter);
return newRouter;
}
@Override
public void removeRouter(OpRouter from, OpRouter to) {
next.remove(from.getId(), to);
}
/**
* get the next router from the current router
*
* @param curRouter current router
* @param mapping
* @return the next router
*/ | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/ElementStreamGraph.java
// public class ElementStreamGraph extends ElementNamedGraph {
// private Window window;
// public ElementStreamGraph(Node n, Window w, Element el) {
// super(n, el);
// window = w;
// }
//
// public Window getWindow() { return window; }
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/OpStream.java
// public class OpStream extends OpQuadPattern {
// Window window;
// public OpStream(Node node,BasicPattern pattern, Window window) {
// super(node, pattern);
// this.window=window;
// }
//
// public OpStream(Node node, Triple triple, Window window) {
// this(node, BasicPattern.wrap(Arrays.asList(triple)), window);
// }
// public Window getWindow() {
// return window;
// }
// /*
// public void vars(Set<Var> acc){
// addVar(acc,getGraphNode());
// addVarsFromTriple(acc, ((OpTriple)getSubOp()).getTriple());
// }
//
// private static void addVarsFromTriple(Collection<Var> acc, Triple t)
// {
// addVar(acc, t.getSubject()) ;
// addVar(acc, t.getPredicate()) ;
// addVar(acc, t.getObject()) ;
// }
// private static void addVar(Collection<Var> acc, Node n)
// {
// if ( n == null )
// return ;
//
// if ( n.isVariable() )
// acc.add(Var.alloc(n)) ;
// }*/
//
// }
// Path: src/main/java/org/deri/cqels/engine/HeuristicRoutingPolicy.java
import com.espertech.esper.client.EPStatement;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.algebra.OpVars;
import com.hp.hpl.jena.sparql.algebra.op.OpDistinct;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.algebra.op.OpFilter;
import com.hp.hpl.jena.sparql.algebra.op.OpJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Quad;
import com.hp.hpl.jena.sparql.core.TriplePath;
import com.hp.hpl.jena.sparql.core.Var;
import com.hp.hpl.jena.sparql.expr.Expr;
import com.hp.hpl.jena.sparql.expr.ExprAggregator;
import com.hp.hpl.jena.sparql.syntax.Element;
import com.hp.hpl.jena.sparql.syntax.ElementBind;
import com.hp.hpl.jena.sparql.syntax.ElementFilter;
import com.hp.hpl.jena.sparql.syntax.ElementGroup;
import com.hp.hpl.jena.sparql.syntax.ElementNamedGraph;
import com.hp.hpl.jena.sparql.syntax.ElementPathBlock;
import com.hp.hpl.jena.sparql.syntax.ElementTriplesBlock;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.jena.atlas.lib.SetUtils;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.lang.cqels.ElementStreamGraph;
import org.deri.cqels.lang.cqels.OpStream;
//return compileModifiers(query, througRouter);
return compiler.compileModifiers(query, througRouter);
}
/**
* create the relationship between 2 router nodes. This version uses hash
* table to identify which router will be the next for the mapping to go
*
* @param from the departing router
* @param newRouter the arriving router
* @return the arriving router
*/
@Override
public OpRouter addRouter(OpRouter from, OpRouter newRouter) {
next.put(from.getId(), newRouter);
return newRouter;
}
@Override
public void removeRouter(OpRouter from, OpRouter to) {
next.remove(from.getId(), to);
}
/**
* get the next router from the current router
*
* @param curRouter current router
* @param mapping
* @return the next router
*/ | public OpRouter next(OpRouter curRouter, Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/ProjectRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Var; | package org.deri.cqels.engine;
/**
* This class implements the router with project operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class ProjectRouter extends OpRouter1 {
private final List<Var> vars;
public ProjectRouter(ExecContext context, OpProject op, OpRouter sub) {
super(context, op, sub);
vars = op.getVars();
}
@Override | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: src/main/java/org/deri/cqels/engine/ProjectRouter.java
import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Var;
package org.deri.cqels.engine;
/**
* This class implements the router with project operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class ProjectRouter extends OpRouter1 {
private final List<Var> vars;
public ProjectRouter(ExecContext context, OpProject op, OpRouter sub) {
super(context, op, sub);
vars = op.getVars();
}
@Override | public void route(Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/ProjectRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Var; | package org.deri.cqels.engine;
/**
* This class implements the router with project operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class ProjectRouter extends OpRouter1 {
private final List<Var> vars;
public ProjectRouter(ExecContext context, OpProject op, OpRouter sub) {
super(context, op, sub);
vars = op.getVars();
}
@Override
public void route(Mapping mapping) { | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: src/main/java/org/deri/cqels/engine/ProjectRouter.java
import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Var;
package org.deri.cqels.engine;
/**
* This class implements the router with project operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class ProjectRouter extends OpRouter1 {
private final List<Var> vars;
public ProjectRouter(ExecContext context, OpProject op, OpRouter sub) {
super(context, op, sub);
vars = op.getVars();
}
@Override
public void route(Mapping mapping) { | _route(new ProjectMapping(context, mapping, vars)); |
KMax/cqels | src/main/java/org/deri/cqels/engine/ProjectRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Var; | package org.deri.cqels.engine;
/**
* This class implements the router with project operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class ProjectRouter extends OpRouter1 {
private final List<Var> vars;
public ProjectRouter(ExecContext context, OpProject op, OpRouter sub) {
super(context, op, sub);
vars = op.getVars();
}
@Override
public void route(Mapping mapping) {
_route(new ProjectMapping(context, mapping, vars));
}
@Override | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: src/main/java/org/deri/cqels/engine/ProjectRouter.java
import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Var;
package org.deri.cqels.engine;
/**
* This class implements the router with project operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class ProjectRouter extends OpRouter1 {
private final List<Var> vars;
public ProjectRouter(ExecContext context, OpProject op, OpRouter sub) {
super(context, op, sub);
vars = op.getVars();
}
@Override
public void route(Mapping mapping) {
_route(new ProjectMapping(context, mapping, vars));
}
@Override | public MappingIterator searchBuff4Match(Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/ProjectRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Var; | package org.deri.cqels.engine;
/**
* This class implements the router with project operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class ProjectRouter extends OpRouter1 {
private final List<Var> vars;
public ProjectRouter(ExecContext context, OpProject op, OpRouter sub) {
super(context, op, sub);
vars = op.getVars();
}
@Override
public void route(Mapping mapping) {
_route(new ProjectMapping(context, mapping, vars));
}
@Override
public MappingIterator searchBuff4Match(Mapping mapping) {
//TODO: check if necessary to call this method | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/ProjectMapping.java
// public class ProjectMapping extends MappingBase {
// Mapping mapping;
// List<Var> vars;
// public ProjectMapping(ExecContext context, Mapping mapping, List<Var> vars) {
// super(context);
// this.mapping = mapping;
// this.vars = vars;
// //TODO check if mapping contains all variable in vars
// }
//
// @Override
// public long get(Var var) {
// if(vars.contains(var)) {
// return mapping.get(var);
// }
// return -1;
// }
//
// @Override
// public Iterator<Var> vars() {
// return vars.iterator();
// }
//
// @Override
// public boolean containsKey(Object key) {
// for(Var _var:vars)
// if(_var.equals(key)) return true;
// return false;
// }
//
// @Override
// public boolean containsValue(Object value) {
// //TODO don't allow data access
// return false;
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// for(Var var:vars)
// if(mapping.get(var)!=(this.mapping.get(var))) return false;
// return true;
// }
//
// @Override
// public boolean isEmpty() {
//
// return vars==null||vars.isEmpty();
// }
//
// @Override
// public int size() {
// // TODO Auto-generated method stub
// return vars!=null?vars.size():0;
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: src/main/java/org/deri/cqels/engine/ProjectRouter.java
import java.util.List;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.ProjectMapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpProject;
import com.hp.hpl.jena.sparql.core.Var;
package org.deri.cqels.engine;
/**
* This class implements the router with project operator
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter1
*/
public class ProjectRouter extends OpRouter1 {
private final List<Var> vars;
public ProjectRouter(ExecContext context, OpProject op, OpRouter sub) {
super(context, op, sub);
vars = op.getVars();
}
@Override
public void route(Mapping mapping) {
_route(new ProjectMapping(context, mapping, vars));
}
@Override
public MappingIterator searchBuff4Match(Mapping mapping) {
//TODO: check if necessary to call this method | return NullMappingIter.instance(); |
KMax/cqels | src/main/java/org/deri/cqels/engine/RoutingPolicy.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
| import org.deri.cqels.data.Mapping;
import com.hp.hpl.jena.query.Query;
import java.util.HashMap;
import org.deri.cqels.data.Mapping;
import com.hp.hpl.jena.query.Query; | package org.deri.cqels.engine;
/**
* This interface contains set of methods which are behaviors of routing policy
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public interface RoutingPolicy
{ | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
// Path: src/main/java/org/deri/cqels/engine/RoutingPolicy.java
import org.deri.cqels.data.Mapping;
import com.hp.hpl.jena.query.Query;
import java.util.HashMap;
import org.deri.cqels.data.Mapping;
import com.hp.hpl.jena.query.Query;
package org.deri.cqels.engine;
/**
* This interface contains set of methods which are behaviors of routing policy
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public interface RoutingPolicy
{ | public OpRouter next(OpRouter curRouter, Mapping mapping); |
KMax/cqels | src/main/java/org/deri/cqels/engine/ThroughRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/MappingWrapped.java
// public class MappingWrapped extends MappingBase {
//
// Mapping mapping;
//
// public MappingWrapped(ExecContext context, Mapping mapping) {
// super(context);
// this.mapping = mapping;
// }
//
// public MappingWrapped(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(mapping.vars(), super.vars());
// }
// return mapping.vars();
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// if (!this.mapping.isCompatible(mapping)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import java.lang.reflect.Method;
import java.util.ArrayList;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.MappingWrapped;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package org.deri.cqels.engine;
public class ThroughRouter extends OpRouterBase {
private static final Logger logger = LoggerFactory.getLogger(
ThroughRouter.class);
private final ArrayList<OpRouter> dataflows;
public ThroughRouter(ExecContext context, ArrayList<OpRouter> dataflows) {
super(context, dataflows.get(0).getOp());
this.dataflows = dataflows;
}
@Override | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/MappingWrapped.java
// public class MappingWrapped extends MappingBase {
//
// Mapping mapping;
//
// public MappingWrapped(ExecContext context, Mapping mapping) {
// super(context);
// this.mapping = mapping;
// }
//
// public MappingWrapped(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(mapping.vars(), super.vars());
// }
// return mapping.vars();
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// if (!this.mapping.isCompatible(mapping)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/ThroughRouter.java
import java.lang.reflect.Method;
import java.util.ArrayList;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.MappingWrapped;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.deri.cqels.engine;
public class ThroughRouter extends OpRouterBase {
private static final Logger logger = LoggerFactory.getLogger(
ThroughRouter.class);
private final ArrayList<OpRouter> dataflows;
public ThroughRouter(ExecContext context, ArrayList<OpRouter> dataflows) {
super(context, dataflows.get(0).getOp());
this.dataflows = dataflows;
}
@Override | public void route(Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/ThroughRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/MappingWrapped.java
// public class MappingWrapped extends MappingBase {
//
// Mapping mapping;
//
// public MappingWrapped(ExecContext context, Mapping mapping) {
// super(context);
// this.mapping = mapping;
// }
//
// public MappingWrapped(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(mapping.vars(), super.vars());
// }
// return mapping.vars();
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// if (!this.mapping.isCompatible(mapping)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import java.lang.reflect.Method;
import java.util.ArrayList;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.MappingWrapped;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package org.deri.cqels.engine;
public class ThroughRouter extends OpRouterBase {
private static final Logger logger = LoggerFactory.getLogger(
ThroughRouter.class);
private final ArrayList<OpRouter> dataflows;
public ThroughRouter(ExecContext context, ArrayList<OpRouter> dataflows) {
super(context, dataflows.get(0).getOp());
this.dataflows = dataflows;
}
@Override
public void route(Mapping mapping) { | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/MappingWrapped.java
// public class MappingWrapped extends MappingBase {
//
// Mapping mapping;
//
// public MappingWrapped(ExecContext context, Mapping mapping) {
// super(context);
// this.mapping = mapping;
// }
//
// public MappingWrapped(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(mapping.vars(), super.vars());
// }
// return mapping.vars();
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// if (!this.mapping.isCompatible(mapping)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/ThroughRouter.java
import java.lang.reflect.Method;
import java.util.ArrayList;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.MappingWrapped;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.deri.cqels.engine;
public class ThroughRouter extends OpRouterBase {
private static final Logger logger = LoggerFactory.getLogger(
ThroughRouter.class);
private final ArrayList<OpRouter> dataflows;
public ThroughRouter(ExecContext context, ArrayList<OpRouter> dataflows) {
super(context, dataflows.get(0).getOp());
this.dataflows = dataflows;
}
@Override
public void route(Mapping mapping) { | _route(new MappingWrapped(context, mapping)); |
KMax/cqels | src/main/java/org/deri/cqels/engine/ThroughRouter.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/MappingWrapped.java
// public class MappingWrapped extends MappingBase {
//
// Mapping mapping;
//
// public MappingWrapped(ExecContext context, Mapping mapping) {
// super(context);
// this.mapping = mapping;
// }
//
// public MappingWrapped(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(mapping.vars(), super.vars());
// }
// return mapping.vars();
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// if (!this.mapping.isCompatible(mapping)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import java.lang.reflect.Method;
import java.util.ArrayList;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.MappingWrapped;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package org.deri.cqels.engine;
public class ThroughRouter extends OpRouterBase {
private static final Logger logger = LoggerFactory.getLogger(
ThroughRouter.class);
private final ArrayList<OpRouter> dataflows;
public ThroughRouter(ExecContext context, ArrayList<OpRouter> dataflows) {
super(context, dataflows.get(0).getOp());
this.dataflows = dataflows;
}
@Override
public void route(Mapping mapping) {
_route(new MappingWrapped(context, mapping));
}
@Override | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/data/MappingWrapped.java
// public class MappingWrapped extends MappingBase {
//
// Mapping mapping;
//
// public MappingWrapped(ExecContext context, Mapping mapping) {
// super(context);
// this.mapping = mapping;
// }
//
// public MappingWrapped(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(mapping.vars(), super.vars());
// }
// return mapping.vars();
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// if (!this.mapping.isCompatible(mapping)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/ThroughRouter.java
import java.lang.reflect.Method;
import java.util.ArrayList;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.data.MappingWrapped;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.deri.cqels.engine;
public class ThroughRouter extends OpRouterBase {
private static final Logger logger = LoggerFactory.getLogger(
ThroughRouter.class);
private final ArrayList<OpRouter> dataflows;
public ThroughRouter(ExecContext context, ArrayList<OpRouter> dataflows) {
super(context, dataflows.get(0).getOp());
this.dataflows = dataflows;
}
@Override
public void route(Mapping mapping) {
_route(new MappingWrapped(context, mapping));
}
@Override | public MappingIterator searchBuff4Match(Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/ExtendRouter.java | // Path: src/main/java/org/deri/cqels/data/ExtendMapping.java
// public class ExtendMapping extends MappingBase {
//
// Mapping mapping;
// VarExprList exprs;
//
// public ExtendMapping(ExecContext context, Mapping mapping, VarExprList exprs) {
// super(context);
// this.mapping = mapping;
// this.exprs = exprs;
// }
//
// public ExtendMapping(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// if (exprs.contains(var)) {
// NodeValue value = exprs.getExpr(var).eval(
// new Mapping2Binding(context, mapping),
// new FunctionEnvBase());
// return context.engine().encode(value.asNode());
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(
// IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator()), super.vars());
// }
// return IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator());
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// if (exprs.contains((Var) key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (mapping.containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// //TODO : need to be checked
// if (!mapping.isCompatible(this)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size() + exprs.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import org.deri.cqels.data.ExtendMapping;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.core.VarExprList; | package org.deri.cqels.engine;
public class ExtendRouter extends OpRouter1 {
private final VarExprList exprs;
public ExtendRouter(ExecContext context, OpExtend op, OpRouter sub) {
super(context, op, sub);
this.exprs = op.getVarExprList();
}
@Override | // Path: src/main/java/org/deri/cqels/data/ExtendMapping.java
// public class ExtendMapping extends MappingBase {
//
// Mapping mapping;
// VarExprList exprs;
//
// public ExtendMapping(ExecContext context, Mapping mapping, VarExprList exprs) {
// super(context);
// this.mapping = mapping;
// this.exprs = exprs;
// }
//
// public ExtendMapping(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// if (exprs.contains(var)) {
// NodeValue value = exprs.getExpr(var).eval(
// new Mapping2Binding(context, mapping),
// new FunctionEnvBase());
// return context.engine().encode(value.asNode());
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(
// IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator()), super.vars());
// }
// return IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator());
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// if (exprs.contains((Var) key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (mapping.containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// //TODO : need to be checked
// if (!mapping.isCompatible(this)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size() + exprs.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: src/main/java/org/deri/cqels/engine/ExtendRouter.java
import org.deri.cqels.data.ExtendMapping;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.core.VarExprList;
package org.deri.cqels.engine;
public class ExtendRouter extends OpRouter1 {
private final VarExprList exprs;
public ExtendRouter(ExecContext context, OpExtend op, OpRouter sub) {
super(context, op, sub);
this.exprs = op.getVarExprList();
}
@Override | public void route(Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/ExtendRouter.java | // Path: src/main/java/org/deri/cqels/data/ExtendMapping.java
// public class ExtendMapping extends MappingBase {
//
// Mapping mapping;
// VarExprList exprs;
//
// public ExtendMapping(ExecContext context, Mapping mapping, VarExprList exprs) {
// super(context);
// this.mapping = mapping;
// this.exprs = exprs;
// }
//
// public ExtendMapping(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// if (exprs.contains(var)) {
// NodeValue value = exprs.getExpr(var).eval(
// new Mapping2Binding(context, mapping),
// new FunctionEnvBase());
// return context.engine().encode(value.asNode());
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(
// IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator()), super.vars());
// }
// return IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator());
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// if (exprs.contains((Var) key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (mapping.containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// //TODO : need to be checked
// if (!mapping.isCompatible(this)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size() + exprs.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import org.deri.cqels.data.ExtendMapping;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.core.VarExprList; | package org.deri.cqels.engine;
public class ExtendRouter extends OpRouter1 {
private final VarExprList exprs;
public ExtendRouter(ExecContext context, OpExtend op, OpRouter sub) {
super(context, op, sub);
this.exprs = op.getVarExprList();
}
@Override
public void route(Mapping mapping) { | // Path: src/main/java/org/deri/cqels/data/ExtendMapping.java
// public class ExtendMapping extends MappingBase {
//
// Mapping mapping;
// VarExprList exprs;
//
// public ExtendMapping(ExecContext context, Mapping mapping, VarExprList exprs) {
// super(context);
// this.mapping = mapping;
// this.exprs = exprs;
// }
//
// public ExtendMapping(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// if (exprs.contains(var)) {
// NodeValue value = exprs.getExpr(var).eval(
// new Mapping2Binding(context, mapping),
// new FunctionEnvBase());
// return context.engine().encode(value.asNode());
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(
// IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator()), super.vars());
// }
// return IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator());
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// if (exprs.contains((Var) key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (mapping.containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// //TODO : need to be checked
// if (!mapping.isCompatible(this)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size() + exprs.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: src/main/java/org/deri/cqels/engine/ExtendRouter.java
import org.deri.cqels.data.ExtendMapping;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.core.VarExprList;
package org.deri.cqels.engine;
public class ExtendRouter extends OpRouter1 {
private final VarExprList exprs;
public ExtendRouter(ExecContext context, OpExtend op, OpRouter sub) {
super(context, op, sub);
this.exprs = op.getVarExprList();
}
@Override
public void route(Mapping mapping) { | _route(new ExtendMapping(context, mapping, exprs)); |
KMax/cqels | src/main/java/org/deri/cqels/engine/ExtendRouter.java | // Path: src/main/java/org/deri/cqels/data/ExtendMapping.java
// public class ExtendMapping extends MappingBase {
//
// Mapping mapping;
// VarExprList exprs;
//
// public ExtendMapping(ExecContext context, Mapping mapping, VarExprList exprs) {
// super(context);
// this.mapping = mapping;
// this.exprs = exprs;
// }
//
// public ExtendMapping(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// if (exprs.contains(var)) {
// NodeValue value = exprs.getExpr(var).eval(
// new Mapping2Binding(context, mapping),
// new FunctionEnvBase());
// return context.engine().encode(value.asNode());
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(
// IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator()), super.vars());
// }
// return IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator());
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// if (exprs.contains((Var) key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (mapping.containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// //TODO : need to be checked
// if (!mapping.isCompatible(this)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size() + exprs.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import org.deri.cqels.data.ExtendMapping;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.core.VarExprList; | package org.deri.cqels.engine;
public class ExtendRouter extends OpRouter1 {
private final VarExprList exprs;
public ExtendRouter(ExecContext context, OpExtend op, OpRouter sub) {
super(context, op, sub);
this.exprs = op.getVarExprList();
}
@Override
public void route(Mapping mapping) {
_route(new ExtendMapping(context, mapping, exprs));
}
@Override | // Path: src/main/java/org/deri/cqels/data/ExtendMapping.java
// public class ExtendMapping extends MappingBase {
//
// Mapping mapping;
// VarExprList exprs;
//
// public ExtendMapping(ExecContext context, Mapping mapping, VarExprList exprs) {
// super(context);
// this.mapping = mapping;
// this.exprs = exprs;
// }
//
// public ExtendMapping(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// if (exprs.contains(var)) {
// NodeValue value = exprs.getExpr(var).eval(
// new Mapping2Binding(context, mapping),
// new FunctionEnvBase());
// return context.engine().encode(value.asNode());
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(
// IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator()), super.vars());
// }
// return IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator());
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// if (exprs.contains((Var) key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (mapping.containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// //TODO : need to be checked
// if (!mapping.isCompatible(this)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size() + exprs.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: src/main/java/org/deri/cqels/engine/ExtendRouter.java
import org.deri.cqels.data.ExtendMapping;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.core.VarExprList;
package org.deri.cqels.engine;
public class ExtendRouter extends OpRouter1 {
private final VarExprList exprs;
public ExtendRouter(ExecContext context, OpExtend op, OpRouter sub) {
super(context, op, sub);
this.exprs = op.getVarExprList();
}
@Override
public void route(Mapping mapping) {
_route(new ExtendMapping(context, mapping, exprs));
}
@Override | public MappingIterator searchBuff4Match(Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/ExtendRouter.java | // Path: src/main/java/org/deri/cqels/data/ExtendMapping.java
// public class ExtendMapping extends MappingBase {
//
// Mapping mapping;
// VarExprList exprs;
//
// public ExtendMapping(ExecContext context, Mapping mapping, VarExprList exprs) {
// super(context);
// this.mapping = mapping;
// this.exprs = exprs;
// }
//
// public ExtendMapping(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// if (exprs.contains(var)) {
// NodeValue value = exprs.getExpr(var).eval(
// new Mapping2Binding(context, mapping),
// new FunctionEnvBase());
// return context.engine().encode(value.asNode());
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(
// IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator()), super.vars());
// }
// return IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator());
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// if (exprs.contains((Var) key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (mapping.containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// //TODO : need to be checked
// if (!mapping.isCompatible(this)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size() + exprs.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import org.deri.cqels.data.ExtendMapping;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.core.VarExprList; | package org.deri.cqels.engine;
public class ExtendRouter extends OpRouter1 {
private final VarExprList exprs;
public ExtendRouter(ExecContext context, OpExtend op, OpRouter sub) {
super(context, op, sub);
this.exprs = op.getVarExprList();
}
@Override
public void route(Mapping mapping) {
_route(new ExtendMapping(context, mapping, exprs));
}
@Override
public MappingIterator searchBuff4Match(Mapping mapping) {
//TODO: check if necessary to call this method | // Path: src/main/java/org/deri/cqels/data/ExtendMapping.java
// public class ExtendMapping extends MappingBase {
//
// Mapping mapping;
// VarExprList exprs;
//
// public ExtendMapping(ExecContext context, Mapping mapping, VarExprList exprs) {
// super(context);
// this.mapping = mapping;
// this.exprs = exprs;
// }
//
// public ExtendMapping(ExecContext context, Mapping mapping, Mapping parent) {
// super(context, parent);
// this.mapping = mapping;
// }
//
// @Override
// public long get(Var var) {
// if (mapping.get(var) != -1) {
// return mapping.get(var);
// }
// if (exprs.contains(var)) {
// NodeValue value = exprs.getExpr(var).eval(
// new Mapping2Binding(context, mapping),
// new FunctionEnvBase());
// return context.engine().encode(value.asNode());
// }
// return super.get(var);
// }
//
// @Override
// public Iterator<Var> vars() {
// if (hasParent()) {
// return IteratorConcat.concat(
// IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator()), super.vars());
// }
// return IteratorConcat.concat(mapping.vars(), exprs.getVars().iterator());
// }
//
// @Override
// public boolean containsKey(Object key) {
// if (mapping.containsKey(key)) {
// return true;
// }
// if (exprs.contains((Var) key)) {
// return true;
// }
// return super.containsKey(key);
// }
//
// @Override
// public boolean containsValue(Object value) {
// if (mapping.containsValue(value)) {
// return true;
// }
// return super.containsValue(value);
// }
//
// @Override
// public boolean isCompatible(Mapping mapping) {
// //TODO : need to be checked
// if (!mapping.isCompatible(this)) {
// return false;
// }
// return super.isCompatible(mapping);
// }
//
// @Override
// public boolean isEmpty() {
// if (mapping.isEmpty()) {
// return true;
// }
// return super.isEmpty();
// }
//
// @Override
// public int size() {
// return mapping.size() + super.size() + exprs.size();
// }
// }
//
// Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/NullMappingIter.java
// public class NullMappingIter extends MappingIter {
// private static NullMappingIter instance;
// public NullMappingIter() {
// super(null);
// }
//
// public static NullMappingIter instance() {
// if(instance==null) instance=new NullMappingIter();
// return instance;
// }
//
// @Override
// protected void closeIterator() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// protected boolean hasNextMapping() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// protected Mapping moveToNextMapping() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// protected void requestCancel() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: src/main/java/org/deri/cqels/engine/ExtendRouter.java
import org.deri.cqels.data.ExtendMapping;
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import org.deri.cqels.engine.iterator.NullMappingIter;
import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
import com.hp.hpl.jena.sparql.core.VarExprList;
package org.deri.cqels.engine;
public class ExtendRouter extends OpRouter1 {
private final VarExprList exprs;
public ExtendRouter(ExecContext context, OpExtend op, OpRouter sub) {
super(context, op, sub);
this.exprs = op.getVarExprList();
}
@Override
public void route(Mapping mapping) {
_route(new ExtendMapping(context, mapping, exprs));
}
@Override
public MappingIterator searchBuff4Match(Mapping mapping) {
//TODO: check if necessary to call this method | return NullMappingIter.instance(); |
KMax/cqels | src/main/java/org/deri/cqels/engine/FixedPlanner.java | // Path: src/main/java/org/deri/cqels/data/EnQuad.java
// public class EnQuad {
// long gID,sID,pID,oID;
// long time;
// public EnQuad(long gID,long sID, long pID, long oID){
// this.gID=gID;
// this.sID=sID;
// this.pID=pID;
// this.oID=oID;
// time=System.nanoTime();
// }
//
// public long getGID(){
// return gID;
// }
//
// public long getSID(){
// return sID;
// }
//
// public long getPID(){
// return pID;
// }
//
// public long getOID(){
// return oID;
// }
//
// public long time(){ return time;};
// }
| import java.util.HashMap;
import org.deri.cqels.data.EnQuad;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.algebra.OpVisitorByType;
import com.hp.hpl.jena.sparql.algebra.op.Op0;
import com.hp.hpl.jena.sparql.algebra.op.Op1;
import com.hp.hpl.jena.sparql.algebra.op.Op2;
import com.hp.hpl.jena.sparql.algebra.op.OpExt;
import com.hp.hpl.jena.sparql.algebra.op.OpFilter;
import com.hp.hpl.jena.sparql.algebra.op.OpLeftJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpN; |
@Override
protected void visit1(Op1 _op) {
_visit(_op.getSubOp(), _op);
}
@Override
protected void visit0(Op0 _op) {
// TODO do nothing?
}
protected void _visit(Op child, Op parent) {
//plan.put(child, context.op2Id(parent));
child.visit(this);
}
@Override
protected void visitFilter(OpFilter of) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
protected void visitLeftJoin(OpLeftJoin op) {
throw new UnsupportedOperationException("Not supported yet.");
}
});
plan.put(op, 0);
System.out.println(" Plan " + plan);
}
| // Path: src/main/java/org/deri/cqels/data/EnQuad.java
// public class EnQuad {
// long gID,sID,pID,oID;
// long time;
// public EnQuad(long gID,long sID, long pID, long oID){
// this.gID=gID;
// this.sID=sID;
// this.pID=pID;
// this.oID=oID;
// time=System.nanoTime();
// }
//
// public long getGID(){
// return gID;
// }
//
// public long getSID(){
// return sID;
// }
//
// public long getPID(){
// return pID;
// }
//
// public long getOID(){
// return oID;
// }
//
// public long time(){ return time;};
// }
// Path: src/main/java/org/deri/cqels/engine/FixedPlanner.java
import java.util.HashMap;
import org.deri.cqels.data.EnQuad;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.algebra.OpVisitorByType;
import com.hp.hpl.jena.sparql.algebra.op.Op0;
import com.hp.hpl.jena.sparql.algebra.op.Op1;
import com.hp.hpl.jena.sparql.algebra.op.Op2;
import com.hp.hpl.jena.sparql.algebra.op.OpExt;
import com.hp.hpl.jena.sparql.algebra.op.OpFilter;
import com.hp.hpl.jena.sparql.algebra.op.OpLeftJoin;
import com.hp.hpl.jena.sparql.algebra.op.OpN;
@Override
protected void visit1(Op1 _op) {
_visit(_op.getSubOp(), _op);
}
@Override
protected void visit0(Op0 _op) {
// TODO do nothing?
}
protected void _visit(Op child, Op parent) {
//plan.put(child, context.op2Id(parent));
child.visit(this);
}
@Override
protected void visitFilter(OpFilter of) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
protected void visitLeftJoin(OpLeftJoin op) {
throw new UnsupportedOperationException("Not supported yet.");
}
});
plan.put(op, 0);
System.out.println(" Plan " + plan);
}
| public HashMap<Op, Integer> getPlan(Op op, EnQuad quad) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/OpRouterBase.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import com.hp.hpl.jena.sparql.algebra.Op; | package org.deri.cqels.engine;
/**
*This class implements the basic behaviors of a router
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter
*/
public abstract class OpRouterBase implements OpRouter {
static int count = 0;
Op op;
/** An execution context that the router is working on */
ExecContext context;
int id;
public OpRouterBase(ExecContext context, Op op) {
this.context = context;
this.op = op;
id = ++count;
//System.out.println("new op "+op);
context.router(id, this);
}
public Op getOp() {
// TODO Auto-generated method stub
return op;
}
public int getId() {
return id;
}
| // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/OpRouterBase.java
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import com.hp.hpl.jena.sparql.algebra.Op;
package org.deri.cqels.engine;
/**
*This class implements the basic behaviors of a router
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter
*/
public abstract class OpRouterBase implements OpRouter {
static int count = 0;
Op op;
/** An execution context that the router is working on */
ExecContext context;
int id;
public OpRouterBase(ExecContext context, Op op) {
this.context = context;
this.op = op;
id = ++count;
//System.out.println("new op "+op);
context.router(id, this);
}
public Op getOp() {
// TODO Auto-generated method stub
return op;
}
public int getId() {
return id;
}
| public void _route( Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/OpRouterBase.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import com.hp.hpl.jena.sparql.algebra.Op; | package org.deri.cqels.engine;
/**
*This class implements the basic behaviors of a router
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter
*/
public abstract class OpRouterBase implements OpRouter {
static int count = 0;
Op op;
/** An execution context that the router is working on */
ExecContext context;
int id;
public OpRouterBase(ExecContext context, Op op) {
this.context = context;
this.op = op;
id = ++count;
//System.out.println("new op "+op);
context.router(id, this);
}
public Op getOp() {
// TODO Auto-generated method stub
return op;
}
public int getId() {
return id;
}
public void _route( Mapping mapping) {
//System.out.println("_route "+mapping);
mapping.from(this);
context.policy().next(this, mapping).route(mapping);
}
public void route(Mapping mapping) {
// do nothing
}
| // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/OpRouterBase.java
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import com.hp.hpl.jena.sparql.algebra.Op;
package org.deri.cqels.engine;
/**
*This class implements the basic behaviors of a router
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter
*/
public abstract class OpRouterBase implements OpRouter {
static int count = 0;
Op op;
/** An execution context that the router is working on */
ExecContext context;
int id;
public OpRouterBase(ExecContext context, Op op) {
this.context = context;
this.op = op;
id = ++count;
//System.out.println("new op "+op);
context.router(id, this);
}
public Op getOp() {
// TODO Auto-generated method stub
return op;
}
public int getId() {
return id;
}
public void _route( Mapping mapping) {
//System.out.println("_route "+mapping);
mapping.from(this);
context.policy().next(this, mapping).route(mapping);
}
public void route(Mapping mapping) {
// do nothing
}
| public MappingIterator searchBuff4Match(Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/ContinuousSelect.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
| import java.util.ArrayList;
import org.deri.cqels.data.Mapping;
import com.hp.hpl.jena.query.Query; | package org.deri.cqels.engine;
/**
* This class acts as a router standing in the root of the tree if the query is
* a select-type
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter
* @see OpRouterBase
*/
public class ContinuousSelect extends OpRouter1 {
private final Query query;
private final ArrayList<ContinuousListener> listeners;
public ContinuousSelect(ExecContext context, Query query,
OpRouter subRouter) {
super(context, subRouter.getOp(), subRouter);
this.query = query;
this.listeners = new ArrayList<ContinuousListener>();
}
@Override | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
// Path: src/main/java/org/deri/cqels/engine/ContinuousSelect.java
import java.util.ArrayList;
import org.deri.cqels.data.Mapping;
import com.hp.hpl.jena.query.Query;
package org.deri.cqels.engine;
/**
* This class acts as a router standing in the root of the tree if the query is
* a select-type
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
* @see OpRouter
* @see OpRouterBase
*/
public class ContinuousSelect extends OpRouter1 {
private final Query query;
private final ArrayList<ContinuousListener> listeners;
public ContinuousSelect(ExecContext context, Query query,
OpRouter subRouter) {
super(context, subRouter.getOp(), subRouter);
this.query = query;
this.listeners = new ArrayList<ContinuousListener>();
}
@Override | public void route(Mapping mapping) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/RangeWindow.java | // Path: src/main/java/org/deri/cqels/lang/cqels/Duration.java
// public class Duration {
// long nanoTime;
// String str;
// public Duration(){
//
// }
//
// public Duration(String str){
// this.str=str;
// nanoTime=parse(str);
// //System.out.println("window time "+nanoTime);
// }
//
// private long parse(String str){
// //System.out.println("window "+str);
// String number="0"; long unit=0;
// int l=str.length()-1;
// if(str.charAt(l)=='s'){
// if(str.charAt(l-1)=='m'){
// number=str.substring(0, l-1);
// unit=(long)1E6;
// }else if(str.charAt(l-1)=='n'){
// number=str.substring(0, l-1);
// unit=1;
// }
// else{
// number=str.substring(0, l);
// unit=(long)1E9;
// }
// }
// else if(str.charAt(l)=='m'){
// number=str.substring(0, l);
// unit=(long)60E9;
// }
// else if(str.charAt(l)=='h'){
// number=str.substring(0, l-1);
// unit=(long)3600E9;
// }
// else if(str.charAt(l)=='d'){
// number=str.substring(0, l-1);
// unit=((long)3600E9)*24;
// }
//
// return Long.parseLong(number)*unit;
// }
// public long inNanosec(){
// return nanoTime;
// }
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/DurationSet.java
// public class DurationSet {
// ArrayList<Duration> durations;
// public DurationSet(){
// durations= new ArrayList<Duration>();
// }
// public void add(Duration duration){
// durations.add(duration);
// }
//
// public long inNanoSec(){
// long nano=0;
// for(Duration duration:durations)
// nano+=duration.inNanosec();
//
// return nano;
//
// }
// }
| import java.util.Timer;
import org.deri.cqels.lang.cqels.Duration;
import org.deri.cqels.lang.cqels.DurationSet;
import com.sleepycat.bind.tuple.LongBinding;
import com.sleepycat.je.Cursor;
import com.sleepycat.je.CursorConfig;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseEntry;
import com.sleepycat.je.LockMode;
import com.sleepycat.je.OperationStatus; | package org.deri.cqels.engine;
/**
* This class implements the time-based window
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public class RangeWindow implements Window {
volatile Database buff;
long w;
long slide;
long wInMili;
long sInMili;
long lastTimestamp = -1;
Timer timer;
long timeout = 3600000;
long start = -1;
public RangeWindow( long w) {
this.w = w;
timer = new Timer();
slide = 0;
}
public RangeWindow(long w, long slide) {
this.w = w;
this.slide = slide;
this.wInMili = (long)(this.w / 1E6);
this.sInMili = (long)(this.slide / 1E6);
timer = new Timer();
}
| // Path: src/main/java/org/deri/cqels/lang/cqels/Duration.java
// public class Duration {
// long nanoTime;
// String str;
// public Duration(){
//
// }
//
// public Duration(String str){
// this.str=str;
// nanoTime=parse(str);
// //System.out.println("window time "+nanoTime);
// }
//
// private long parse(String str){
// //System.out.println("window "+str);
// String number="0"; long unit=0;
// int l=str.length()-1;
// if(str.charAt(l)=='s'){
// if(str.charAt(l-1)=='m'){
// number=str.substring(0, l-1);
// unit=(long)1E6;
// }else if(str.charAt(l-1)=='n'){
// number=str.substring(0, l-1);
// unit=1;
// }
// else{
// number=str.substring(0, l);
// unit=(long)1E9;
// }
// }
// else if(str.charAt(l)=='m'){
// number=str.substring(0, l);
// unit=(long)60E9;
// }
// else if(str.charAt(l)=='h'){
// number=str.substring(0, l-1);
// unit=(long)3600E9;
// }
// else if(str.charAt(l)=='d'){
// number=str.substring(0, l-1);
// unit=((long)3600E9)*24;
// }
//
// return Long.parseLong(number)*unit;
// }
// public long inNanosec(){
// return nanoTime;
// }
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/DurationSet.java
// public class DurationSet {
// ArrayList<Duration> durations;
// public DurationSet(){
// durations= new ArrayList<Duration>();
// }
// public void add(Duration duration){
// durations.add(duration);
// }
//
// public long inNanoSec(){
// long nano=0;
// for(Duration duration:durations)
// nano+=duration.inNanosec();
//
// return nano;
//
// }
// }
// Path: src/main/java/org/deri/cqels/engine/RangeWindow.java
import java.util.Timer;
import org.deri.cqels.lang.cqels.Duration;
import org.deri.cqels.lang.cqels.DurationSet;
import com.sleepycat.bind.tuple.LongBinding;
import com.sleepycat.je.Cursor;
import com.sleepycat.je.CursorConfig;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseEntry;
import com.sleepycat.je.LockMode;
import com.sleepycat.je.OperationStatus;
package org.deri.cqels.engine;
/**
* This class implements the time-based window
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public class RangeWindow implements Window {
volatile Database buff;
long w;
long slide;
long wInMili;
long sInMili;
long lastTimestamp = -1;
Timer timer;
long timeout = 3600000;
long start = -1;
public RangeWindow( long w) {
this.w = w;
timer = new Timer();
slide = 0;
}
public RangeWindow(long w, long slide) {
this.w = w;
this.slide = slide;
this.wInMili = (long)(this.w / 1E6);
this.sInMili = (long)(this.slide / 1E6);
timer = new Timer();
}
| public RangeWindow(DurationSet durations, Duration slideDuration) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/RangeWindow.java | // Path: src/main/java/org/deri/cqels/lang/cqels/Duration.java
// public class Duration {
// long nanoTime;
// String str;
// public Duration(){
//
// }
//
// public Duration(String str){
// this.str=str;
// nanoTime=parse(str);
// //System.out.println("window time "+nanoTime);
// }
//
// private long parse(String str){
// //System.out.println("window "+str);
// String number="0"; long unit=0;
// int l=str.length()-1;
// if(str.charAt(l)=='s'){
// if(str.charAt(l-1)=='m'){
// number=str.substring(0, l-1);
// unit=(long)1E6;
// }else if(str.charAt(l-1)=='n'){
// number=str.substring(0, l-1);
// unit=1;
// }
// else{
// number=str.substring(0, l);
// unit=(long)1E9;
// }
// }
// else if(str.charAt(l)=='m'){
// number=str.substring(0, l);
// unit=(long)60E9;
// }
// else if(str.charAt(l)=='h'){
// number=str.substring(0, l-1);
// unit=(long)3600E9;
// }
// else if(str.charAt(l)=='d'){
// number=str.substring(0, l-1);
// unit=((long)3600E9)*24;
// }
//
// return Long.parseLong(number)*unit;
// }
// public long inNanosec(){
// return nanoTime;
// }
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/DurationSet.java
// public class DurationSet {
// ArrayList<Duration> durations;
// public DurationSet(){
// durations= new ArrayList<Duration>();
// }
// public void add(Duration duration){
// durations.add(duration);
// }
//
// public long inNanoSec(){
// long nano=0;
// for(Duration duration:durations)
// nano+=duration.inNanosec();
//
// return nano;
//
// }
// }
| import java.util.Timer;
import org.deri.cqels.lang.cqels.Duration;
import org.deri.cqels.lang.cqels.DurationSet;
import com.sleepycat.bind.tuple.LongBinding;
import com.sleepycat.je.Cursor;
import com.sleepycat.je.CursorConfig;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseEntry;
import com.sleepycat.je.LockMode;
import com.sleepycat.je.OperationStatus; | package org.deri.cqels.engine;
/**
* This class implements the time-based window
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public class RangeWindow implements Window {
volatile Database buff;
long w;
long slide;
long wInMili;
long sInMili;
long lastTimestamp = -1;
Timer timer;
long timeout = 3600000;
long start = -1;
public RangeWindow( long w) {
this.w = w;
timer = new Timer();
slide = 0;
}
public RangeWindow(long w, long slide) {
this.w = w;
this.slide = slide;
this.wInMili = (long)(this.w / 1E6);
this.sInMili = (long)(this.slide / 1E6);
timer = new Timer();
}
| // Path: src/main/java/org/deri/cqels/lang/cqels/Duration.java
// public class Duration {
// long nanoTime;
// String str;
// public Duration(){
//
// }
//
// public Duration(String str){
// this.str=str;
// nanoTime=parse(str);
// //System.out.println("window time "+nanoTime);
// }
//
// private long parse(String str){
// //System.out.println("window "+str);
// String number="0"; long unit=0;
// int l=str.length()-1;
// if(str.charAt(l)=='s'){
// if(str.charAt(l-1)=='m'){
// number=str.substring(0, l-1);
// unit=(long)1E6;
// }else if(str.charAt(l-1)=='n'){
// number=str.substring(0, l-1);
// unit=1;
// }
// else{
// number=str.substring(0, l);
// unit=(long)1E9;
// }
// }
// else if(str.charAt(l)=='m'){
// number=str.substring(0, l);
// unit=(long)60E9;
// }
// else if(str.charAt(l)=='h'){
// number=str.substring(0, l-1);
// unit=(long)3600E9;
// }
// else if(str.charAt(l)=='d'){
// number=str.substring(0, l-1);
// unit=((long)3600E9)*24;
// }
//
// return Long.parseLong(number)*unit;
// }
// public long inNanosec(){
// return nanoTime;
// }
// }
//
// Path: src/main/java/org/deri/cqels/lang/cqels/DurationSet.java
// public class DurationSet {
// ArrayList<Duration> durations;
// public DurationSet(){
// durations= new ArrayList<Duration>();
// }
// public void add(Duration duration){
// durations.add(duration);
// }
//
// public long inNanoSec(){
// long nano=0;
// for(Duration duration:durations)
// nano+=duration.inNanosec();
//
// return nano;
//
// }
// }
// Path: src/main/java/org/deri/cqels/engine/RangeWindow.java
import java.util.Timer;
import org.deri.cqels.lang.cqels.Duration;
import org.deri.cqels.lang.cqels.DurationSet;
import com.sleepycat.bind.tuple.LongBinding;
import com.sleepycat.je.Cursor;
import com.sleepycat.je.CursorConfig;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseEntry;
import com.sleepycat.je.LockMode;
import com.sleepycat.je.OperationStatus;
package org.deri.cqels.engine;
/**
* This class implements the time-based window
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public class RangeWindow implements Window {
volatile Database buff;
long w;
long slide;
long wInMili;
long sInMili;
long lastTimestamp = -1;
Timer timer;
long timeout = 3600000;
long start = -1;
public RangeWindow( long w) {
this.w = w;
timer = new Timer();
slide = 0;
}
public RangeWindow(long w, long slide) {
this.w = w;
this.slide = slide;
this.wInMili = (long)(this.w / 1E6);
this.sInMili = (long)(this.slide / 1E6);
timer = new Timer();
}
| public RangeWindow(DurationSet durations, Duration slideDuration) { |
KMax/cqels | src/main/java/org/deri/cqels/engine/RoutingRunner.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import com.hp.hpl.jena.sparql.algebra.Op; | package org.deri.cqels.engine;
public class RoutingRunner extends Thread {
ExecContext context; | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/RoutingRunner.java
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import com.hp.hpl.jena.sparql.algebra.Op;
package org.deri.cqels.engine;
public class RoutingRunner extends Thread {
ExecContext context; | MappingIterator itr; |
KMax/cqels | src/main/java/org/deri/cqels/engine/RoutingRunner.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
| import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import com.hp.hpl.jena.sparql.algebra.Op; | package org.deri.cqels.engine;
public class RoutingRunner extends Thread {
ExecContext context;
MappingIterator itr;
OpRouterBase router;
public RoutingRunner (ExecContext context,MappingIterator itr,OpRouterBase router){
this.context=context;
this.itr=itr;
this.router=router;
}
public void run() {
//System.out.println("start send thread "+this.toString());
//System.out.println(mapping.getCtx().plan());
//TODO: get plan via planner
while (itr.hasNext()) {
| // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
//
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIterator.java
// public interface MappingIterator extends Closeable, Iterator<Mapping> {
//
// /**
// * Get next binding
// */
// public Mapping nextMapping();
//
// /**
// * Cancels the query as soon as is possible for the given iterator
// */
// public void cancel();
// }
// Path: src/main/java/org/deri/cqels/engine/RoutingRunner.java
import org.deri.cqels.data.Mapping;
import org.deri.cqels.engine.iterator.MappingIterator;
import com.hp.hpl.jena.sparql.algebra.Op;
package org.deri.cqels.engine;
public class RoutingRunner extends Thread {
ExecContext context;
MappingIterator itr;
OpRouterBase router;
public RoutingRunner (ExecContext context,MappingIterator itr,OpRouterBase router){
this.context=context;
this.itr=itr;
this.router=router;
}
public void run() {
//System.out.println("start send thread "+this.toString());
//System.out.println(mapping.getCtx().plan());
//TODO: get plan via planner
while (itr.hasNext()) {
| Mapping _mapping=itr.next(); |
KMax/cqels | src/main/java/org/deri/cqels/engine/iterator/MappingIteratorBase.java | // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
| import java.util.NoSuchElementException;
import org.deri.cqels.data.Mapping;
import com.hp.hpl.jena.query.QueryCancelledException;
import com.hp.hpl.jena.query.QueryException;
import com.hp.hpl.jena.query.QueryFatalException;
import com.hp.hpl.jena.sparql.util.Utils;
import org.apache.jena.atlas.logging.Log; | package org.deri.cqels.engine.iterator;
public abstract class MappingIteratorBase implements MappingIterator {
private boolean finished = false;
private boolean requestingCancel = false;
private volatile boolean abortIterator = false;
protected abstract void closeIterator();
protected abstract boolean hasNextMapping();
| // Path: src/main/java/org/deri/cqels/data/Mapping.java
// public interface Mapping extends Map<Var, Long>{
//
//
// public long get(Var var);
//
// public void from(OpRouter router);
//
// public OpRouter from();
//
// public ExecContext getCtx();
//
// public Iterator<Var> vars();
//
// public void addParent(Mapping parent);
//
// public boolean hasParent();
//
// public boolean isCompatible(Mapping mapping);
// }
// Path: src/main/java/org/deri/cqels/engine/iterator/MappingIteratorBase.java
import java.util.NoSuchElementException;
import org.deri.cqels.data.Mapping;
import com.hp.hpl.jena.query.QueryCancelledException;
import com.hp.hpl.jena.query.QueryException;
import com.hp.hpl.jena.query.QueryFatalException;
import com.hp.hpl.jena.sparql.util.Utils;
import org.apache.jena.atlas.logging.Log;
package org.deri.cqels.engine.iterator;
public abstract class MappingIteratorBase implements MappingIterator {
private boolean finished = false;
private boolean requestingCancel = false;
private volatile boolean abortIterator = false;
protected abstract void closeIterator();
protected abstract boolean hasNextMapping();
| protected abstract Mapping moveToNextMapping(); |
KMax/cqels | src/main/java/org/deri/cqels/engine/CQELSEngine.java | // Path: src/main/java/org/deri/cqels/data/EnQuad.java
// public class EnQuad {
// long gID,sID,pID,oID;
// long time;
// public EnQuad(long gID,long sID, long pID, long oID){
// this.gID=gID;
// this.sID=sID;
// this.pID=pID;
// this.oID=oID;
// time=System.nanoTime();
// }
//
// public long getGID(){
// return gID;
// }
//
// public long getSID(){
// return sID;
// }
//
// public long getPID(){
// return pID;
// }
//
// public long getOID(){
// return oID;
// }
//
// public long time(){ return time;};
// }
| import org.deri.cqels.data.EnQuad;
import com.espertech.esper.client.EPServiceProvider;
import com.espertech.esper.client.EPServiceProviderManager;
import com.espertech.esper.client.EPStatement;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.sparql.core.Quad;
import com.hp.hpl.jena.tdb.store.NodeId; | package org.deri.cqels.engine;
/**
* This class implements CQELS engine. It has an Esper Service provider and context belonging to
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public class CQELSEngine {
EPServiceProvider provider;
ExecContext context;
/**
* @param context the context this engine belonging to
*/
public CQELSEngine(ExecContext context) {
this.provider = EPServiceProviderManager.getDefaultProvider();
this.context = context;
}
/**
* send a quad to to engine
* @param quad the quad will be sent after encoded
*/
public void send(Quad quad) {
this.provider.getEPRuntime().sendEvent(encode(quad));
}
/**
* send a quad which is represented as a graph node and a triple to engine
* @param graph graph node
* @param triple
*/
public void send(Node graph, Triple triple) {
this.provider.getEPRuntime().sendEvent(encode(graph,triple));
}
/**
* send a quad which is represented as a graph, subject,
* predicate and object node to engine
* @param graph graph node
* @param s subject
* @param p predicate
* @param o object
*/
public void send(Node graph, Node s, Node p, Node o) { | // Path: src/main/java/org/deri/cqels/data/EnQuad.java
// public class EnQuad {
// long gID,sID,pID,oID;
// long time;
// public EnQuad(long gID,long sID, long pID, long oID){
// this.gID=gID;
// this.sID=sID;
// this.pID=pID;
// this.oID=oID;
// time=System.nanoTime();
// }
//
// public long getGID(){
// return gID;
// }
//
// public long getSID(){
// return sID;
// }
//
// public long getPID(){
// return pID;
// }
//
// public long getOID(){
// return oID;
// }
//
// public long time(){ return time;};
// }
// Path: src/main/java/org/deri/cqels/engine/CQELSEngine.java
import org.deri.cqels.data.EnQuad;
import com.espertech.esper.client.EPServiceProvider;
import com.espertech.esper.client.EPServiceProviderManager;
import com.espertech.esper.client.EPStatement;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
import com.hp.hpl.jena.sparql.core.Quad;
import com.hp.hpl.jena.tdb.store.NodeId;
package org.deri.cqels.engine;
/**
* This class implements CQELS engine. It has an Esper Service provider and context belonging to
*
* @author Danh Le Phuoc
* @author Chan Le Van
* @organization DERI Galway, NUIG, Ireland www.deri.ie
* @email danh.lephuoc@deri.org
* @email chan.levan@deri.org
*/
public class CQELSEngine {
EPServiceProvider provider;
ExecContext context;
/**
* @param context the context this engine belonging to
*/
public CQELSEngine(ExecContext context) {
this.provider = EPServiceProviderManager.getDefaultProvider();
this.context = context;
}
/**
* send a quad to to engine
* @param quad the quad will be sent after encoded
*/
public void send(Quad quad) {
this.provider.getEPRuntime().sendEvent(encode(quad));
}
/**
* send a quad which is represented as a graph node and a triple to engine
* @param graph graph node
* @param triple
*/
public void send(Node graph, Triple triple) {
this.provider.getEPRuntime().sendEvent(encode(graph,triple));
}
/**
* send a quad which is represented as a graph, subject,
* predicate and object node to engine
* @param graph graph node
* @param s subject
* @param p predicate
* @param o object
*/
public void send(Node graph, Node s, Node p, Node o) { | this.provider.getEPRuntime().sendEvent(new EnQuad(encode(graph), encode(s), |
bartwell/ultra-debugger | ultradebugger/src/main/java/ru/bartwell/ultradebugger/UltraDebugger.java | // Path: base/src/main/java/ru/bartwell/ultradebugger/base/utils/IpUtils.java
// public class IpUtils {
// private static final String IPV4_BASIC_PATTERN_STRING = "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])";
// private static final Pattern IPV4_PATTERN = Pattern.compile("^" + IPV4_BASIC_PATTERN_STRING + "$");
//
// @Nullable
// public static String getIpV4() {
// return getIpAddress(true);
// }
//
// @Nullable
// public static String getIpV6() {
// return getIpAddress(false);
// }
//
// @Nullable
// private static String getIpAddress(boolean useIPv4) {
// try {
// List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
// for (NetworkInterface networkInterface : interfaces) {
// List<InetAddress> addresses = Collections.list(networkInterface.getInetAddresses());
// for (InetAddress address : addresses) {
// if (!address.isLoopbackAddress()) {
// String resultAddress = address.getHostAddress().toUpperCase();
// boolean isIPv4 = isIPv4Address(resultAddress);
// if (useIPv4) {
// if (isIPv4) {
// return resultAddress;
// }
// } else {
// if (!isIPv4) {
// int delimiter = resultAddress.indexOf('%');
// return delimiter < 0 ? resultAddress : resultAddress.substring(0, delimiter);
// }
// }
// }
// }
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
//
// private static boolean isIPv4Address(@NonNull String input) {
// return IPV4_PATTERN.matcher(input).matches();
// }
// }
| import android.content.Context;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
import ru.bartwell.ultradebugger.base.utils.IpUtils; | package ru.bartwell.ultradebugger;
/**
* Created by BArtWell on 01.01.2017.
*/
public class UltraDebugger {
private static final String TAG = "UltraDebugger";
private static String sIp;
private static int sPort;
public static void start(@NonNull Context context) {
start(context, HttpServer.DEFAULT_PORT);
}
public static void start(@NonNull Context context, int port) { | // Path: base/src/main/java/ru/bartwell/ultradebugger/base/utils/IpUtils.java
// public class IpUtils {
// private static final String IPV4_BASIC_PATTERN_STRING = "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])";
// private static final Pattern IPV4_PATTERN = Pattern.compile("^" + IPV4_BASIC_PATTERN_STRING + "$");
//
// @Nullable
// public static String getIpV4() {
// return getIpAddress(true);
// }
//
// @Nullable
// public static String getIpV6() {
// return getIpAddress(false);
// }
//
// @Nullable
// private static String getIpAddress(boolean useIPv4) {
// try {
// List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
// for (NetworkInterface networkInterface : interfaces) {
// List<InetAddress> addresses = Collections.list(networkInterface.getInetAddresses());
// for (InetAddress address : addresses) {
// if (!address.isLoopbackAddress()) {
// String resultAddress = address.getHostAddress().toUpperCase();
// boolean isIPv4 = isIPv4Address(resultAddress);
// if (useIPv4) {
// if (isIPv4) {
// return resultAddress;
// }
// } else {
// if (!isIPv4) {
// int delimiter = resultAddress.indexOf('%');
// return delimiter < 0 ? resultAddress : resultAddress.substring(0, delimiter);
// }
// }
// }
// }
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
//
// private static boolean isIPv4Address(@NonNull String input) {
// return IPV4_PATTERN.matcher(input).matches();
// }
// }
// Path: ultradebugger/src/main/java/ru/bartwell/ultradebugger/UltraDebugger.java
import android.content.Context;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
import ru.bartwell.ultradebugger.base.utils.IpUtils;
package ru.bartwell.ultradebugger;
/**
* Created by BArtWell on 01.01.2017.
*/
public class UltraDebugger {
private static final String TAG = "UltraDebugger";
private static String sIp;
private static int sPort;
public static void start(@NonNull Context context) {
start(context, HttpServer.DEFAULT_PORT);
}
public static void start(@NonNull Context context, int port) { | sIp = IpUtils.getIpV4(); |
bartwell/ultra-debugger | base/src/main/java/ru/bartwell/ultradebugger/base/BaseModule.java | // Path: base/src/main/java/ru/bartwell/ultradebugger/base/model/HttpRequest.java
// public class HttpRequest {
// private Map<String, List<String>> mParameters;
// private Method mMethod;
// private String mUri;
//
// public HttpRequest(String uri, Method method, Map<String, List<String>> parameters) {
// mUri = uri;
// mMethod = method;
// mParameters = parameters;
// }
//
// public Map<String, List<String>> getParameters() {
// return mParameters;
// }
//
// public Method getMethod() {
// return mMethod;
// }
//
// public String getUri() {
// return mUri;
// }
//
// public enum Method {
// GET,
// POST
// }
// }
//
// Path: base/src/main/java/ru/bartwell/ultradebugger/base/model/HttpResponse.java
// public class HttpResponse {
//
// private static final String CONTENT_TYPE_TEXT_HTML = "text/html";
//
// @NonNull
// private Status mStatus;
// @NonNull
// private String mContentType;
// @Nullable
// private String mContent;
// @Nullable
// private InputStream mStream;
// private long mContentLength;
// @NonNull
// Map<String, String> mHeaders = new HashMap<>();
//
// public HttpResponse(@NonNull String content) {
// mStatus = Status.OK;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// mContent = content;
// }
//
// @SuppressWarnings("WeakerAccess")
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream, long contentLength) {
// mStatus = Status.OK;
// mContentType = contentType;
// mStream = stream;
// mContentLength = contentLength;
// }
//
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream) {
// this(contentType, stream, -1);
// }
//
// public HttpResponse(@NonNull Status status) {
// mStatus = status;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// }
//
// @Nullable
// public String getContent() {
// return mContent;
// }
//
// @NonNull
// public String getContentType() {
// return mContentType;
// }
//
// @NonNull
// public Status getStatus() {
// return mStatus;
// }
//
// @Nullable
// public InputStream getStream() {
// return mStream;
// }
//
// public long getContentLength() {
// return mContentLength;
// }
//
// public void addHeader(@NonNull String name, @NonNull String value) {
// mHeaders.put(name, value);
// }
//
// @NonNull
// public Map<String, String> getHeaders() {
// return mHeaders;
// }
//
// public enum Status {
// OK(200, "OK"),
// BAD_REQUEST(400, "Bad request"),
// NOT_FOUND(404, "Not found"),
// INTERNAL_SERVER_ERROR(500, "Internal server error");
//
// private int mCode;
// private String mDescription;
//
// Status(int code, String description) {
// mCode = code;
// mDescription = description;
// }
//
// public int getCode() {
// return mCode;
// }
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
| import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import ru.bartwell.ultradebugger.base.model.HttpRequest;
import ru.bartwell.ultradebugger.base.model.HttpResponse; | package ru.bartwell.ultradebugger.base;
/**
* Created by BArtWell on 04.01.2017.
*/
public abstract class BaseModule {
@NonNull
private Context mContext;
private String mModuleId;
public BaseModule(@NonNull Context context, @NonNull String moduleId) {
mContext = context;
mModuleId = moduleId;
}
@NonNull
public Context getContext() {
return mContext;
}
@NonNull
protected String getModuleId() {
return mModuleId;
}
@NonNull
protected String getString(@StringRes int stringResId) {
return mContext.getString(stringResId);
}
@NonNull
public abstract String getName();
@NonNull
public abstract String getDescription();
@NonNull | // Path: base/src/main/java/ru/bartwell/ultradebugger/base/model/HttpRequest.java
// public class HttpRequest {
// private Map<String, List<String>> mParameters;
// private Method mMethod;
// private String mUri;
//
// public HttpRequest(String uri, Method method, Map<String, List<String>> parameters) {
// mUri = uri;
// mMethod = method;
// mParameters = parameters;
// }
//
// public Map<String, List<String>> getParameters() {
// return mParameters;
// }
//
// public Method getMethod() {
// return mMethod;
// }
//
// public String getUri() {
// return mUri;
// }
//
// public enum Method {
// GET,
// POST
// }
// }
//
// Path: base/src/main/java/ru/bartwell/ultradebugger/base/model/HttpResponse.java
// public class HttpResponse {
//
// private static final String CONTENT_TYPE_TEXT_HTML = "text/html";
//
// @NonNull
// private Status mStatus;
// @NonNull
// private String mContentType;
// @Nullable
// private String mContent;
// @Nullable
// private InputStream mStream;
// private long mContentLength;
// @NonNull
// Map<String, String> mHeaders = new HashMap<>();
//
// public HttpResponse(@NonNull String content) {
// mStatus = Status.OK;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// mContent = content;
// }
//
// @SuppressWarnings("WeakerAccess")
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream, long contentLength) {
// mStatus = Status.OK;
// mContentType = contentType;
// mStream = stream;
// mContentLength = contentLength;
// }
//
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream) {
// this(contentType, stream, -1);
// }
//
// public HttpResponse(@NonNull Status status) {
// mStatus = status;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// }
//
// @Nullable
// public String getContent() {
// return mContent;
// }
//
// @NonNull
// public String getContentType() {
// return mContentType;
// }
//
// @NonNull
// public Status getStatus() {
// return mStatus;
// }
//
// @Nullable
// public InputStream getStream() {
// return mStream;
// }
//
// public long getContentLength() {
// return mContentLength;
// }
//
// public void addHeader(@NonNull String name, @NonNull String value) {
// mHeaders.put(name, value);
// }
//
// @NonNull
// public Map<String, String> getHeaders() {
// return mHeaders;
// }
//
// public enum Status {
// OK(200, "OK"),
// BAD_REQUEST(400, "Bad request"),
// NOT_FOUND(404, "Not found"),
// INTERNAL_SERVER_ERROR(500, "Internal server error");
//
// private int mCode;
// private String mDescription;
//
// Status(int code, String description) {
// mCode = code;
// mDescription = description;
// }
//
// public int getCode() {
// return mCode;
// }
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
// Path: base/src/main/java/ru/bartwell/ultradebugger/base/BaseModule.java
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import ru.bartwell.ultradebugger.base.model.HttpRequest;
import ru.bartwell.ultradebugger.base.model.HttpResponse;
package ru.bartwell.ultradebugger.base;
/**
* Created by BArtWell on 04.01.2017.
*/
public abstract class BaseModule {
@NonNull
private Context mContext;
private String mModuleId;
public BaseModule(@NonNull Context context, @NonNull String moduleId) {
mContext = context;
mModuleId = moduleId;
}
@NonNull
public Context getContext() {
return mContext;
}
@NonNull
protected String getModuleId() {
return mModuleId;
}
@NonNull
protected String getString(@StringRes int stringResId) {
return mContext.getString(stringResId);
}
@NonNull
public abstract String getName();
@NonNull
public abstract String getDescription();
@NonNull | public abstract HttpResponse handle(@NonNull HttpRequest request); |
bartwell/ultra-debugger | base/src/main/java/ru/bartwell/ultradebugger/base/BaseModule.java | // Path: base/src/main/java/ru/bartwell/ultradebugger/base/model/HttpRequest.java
// public class HttpRequest {
// private Map<String, List<String>> mParameters;
// private Method mMethod;
// private String mUri;
//
// public HttpRequest(String uri, Method method, Map<String, List<String>> parameters) {
// mUri = uri;
// mMethod = method;
// mParameters = parameters;
// }
//
// public Map<String, List<String>> getParameters() {
// return mParameters;
// }
//
// public Method getMethod() {
// return mMethod;
// }
//
// public String getUri() {
// return mUri;
// }
//
// public enum Method {
// GET,
// POST
// }
// }
//
// Path: base/src/main/java/ru/bartwell/ultradebugger/base/model/HttpResponse.java
// public class HttpResponse {
//
// private static final String CONTENT_TYPE_TEXT_HTML = "text/html";
//
// @NonNull
// private Status mStatus;
// @NonNull
// private String mContentType;
// @Nullable
// private String mContent;
// @Nullable
// private InputStream mStream;
// private long mContentLength;
// @NonNull
// Map<String, String> mHeaders = new HashMap<>();
//
// public HttpResponse(@NonNull String content) {
// mStatus = Status.OK;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// mContent = content;
// }
//
// @SuppressWarnings("WeakerAccess")
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream, long contentLength) {
// mStatus = Status.OK;
// mContentType = contentType;
// mStream = stream;
// mContentLength = contentLength;
// }
//
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream) {
// this(contentType, stream, -1);
// }
//
// public HttpResponse(@NonNull Status status) {
// mStatus = status;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// }
//
// @Nullable
// public String getContent() {
// return mContent;
// }
//
// @NonNull
// public String getContentType() {
// return mContentType;
// }
//
// @NonNull
// public Status getStatus() {
// return mStatus;
// }
//
// @Nullable
// public InputStream getStream() {
// return mStream;
// }
//
// public long getContentLength() {
// return mContentLength;
// }
//
// public void addHeader(@NonNull String name, @NonNull String value) {
// mHeaders.put(name, value);
// }
//
// @NonNull
// public Map<String, String> getHeaders() {
// return mHeaders;
// }
//
// public enum Status {
// OK(200, "OK"),
// BAD_REQUEST(400, "Bad request"),
// NOT_FOUND(404, "Not found"),
// INTERNAL_SERVER_ERROR(500, "Internal server error");
//
// private int mCode;
// private String mDescription;
//
// Status(int code, String description) {
// mCode = code;
// mDescription = description;
// }
//
// public int getCode() {
// return mCode;
// }
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
| import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import ru.bartwell.ultradebugger.base.model.HttpRequest;
import ru.bartwell.ultradebugger.base.model.HttpResponse; | package ru.bartwell.ultradebugger.base;
/**
* Created by BArtWell on 04.01.2017.
*/
public abstract class BaseModule {
@NonNull
private Context mContext;
private String mModuleId;
public BaseModule(@NonNull Context context, @NonNull String moduleId) {
mContext = context;
mModuleId = moduleId;
}
@NonNull
public Context getContext() {
return mContext;
}
@NonNull
protected String getModuleId() {
return mModuleId;
}
@NonNull
protected String getString(@StringRes int stringResId) {
return mContext.getString(stringResId);
}
@NonNull
public abstract String getName();
@NonNull
public abstract String getDescription();
@NonNull | // Path: base/src/main/java/ru/bartwell/ultradebugger/base/model/HttpRequest.java
// public class HttpRequest {
// private Map<String, List<String>> mParameters;
// private Method mMethod;
// private String mUri;
//
// public HttpRequest(String uri, Method method, Map<String, List<String>> parameters) {
// mUri = uri;
// mMethod = method;
// mParameters = parameters;
// }
//
// public Map<String, List<String>> getParameters() {
// return mParameters;
// }
//
// public Method getMethod() {
// return mMethod;
// }
//
// public String getUri() {
// return mUri;
// }
//
// public enum Method {
// GET,
// POST
// }
// }
//
// Path: base/src/main/java/ru/bartwell/ultradebugger/base/model/HttpResponse.java
// public class HttpResponse {
//
// private static final String CONTENT_TYPE_TEXT_HTML = "text/html";
//
// @NonNull
// private Status mStatus;
// @NonNull
// private String mContentType;
// @Nullable
// private String mContent;
// @Nullable
// private InputStream mStream;
// private long mContentLength;
// @NonNull
// Map<String, String> mHeaders = new HashMap<>();
//
// public HttpResponse(@NonNull String content) {
// mStatus = Status.OK;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// mContent = content;
// }
//
// @SuppressWarnings("WeakerAccess")
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream, long contentLength) {
// mStatus = Status.OK;
// mContentType = contentType;
// mStream = stream;
// mContentLength = contentLength;
// }
//
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream) {
// this(contentType, stream, -1);
// }
//
// public HttpResponse(@NonNull Status status) {
// mStatus = status;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// }
//
// @Nullable
// public String getContent() {
// return mContent;
// }
//
// @NonNull
// public String getContentType() {
// return mContentType;
// }
//
// @NonNull
// public Status getStatus() {
// return mStatus;
// }
//
// @Nullable
// public InputStream getStream() {
// return mStream;
// }
//
// public long getContentLength() {
// return mContentLength;
// }
//
// public void addHeader(@NonNull String name, @NonNull String value) {
// mHeaders.put(name, value);
// }
//
// @NonNull
// public Map<String, String> getHeaders() {
// return mHeaders;
// }
//
// public enum Status {
// OK(200, "OK"),
// BAD_REQUEST(400, "Bad request"),
// NOT_FOUND(404, "Not found"),
// INTERNAL_SERVER_ERROR(500, "Internal server error");
//
// private int mCode;
// private String mDescription;
//
// Status(int code, String description) {
// mCode = code;
// mDescription = description;
// }
//
// public int getCode() {
// return mCode;
// }
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
// Path: base/src/main/java/ru/bartwell/ultradebugger/base/BaseModule.java
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import ru.bartwell.ultradebugger.base.model.HttpRequest;
import ru.bartwell.ultradebugger.base.model.HttpResponse;
package ru.bartwell.ultradebugger.base;
/**
* Created by BArtWell on 04.01.2017.
*/
public abstract class BaseModule {
@NonNull
private Context mContext;
private String mModuleId;
public BaseModule(@NonNull Context context, @NonNull String moduleId) {
mContext = context;
mModuleId = moduleId;
}
@NonNull
public Context getContext() {
return mContext;
}
@NonNull
protected String getModuleId() {
return mModuleId;
}
@NonNull
protected String getString(@StringRes int stringResId) {
return mContext.getString(stringResId);
}
@NonNull
public abstract String getName();
@NonNull
public abstract String getDescription();
@NonNull | public abstract HttpResponse handle(@NonNull HttpRequest request); |
bartwell/ultra-debugger | base/src/main/java/ru/bartwell/ultradebugger/base/utils/CommonUtils.java | // Path: base/src/main/java/ru/bartwell/ultradebugger/base/html/ErrorPage.java
// public class ErrorPage extends Page {
//
// public ErrorPage(String errorText) {
// this(errorText, true);
// }
//
// public ErrorPage(String errorText, boolean showHomeButton) {
// Content content = new Content();
// content.add(new RawContentPart("<p align=\"center\">" + errorText + "</p>"));
// setContent(content);
// setTitle("Error");
// showHomeButton(showHomeButton);
// }
// }
//
// Path: base/src/main/java/ru/bartwell/ultradebugger/base/model/HttpResponse.java
// public class HttpResponse {
//
// private static final String CONTENT_TYPE_TEXT_HTML = "text/html";
//
// @NonNull
// private Status mStatus;
// @NonNull
// private String mContentType;
// @Nullable
// private String mContent;
// @Nullable
// private InputStream mStream;
// private long mContentLength;
// @NonNull
// Map<String, String> mHeaders = new HashMap<>();
//
// public HttpResponse(@NonNull String content) {
// mStatus = Status.OK;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// mContent = content;
// }
//
// @SuppressWarnings("WeakerAccess")
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream, long contentLength) {
// mStatus = Status.OK;
// mContentType = contentType;
// mStream = stream;
// mContentLength = contentLength;
// }
//
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream) {
// this(contentType, stream, -1);
// }
//
// public HttpResponse(@NonNull Status status) {
// mStatus = status;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// }
//
// @Nullable
// public String getContent() {
// return mContent;
// }
//
// @NonNull
// public String getContentType() {
// return mContentType;
// }
//
// @NonNull
// public Status getStatus() {
// return mStatus;
// }
//
// @Nullable
// public InputStream getStream() {
// return mStream;
// }
//
// public long getContentLength() {
// return mContentLength;
// }
//
// public void addHeader(@NonNull String name, @NonNull String value) {
// mHeaders.put(name, value);
// }
//
// @NonNull
// public Map<String, String> getHeaders() {
// return mHeaders;
// }
//
// public enum Status {
// OK(200, "OK"),
// BAD_REQUEST(400, "Bad request"),
// NOT_FOUND(404, "Not found"),
// INTERNAL_SERVER_ERROR(500, "Internal server error");
//
// private int mCode;
// private String mDescription;
//
// Status(int code, String description) {
// mCode = code;
// mDescription = description;
// }
//
// public int getCode() {
// return mCode;
// }
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
| import android.annotation.TargetApi;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.Map;
import ru.bartwell.ultradebugger.base.html.ErrorPage;
import ru.bartwell.ultradebugger.base.model.HttpResponse; | @Nullable
public static Activity getCurrentActivity() {
try {
Class activityThreadClass = Class.forName("android.app.ActivityThread");
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
activitiesField.setAccessible(true);
Map<Object, Object> activities = (Map<Object, Object>) activitiesField.get(activityThread);
if (activities == null)
return null;
for (Object activityRecord : activities.values()) {
Class activityRecordClass = activityRecord.getClass();
Field pausedField = activityRecordClass.getDeclaredField("paused");
pausedField.setAccessible(true);
if (!pausedField.getBoolean(activityRecord)) {
Field activityField = activityRecordClass.getDeclaredField("activity");
activityField.setAccessible(true);
Activity activity = (Activity) activityField.get(activityRecord);
return activity;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Nullable | // Path: base/src/main/java/ru/bartwell/ultradebugger/base/html/ErrorPage.java
// public class ErrorPage extends Page {
//
// public ErrorPage(String errorText) {
// this(errorText, true);
// }
//
// public ErrorPage(String errorText, boolean showHomeButton) {
// Content content = new Content();
// content.add(new RawContentPart("<p align=\"center\">" + errorText + "</p>"));
// setContent(content);
// setTitle("Error");
// showHomeButton(showHomeButton);
// }
// }
//
// Path: base/src/main/java/ru/bartwell/ultradebugger/base/model/HttpResponse.java
// public class HttpResponse {
//
// private static final String CONTENT_TYPE_TEXT_HTML = "text/html";
//
// @NonNull
// private Status mStatus;
// @NonNull
// private String mContentType;
// @Nullable
// private String mContent;
// @Nullable
// private InputStream mStream;
// private long mContentLength;
// @NonNull
// Map<String, String> mHeaders = new HashMap<>();
//
// public HttpResponse(@NonNull String content) {
// mStatus = Status.OK;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// mContent = content;
// }
//
// @SuppressWarnings("WeakerAccess")
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream, long contentLength) {
// mStatus = Status.OK;
// mContentType = contentType;
// mStream = stream;
// mContentLength = contentLength;
// }
//
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream) {
// this(contentType, stream, -1);
// }
//
// public HttpResponse(@NonNull Status status) {
// mStatus = status;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// }
//
// @Nullable
// public String getContent() {
// return mContent;
// }
//
// @NonNull
// public String getContentType() {
// return mContentType;
// }
//
// @NonNull
// public Status getStatus() {
// return mStatus;
// }
//
// @Nullable
// public InputStream getStream() {
// return mStream;
// }
//
// public long getContentLength() {
// return mContentLength;
// }
//
// public void addHeader(@NonNull String name, @NonNull String value) {
// mHeaders.put(name, value);
// }
//
// @NonNull
// public Map<String, String> getHeaders() {
// return mHeaders;
// }
//
// public enum Status {
// OK(200, "OK"),
// BAD_REQUEST(400, "Bad request"),
// NOT_FOUND(404, "Not found"),
// INTERNAL_SERVER_ERROR(500, "Internal server error");
//
// private int mCode;
// private String mDescription;
//
// Status(int code, String description) {
// mCode = code;
// mDescription = description;
// }
//
// public int getCode() {
// return mCode;
// }
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
// Path: base/src/main/java/ru/bartwell/ultradebugger/base/utils/CommonUtils.java
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.Map;
import ru.bartwell.ultradebugger.base.html.ErrorPage;
import ru.bartwell.ultradebugger.base.model.HttpResponse;
@Nullable
public static Activity getCurrentActivity() {
try {
Class activityThreadClass = Class.forName("android.app.ActivityThread");
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
activitiesField.setAccessible(true);
Map<Object, Object> activities = (Map<Object, Object>) activitiesField.get(activityThread);
if (activities == null)
return null;
for (Object activityRecord : activities.values()) {
Class activityRecordClass = activityRecord.getClass();
Field pausedField = activityRecordClass.getDeclaredField("paused");
pausedField.setAccessible(true);
if (!pausedField.getBoolean(activityRecord)) {
Field activityField = activityRecordClass.getDeclaredField("activity");
activityField.setAccessible(true);
Activity activity = (Activity) activityField.get(activityRecord);
return activity;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Nullable | public static HttpResponse requestPermissions(@NonNull String ... permissions) { |
bartwell/ultra-debugger | base/src/main/java/ru/bartwell/ultradebugger/base/utils/CommonUtils.java | // Path: base/src/main/java/ru/bartwell/ultradebugger/base/html/ErrorPage.java
// public class ErrorPage extends Page {
//
// public ErrorPage(String errorText) {
// this(errorText, true);
// }
//
// public ErrorPage(String errorText, boolean showHomeButton) {
// Content content = new Content();
// content.add(new RawContentPart("<p align=\"center\">" + errorText + "</p>"));
// setContent(content);
// setTitle("Error");
// showHomeButton(showHomeButton);
// }
// }
//
// Path: base/src/main/java/ru/bartwell/ultradebugger/base/model/HttpResponse.java
// public class HttpResponse {
//
// private static final String CONTENT_TYPE_TEXT_HTML = "text/html";
//
// @NonNull
// private Status mStatus;
// @NonNull
// private String mContentType;
// @Nullable
// private String mContent;
// @Nullable
// private InputStream mStream;
// private long mContentLength;
// @NonNull
// Map<String, String> mHeaders = new HashMap<>();
//
// public HttpResponse(@NonNull String content) {
// mStatus = Status.OK;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// mContent = content;
// }
//
// @SuppressWarnings("WeakerAccess")
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream, long contentLength) {
// mStatus = Status.OK;
// mContentType = contentType;
// mStream = stream;
// mContentLength = contentLength;
// }
//
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream) {
// this(contentType, stream, -1);
// }
//
// public HttpResponse(@NonNull Status status) {
// mStatus = status;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// }
//
// @Nullable
// public String getContent() {
// return mContent;
// }
//
// @NonNull
// public String getContentType() {
// return mContentType;
// }
//
// @NonNull
// public Status getStatus() {
// return mStatus;
// }
//
// @Nullable
// public InputStream getStream() {
// return mStream;
// }
//
// public long getContentLength() {
// return mContentLength;
// }
//
// public void addHeader(@NonNull String name, @NonNull String value) {
// mHeaders.put(name, value);
// }
//
// @NonNull
// public Map<String, String> getHeaders() {
// return mHeaders;
// }
//
// public enum Status {
// OK(200, "OK"),
// BAD_REQUEST(400, "Bad request"),
// NOT_FOUND(404, "Not found"),
// INTERNAL_SERVER_ERROR(500, "Internal server error");
//
// private int mCode;
// private String mDescription;
//
// Status(int code, String description) {
// mCode = code;
// mDescription = description;
// }
//
// public int getCode() {
// return mCode;
// }
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
| import android.annotation.TargetApi;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.Map;
import ru.bartwell.ultradebugger.base.html.ErrorPage;
import ru.bartwell.ultradebugger.base.model.HttpResponse; | Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
activitiesField.setAccessible(true);
Map<Object, Object> activities = (Map<Object, Object>) activitiesField.get(activityThread);
if (activities == null)
return null;
for (Object activityRecord : activities.values()) {
Class activityRecordClass = activityRecord.getClass();
Field pausedField = activityRecordClass.getDeclaredField("paused");
pausedField.setAccessible(true);
if (!pausedField.getBoolean(activityRecord)) {
Field activityField = activityRecordClass.getDeclaredField("activity");
activityField.setAccessible(true);
Activity activity = (Activity) activityField.get(activityRecord);
return activity;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Nullable
public static HttpResponse requestPermissions(@NonNull String ... permissions) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Activity activity = getCurrentActivity();
if (activity != null && !checkSelfPermissions(activity, permissions)) {
activity.requestPermissions(permissions, 0); | // Path: base/src/main/java/ru/bartwell/ultradebugger/base/html/ErrorPage.java
// public class ErrorPage extends Page {
//
// public ErrorPage(String errorText) {
// this(errorText, true);
// }
//
// public ErrorPage(String errorText, boolean showHomeButton) {
// Content content = new Content();
// content.add(new RawContentPart("<p align=\"center\">" + errorText + "</p>"));
// setContent(content);
// setTitle("Error");
// showHomeButton(showHomeButton);
// }
// }
//
// Path: base/src/main/java/ru/bartwell/ultradebugger/base/model/HttpResponse.java
// public class HttpResponse {
//
// private static final String CONTENT_TYPE_TEXT_HTML = "text/html";
//
// @NonNull
// private Status mStatus;
// @NonNull
// private String mContentType;
// @Nullable
// private String mContent;
// @Nullable
// private InputStream mStream;
// private long mContentLength;
// @NonNull
// Map<String, String> mHeaders = new HashMap<>();
//
// public HttpResponse(@NonNull String content) {
// mStatus = Status.OK;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// mContent = content;
// }
//
// @SuppressWarnings("WeakerAccess")
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream, long contentLength) {
// mStatus = Status.OK;
// mContentType = contentType;
// mStream = stream;
// mContentLength = contentLength;
// }
//
// public HttpResponse(@NonNull String contentType, @NonNull InputStream stream) {
// this(contentType, stream, -1);
// }
//
// public HttpResponse(@NonNull Status status) {
// mStatus = status;
// mContentType = CONTENT_TYPE_TEXT_HTML;
// }
//
// @Nullable
// public String getContent() {
// return mContent;
// }
//
// @NonNull
// public String getContentType() {
// return mContentType;
// }
//
// @NonNull
// public Status getStatus() {
// return mStatus;
// }
//
// @Nullable
// public InputStream getStream() {
// return mStream;
// }
//
// public long getContentLength() {
// return mContentLength;
// }
//
// public void addHeader(@NonNull String name, @NonNull String value) {
// mHeaders.put(name, value);
// }
//
// @NonNull
// public Map<String, String> getHeaders() {
// return mHeaders;
// }
//
// public enum Status {
// OK(200, "OK"),
// BAD_REQUEST(400, "Bad request"),
// NOT_FOUND(404, "Not found"),
// INTERNAL_SERVER_ERROR(500, "Internal server error");
//
// private int mCode;
// private String mDescription;
//
// Status(int code, String description) {
// mCode = code;
// mDescription = description;
// }
//
// public int getCode() {
// return mCode;
// }
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
// Path: base/src/main/java/ru/bartwell/ultradebugger/base/utils/CommonUtils.java
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.Map;
import ru.bartwell.ultradebugger.base.html.ErrorPage;
import ru.bartwell.ultradebugger.base.model.HttpResponse;
Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
activitiesField.setAccessible(true);
Map<Object, Object> activities = (Map<Object, Object>) activitiesField.get(activityThread);
if (activities == null)
return null;
for (Object activityRecord : activities.values()) {
Class activityRecordClass = activityRecord.getClass();
Field pausedField = activityRecordClass.getDeclaredField("paused");
pausedField.setAccessible(true);
if (!pausedField.getBoolean(activityRecord)) {
Field activityField = activityRecordClass.getDeclaredField("activity");
activityField.setAccessible(true);
Activity activity = (Activity) activityField.get(activityRecord);
return activity;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Nullable
public static HttpResponse requestPermissions(@NonNull String ... permissions) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Activity activity = getCurrentActivity();
if (activity != null && !checkSelfPermissions(activity, permissions)) {
activity.requestPermissions(permissions, 0); | return new HttpResponse(new ErrorPage("This module require additional permissions. Please allow it on your smartphone and reload this page.").toHtml()); |
bartwell/ultra-debugger | app/src/main/java/ru/bartwell/ultradebugger/sampleapp/DebuggerApplication.java | // Path: wrapper/src/main/java/ru/bartwell/ultradebugger/wrapper/UltraDebuggerWrapper.java
// public class UltraDebuggerWrapper {
//
// private static boolean sIsEnabled = true;
//
// private UltraDebuggerWrapper() {
// }
//
// public static void setEnabled(boolean isEnabled) {
// sIsEnabled = isEnabled;
// }
//
// public static void start(@NonNull Context context) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("start", Context.class);
// method.invoke(null, context);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static void start(@NonNull Context context, int port) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("start", Context.class, int.class);
// method.invoke(null, context, port);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static void stop(@NonNull Context context) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("stop", Context.class);
// method.invoke(null, context);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static int getPort() {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("getPort");
// return (int) method.invoke(null);
// } catch (Exception ignored) {
// }
// }
// return -1;
// }
//
// @Nullable
// public static String getIp() {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("getIp");
// return (String) method.invoke(null);
// } catch (Exception ignored) {
// }
// }
// return null;
// }
//
// public static void addLog(@NonNull Context context, @NonNull String text) {
// addLog(context, text, null);
// }
//
// public static void addLog(@NonNull Context context, @NonNull String text, @Nullable Throwable throwable) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("addLog", Context.class, String.class, Throwable.class);
// method.invoke(null, context, text, throwable);
// } catch (Exception ignored) {
// }
// }
// }
//
// @NonNull
// public static String getLogDownloadPath() {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("getLogDownloadPath");
// return (String) method.invoke(null);
// } catch (Exception ignored) {
// }
// }
// return "";
// }
//
// public static void clearLogs(@NonNull Context context) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("clearLogs", Context.class);
// method.invoke(null, context);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static void saveValue(@NonNull Context context, @NonNull String key, @Nullable Object value) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("saveValue", Context.class, String.class, Object.class);
// method.invoke(null, context, key, value);
// } catch (Exception ignored) {
// }
// }
// }
// }
| import android.app.Application;
import ru.bartwell.ultradebugger.wrapper.UltraDebuggerWrapper; | package ru.bartwell.ultradebugger.sampleapp;
/**
* Created by BArtWell on 01.01.2017.
*/
public class DebuggerApplication extends Application {
@Override
public void onCreate() {
super.onCreate(); | // Path: wrapper/src/main/java/ru/bartwell/ultradebugger/wrapper/UltraDebuggerWrapper.java
// public class UltraDebuggerWrapper {
//
// private static boolean sIsEnabled = true;
//
// private UltraDebuggerWrapper() {
// }
//
// public static void setEnabled(boolean isEnabled) {
// sIsEnabled = isEnabled;
// }
//
// public static void start(@NonNull Context context) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("start", Context.class);
// method.invoke(null, context);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static void start(@NonNull Context context, int port) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("start", Context.class, int.class);
// method.invoke(null, context, port);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static void stop(@NonNull Context context) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("stop", Context.class);
// method.invoke(null, context);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static int getPort() {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("getPort");
// return (int) method.invoke(null);
// } catch (Exception ignored) {
// }
// }
// return -1;
// }
//
// @Nullable
// public static String getIp() {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("getIp");
// return (String) method.invoke(null);
// } catch (Exception ignored) {
// }
// }
// return null;
// }
//
// public static void addLog(@NonNull Context context, @NonNull String text) {
// addLog(context, text, null);
// }
//
// public static void addLog(@NonNull Context context, @NonNull String text, @Nullable Throwable throwable) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("addLog", Context.class, String.class, Throwable.class);
// method.invoke(null, context, text, throwable);
// } catch (Exception ignored) {
// }
// }
// }
//
// @NonNull
// public static String getLogDownloadPath() {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("getLogDownloadPath");
// return (String) method.invoke(null);
// } catch (Exception ignored) {
// }
// }
// return "";
// }
//
// public static void clearLogs(@NonNull Context context) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("clearLogs", Context.class);
// method.invoke(null, context);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static void saveValue(@NonNull Context context, @NonNull String key, @Nullable Object value) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("saveValue", Context.class, String.class, Object.class);
// method.invoke(null, context, key, value);
// } catch (Exception ignored) {
// }
// }
// }
// }
// Path: app/src/main/java/ru/bartwell/ultradebugger/sampleapp/DebuggerApplication.java
import android.app.Application;
import ru.bartwell.ultradebugger.wrapper.UltraDebuggerWrapper;
package ru.bartwell.ultradebugger.sampleapp;
/**
* Created by BArtWell on 01.01.2017.
*/
public class DebuggerApplication extends Application {
@Override
public void onCreate() {
super.onCreate(); | UltraDebuggerWrapper.setEnabled(BuildConfig.FLAVOR.equals("dev")); |
bartwell/ultra-debugger | ultradebugger/src/main/java/ru/bartwell/ultradebugger/ModulesManager.java | // Path: base/src/main/java/ru/bartwell/ultradebugger/base/BaseModule.java
// public abstract class BaseModule {
// @NonNull
// private Context mContext;
// private String mModuleId;
//
// public BaseModule(@NonNull Context context, @NonNull String moduleId) {
// mContext = context;
// mModuleId = moduleId;
// }
//
// @NonNull
// public Context getContext() {
// return mContext;
// }
//
// @NonNull
// protected String getModuleId() {
// return mModuleId;
// }
//
// @NonNull
// protected String getString(@StringRes int stringResId) {
// return mContext.getString(stringResId);
// }
//
// @NonNull
// public abstract String getName();
//
// @NonNull
// public abstract String getDescription();
//
// @NonNull
// public abstract HttpResponse handle(@NonNull HttpRequest request);
// }
| import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import ru.bartwell.ultradebugger.base.BaseModule; | package ru.bartwell.ultradebugger;
/**
* Created by BArtWell on 04.01.2017.
*/
class ModulesManager {
private static final String MODULE_CLASS_NAME_FORMAT = "%1$s.module.%2$s.Module";
@Nullable
private static ModulesManager sInstance;
@NonNull | // Path: base/src/main/java/ru/bartwell/ultradebugger/base/BaseModule.java
// public abstract class BaseModule {
// @NonNull
// private Context mContext;
// private String mModuleId;
//
// public BaseModule(@NonNull Context context, @NonNull String moduleId) {
// mContext = context;
// mModuleId = moduleId;
// }
//
// @NonNull
// public Context getContext() {
// return mContext;
// }
//
// @NonNull
// protected String getModuleId() {
// return mModuleId;
// }
//
// @NonNull
// protected String getString(@StringRes int stringResId) {
// return mContext.getString(stringResId);
// }
//
// @NonNull
// public abstract String getName();
//
// @NonNull
// public abstract String getDescription();
//
// @NonNull
// public abstract HttpResponse handle(@NonNull HttpRequest request);
// }
// Path: ultradebugger/src/main/java/ru/bartwell/ultradebugger/ModulesManager.java
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import ru.bartwell.ultradebugger.base.BaseModule;
package ru.bartwell.ultradebugger;
/**
* Created by BArtWell on 04.01.2017.
*/
class ModulesManager {
private static final String MODULE_CLASS_NAME_FORMAT = "%1$s.module.%2$s.Module";
@Nullable
private static ModulesManager sInstance;
@NonNull | private Map<String, BaseModule> mModules = new HashMap<>(); |
bartwell/ultra-debugger | app/src/main/java/ru/bartwell/ultradebugger/sampleapp/MainActivity.java | // Path: wrapper/src/main/java/ru/bartwell/ultradebugger/wrapper/UltraDebuggerWrapper.java
// public class UltraDebuggerWrapper {
//
// private static boolean sIsEnabled = true;
//
// private UltraDebuggerWrapper() {
// }
//
// public static void setEnabled(boolean isEnabled) {
// sIsEnabled = isEnabled;
// }
//
// public static void start(@NonNull Context context) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("start", Context.class);
// method.invoke(null, context);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static void start(@NonNull Context context, int port) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("start", Context.class, int.class);
// method.invoke(null, context, port);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static void stop(@NonNull Context context) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("stop", Context.class);
// method.invoke(null, context);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static int getPort() {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("getPort");
// return (int) method.invoke(null);
// } catch (Exception ignored) {
// }
// }
// return -1;
// }
//
// @Nullable
// public static String getIp() {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("getIp");
// return (String) method.invoke(null);
// } catch (Exception ignored) {
// }
// }
// return null;
// }
//
// public static void addLog(@NonNull Context context, @NonNull String text) {
// addLog(context, text, null);
// }
//
// public static void addLog(@NonNull Context context, @NonNull String text, @Nullable Throwable throwable) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("addLog", Context.class, String.class, Throwable.class);
// method.invoke(null, context, text, throwable);
// } catch (Exception ignored) {
// }
// }
// }
//
// @NonNull
// public static String getLogDownloadPath() {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("getLogDownloadPath");
// return (String) method.invoke(null);
// } catch (Exception ignored) {
// }
// }
// return "";
// }
//
// public static void clearLogs(@NonNull Context context) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("clearLogs", Context.class);
// method.invoke(null, context);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static void saveValue(@NonNull Context context, @NonNull String key, @Nullable Object value) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("saveValue", Context.class, String.class, Object.class);
// method.invoke(null, context, key, value);
// } catch (Exception ignored) {
// }
// }
// }
// }
| import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Random;
import ru.bartwell.ultradebugger.wrapper.UltraDebuggerWrapper; | package ru.bartwell.ultradebugger.sampleapp;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Fill information about IP and port | // Path: wrapper/src/main/java/ru/bartwell/ultradebugger/wrapper/UltraDebuggerWrapper.java
// public class UltraDebuggerWrapper {
//
// private static boolean sIsEnabled = true;
//
// private UltraDebuggerWrapper() {
// }
//
// public static void setEnabled(boolean isEnabled) {
// sIsEnabled = isEnabled;
// }
//
// public static void start(@NonNull Context context) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("start", Context.class);
// method.invoke(null, context);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static void start(@NonNull Context context, int port) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("start", Context.class, int.class);
// method.invoke(null, context, port);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static void stop(@NonNull Context context) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("stop", Context.class);
// method.invoke(null, context);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static int getPort() {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("getPort");
// return (int) method.invoke(null);
// } catch (Exception ignored) {
// }
// }
// return -1;
// }
//
// @Nullable
// public static String getIp() {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.UltraDebugger");
// Method method = clazz.getMethod("getIp");
// return (String) method.invoke(null);
// } catch (Exception ignored) {
// }
// }
// return null;
// }
//
// public static void addLog(@NonNull Context context, @NonNull String text) {
// addLog(context, text, null);
// }
//
// public static void addLog(@NonNull Context context, @NonNull String text, @Nullable Throwable throwable) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("addLog", Context.class, String.class, Throwable.class);
// method.invoke(null, context, text, throwable);
// } catch (Exception ignored) {
// }
// }
// }
//
// @NonNull
// public static String getLogDownloadPath() {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("getLogDownloadPath");
// return (String) method.invoke(null);
// } catch (Exception ignored) {
// }
// }
// return "";
// }
//
// public static void clearLogs(@NonNull Context context) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("clearLogs", Context.class);
// method.invoke(null, context);
// } catch (Exception ignored) {
// }
// }
// }
//
// public static void saveValue(@NonNull Context context, @NonNull String key, @Nullable Object value) {
// if (sIsEnabled) {
// try {
// Class<?> clazz = Class.forName("ru.bartwell.ultradebugger.module.logger.Logger");
// Method method = clazz.getMethod("saveValue", Context.class, String.class, Object.class);
// method.invoke(null, context, key, value);
// } catch (Exception ignored) {
// }
// }
// }
// }
// Path: app/src/main/java/ru/bartwell/ultradebugger/sampleapp/MainActivity.java
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Random;
import ru.bartwell.ultradebugger.wrapper.UltraDebuggerWrapper;
package ru.bartwell.ultradebugger.sampleapp;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Fill information about IP and port | String ip = UltraDebuggerWrapper.getIp(); |
hsz/idea-latex | src/mobi/hsz/idea/latex/inspections/LatexSpellcheckingStrategy.java | // Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
| import com.intellij.psi.PsiElement;
import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy;
import com.intellij.spellchecker.tokenizer.Tokenizer;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.psi.LatexText;
import org.jetbrains.annotations.NotNull; | /*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.inspections;
/**
* {@link SpellcheckingStrategy} implementation for LaTeX language.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexSpellcheckingStrategy extends SpellcheckingStrategy {
/**
* Checks if elements is supported.
*
* @param element to check
* @return element is {@link LatexLanguage} instance
*/
@Override
public boolean isMyContext(@NotNull PsiElement element) { | // Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
// Path: src/mobi/hsz/idea/latex/inspections/LatexSpellcheckingStrategy.java
import com.intellij.psi.PsiElement;
import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy;
import com.intellij.spellchecker.tokenizer.Tokenizer;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.psi.LatexText;
import org.jetbrains.annotations.NotNull;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.inspections;
/**
* {@link SpellcheckingStrategy} implementation for LaTeX language.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexSpellcheckingStrategy extends SpellcheckingStrategy {
/**
* Checks if elements is supported.
*
* @param element to check
* @return element is {@link LatexLanguage} instance
*/
@Override
public boolean isMyContext(@NotNull PsiElement element) { | return LatexLanguage.INSTANCE.is(element.getLanguage()); |
hsz/idea-latex | src/mobi/hsz/idea/latex/actions/CreateLatexFileAction.java | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/util/Icons.java
// public class Icons {
//
// public static final Icon FILE = IconLoader.getIcon("/icons/tex.png");
//
// public static class Editor {
//
// public static final Icon ALIGN_LEFT = IconLoader.getIcon("/icons/editor/align_left.png");
// public static final Icon ALIGN_CENTER = IconLoader.getIcon("/icons/editor/align_center.png");
// public static final Icon ALIGN_RIGHT = IconLoader.getIcon("/icons/editor/align_right.png");
// public static final Icon BOLD = IconLoader.getIcon("/icons/editor/bold.png");
// public static final Icon IMAGE = IconLoader.getIcon("/icons/editor/image.png");
// public static final Icon ITALIC = IconLoader.getIcon("/icons/editor/italic.png");
// public static final Icon MATRIX = IconLoader.getIcon("/icons/editor/matrix.png");
// public static final Icon TABLE = IconLoader.getIcon("/icons/editor/table.png");
// public static final Icon UNDERLINE = IconLoader.getIcon("/icons/editor/underline.png");
//
// }
//
// }
| import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.psi.LatexFile;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.Nullable;
import com.intellij.ide.actions.CreateFileFromTemplateDialog;
import com.intellij.ide.actions.CreateFromTemplateAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import mobi.hsz.idea.latex.LatexBundle; | /*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions;
/**
* New file action
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class CreateLatexFileAction extends CreateFromTemplateAction<LatexFile> implements DumbAware {
public CreateLatexFileAction() { | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/util/Icons.java
// public class Icons {
//
// public static final Icon FILE = IconLoader.getIcon("/icons/tex.png");
//
// public static class Editor {
//
// public static final Icon ALIGN_LEFT = IconLoader.getIcon("/icons/editor/align_left.png");
// public static final Icon ALIGN_CENTER = IconLoader.getIcon("/icons/editor/align_center.png");
// public static final Icon ALIGN_RIGHT = IconLoader.getIcon("/icons/editor/align_right.png");
// public static final Icon BOLD = IconLoader.getIcon("/icons/editor/bold.png");
// public static final Icon IMAGE = IconLoader.getIcon("/icons/editor/image.png");
// public static final Icon ITALIC = IconLoader.getIcon("/icons/editor/italic.png");
// public static final Icon MATRIX = IconLoader.getIcon("/icons/editor/matrix.png");
// public static final Icon TABLE = IconLoader.getIcon("/icons/editor/table.png");
// public static final Icon UNDERLINE = IconLoader.getIcon("/icons/editor/underline.png");
//
// }
//
// }
// Path: src/mobi/hsz/idea/latex/actions/CreateLatexFileAction.java
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.psi.LatexFile;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.Nullable;
import com.intellij.ide.actions.CreateFileFromTemplateDialog;
import com.intellij.ide.actions.CreateFromTemplateAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import mobi.hsz.idea.latex.LatexBundle;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions;
/**
* New file action
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class CreateLatexFileAction extends CreateFromTemplateAction<LatexFile> implements DumbAware {
public CreateLatexFileAction() { | super(LatexBundle.message("action.create.file"), LatexBundle.message("action.create.file.description"), Icons.FILE); |
hsz/idea-latex | src/mobi/hsz/idea/latex/actions/CreateLatexFileAction.java | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/util/Icons.java
// public class Icons {
//
// public static final Icon FILE = IconLoader.getIcon("/icons/tex.png");
//
// public static class Editor {
//
// public static final Icon ALIGN_LEFT = IconLoader.getIcon("/icons/editor/align_left.png");
// public static final Icon ALIGN_CENTER = IconLoader.getIcon("/icons/editor/align_center.png");
// public static final Icon ALIGN_RIGHT = IconLoader.getIcon("/icons/editor/align_right.png");
// public static final Icon BOLD = IconLoader.getIcon("/icons/editor/bold.png");
// public static final Icon IMAGE = IconLoader.getIcon("/icons/editor/image.png");
// public static final Icon ITALIC = IconLoader.getIcon("/icons/editor/italic.png");
// public static final Icon MATRIX = IconLoader.getIcon("/icons/editor/matrix.png");
// public static final Icon TABLE = IconLoader.getIcon("/icons/editor/table.png");
// public static final Icon UNDERLINE = IconLoader.getIcon("/icons/editor/underline.png");
//
// }
//
// }
| import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.psi.LatexFile;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.Nullable;
import com.intellij.ide.actions.CreateFileFromTemplateDialog;
import com.intellij.ide.actions.CreateFromTemplateAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import mobi.hsz.idea.latex.LatexBundle; | /*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions;
/**
* New file action
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class CreateLatexFileAction extends CreateFromTemplateAction<LatexFile> implements DumbAware {
public CreateLatexFileAction() { | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/util/Icons.java
// public class Icons {
//
// public static final Icon FILE = IconLoader.getIcon("/icons/tex.png");
//
// public static class Editor {
//
// public static final Icon ALIGN_LEFT = IconLoader.getIcon("/icons/editor/align_left.png");
// public static final Icon ALIGN_CENTER = IconLoader.getIcon("/icons/editor/align_center.png");
// public static final Icon ALIGN_RIGHT = IconLoader.getIcon("/icons/editor/align_right.png");
// public static final Icon BOLD = IconLoader.getIcon("/icons/editor/bold.png");
// public static final Icon IMAGE = IconLoader.getIcon("/icons/editor/image.png");
// public static final Icon ITALIC = IconLoader.getIcon("/icons/editor/italic.png");
// public static final Icon MATRIX = IconLoader.getIcon("/icons/editor/matrix.png");
// public static final Icon TABLE = IconLoader.getIcon("/icons/editor/table.png");
// public static final Icon UNDERLINE = IconLoader.getIcon("/icons/editor/underline.png");
//
// }
//
// }
// Path: src/mobi/hsz/idea/latex/actions/CreateLatexFileAction.java
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.psi.LatexFile;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.Nullable;
import com.intellij.ide.actions.CreateFileFromTemplateDialog;
import com.intellij.ide.actions.CreateFromTemplateAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import mobi.hsz.idea.latex.LatexBundle;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions;
/**
* New file action
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class CreateLatexFileAction extends CreateFromTemplateAction<LatexFile> implements DumbAware {
public CreateLatexFileAction() { | super(LatexBundle.message("action.create.file"), LatexBundle.message("action.create.file.description"), Icons.FILE); |
hsz/idea-latex | src/mobi/hsz/idea/latex/actions/CreateLatexFileAction.java | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/util/Icons.java
// public class Icons {
//
// public static final Icon FILE = IconLoader.getIcon("/icons/tex.png");
//
// public static class Editor {
//
// public static final Icon ALIGN_LEFT = IconLoader.getIcon("/icons/editor/align_left.png");
// public static final Icon ALIGN_CENTER = IconLoader.getIcon("/icons/editor/align_center.png");
// public static final Icon ALIGN_RIGHT = IconLoader.getIcon("/icons/editor/align_right.png");
// public static final Icon BOLD = IconLoader.getIcon("/icons/editor/bold.png");
// public static final Icon IMAGE = IconLoader.getIcon("/icons/editor/image.png");
// public static final Icon ITALIC = IconLoader.getIcon("/icons/editor/italic.png");
// public static final Icon MATRIX = IconLoader.getIcon("/icons/editor/matrix.png");
// public static final Icon TABLE = IconLoader.getIcon("/icons/editor/table.png");
// public static final Icon UNDERLINE = IconLoader.getIcon("/icons/editor/underline.png");
//
// }
//
// }
| import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.psi.LatexFile;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.Nullable;
import com.intellij.ide.actions.CreateFileFromTemplateDialog;
import com.intellij.ide.actions.CreateFromTemplateAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import mobi.hsz.idea.latex.LatexBundle; | /*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions;
/**
* New file action
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class CreateLatexFileAction extends CreateFromTemplateAction<LatexFile> implements DumbAware {
public CreateLatexFileAction() {
super(LatexBundle.message("action.create.file"), LatexBundle.message("action.create.file.description"), Icons.FILE);
}
@Override
protected String getDefaultTemplateProperty() {
return LatexTemplates.LATEX_EMPTY;
}
@Nullable
@Override
protected LatexFile createFile(String name, String templateName, PsiDirectory dir) { | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/util/Icons.java
// public class Icons {
//
// public static final Icon FILE = IconLoader.getIcon("/icons/tex.png");
//
// public static class Editor {
//
// public static final Icon ALIGN_LEFT = IconLoader.getIcon("/icons/editor/align_left.png");
// public static final Icon ALIGN_CENTER = IconLoader.getIcon("/icons/editor/align_center.png");
// public static final Icon ALIGN_RIGHT = IconLoader.getIcon("/icons/editor/align_right.png");
// public static final Icon BOLD = IconLoader.getIcon("/icons/editor/bold.png");
// public static final Icon IMAGE = IconLoader.getIcon("/icons/editor/image.png");
// public static final Icon ITALIC = IconLoader.getIcon("/icons/editor/italic.png");
// public static final Icon MATRIX = IconLoader.getIcon("/icons/editor/matrix.png");
// public static final Icon TABLE = IconLoader.getIcon("/icons/editor/table.png");
// public static final Icon UNDERLINE = IconLoader.getIcon("/icons/editor/underline.png");
//
// }
//
// }
// Path: src/mobi/hsz/idea/latex/actions/CreateLatexFileAction.java
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.psi.LatexFile;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.Nullable;
import com.intellij.ide.actions.CreateFileFromTemplateDialog;
import com.intellij.ide.actions.CreateFromTemplateAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import mobi.hsz.idea.latex.LatexBundle;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions;
/**
* New file action
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class CreateLatexFileAction extends CreateFromTemplateAction<LatexFile> implements DumbAware {
public CreateLatexFileAction() {
super(LatexBundle.message("action.create.file"), LatexBundle.message("action.create.file.description"), Icons.FILE);
}
@Override
protected String getDefaultTemplateProperty() {
return LatexTemplates.LATEX_EMPTY;
}
@Nullable
@Override
protected LatexFile createFile(String name, String templateName, PsiDirectory dir) { | String filename = name.endsWith("." + LatexLanguage.EXTENSION) ? name : name + "." + LatexLanguage.EXTENSION; |
hsz/idea-latex | src/mobi/hsz/idea/latex/reference/LatexReferenceContributor.java | // Path: src/mobi/hsz/idea/latex/psi/impl/LatexInstructionExtImpl.java
// public abstract class LatexInstructionExtImpl extends LatexElementImpl implements LatexInstruction {
//
// /** {@link TokenSet} containing all identifier types. */
// private static final TokenSet IDENTIFIERS = TokenSet.create(IDENTIFIER, IDENTIFIER_BEGIN, IDENTIFIER_END);
//
// /** Default constructor. */
// LatexInstructionExtImpl(ASTNode node) {
// super(node);
// }
//
// /** Returns list of identifiers and identifiers subtypes. */
// @NotNull
// public PsiElement getIdentifier() {
// return findNotNullChildByType(IDENTIFIERS);
// }
//
// /**
// * Returns the {@link LatexInstruction} arguments list.
// *
// * @return {@link LatexArgument} instances list.
// */
// @Override
// @NotNull
// public List<LatexArgument> getArgumentList() {
// return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexArgument.class);
// }
//
// /**
// * Returns the {@link LatexInstruction} argument.
// *
// * @return {@link LatexArgument} instance.
// */
// @Nullable
// public LatexArgument getArgument() {
// return findChildByClass(LatexArgument.class);
// }
//
// }
| import mobi.hsz.idea.latex.psi.impl.LatexInstructionExtImpl;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import static com.intellij.patterns.PlatformPatterns.psiElement;
import static com.intellij.patterns.PlatformPatterns.psiFile;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet;
import com.intellij.util.ProcessingContext;
import mobi.hsz.idea.latex.psi.LatexArgument;
import mobi.hsz.idea.latex.psi.LatexFile;
import mobi.hsz.idea.latex.psi.LatexInstruction; | /*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.reference;
/**
* PSI elements references contributor.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexReferenceContributor extends PsiReferenceContributor {
/**
* Registers new references provider for PSI element.
*
* @param psiReferenceRegistrar reference provider
*/
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar psiReferenceRegistrar) {
psiReferenceRegistrar.registerReferenceProvider(psiElement().inFile(psiFile(LatexFile.class)), new LatexReferenceProvider());
}
/** Reference provider definition. */
private static class LatexReferenceProvider extends PsiReferenceProvider {
private static final String[] IDENTIFIERS = {"\\input", "\\include", "\\includeonly"};
/**
* Returns references for given @{link PsiElement}.
*
* @param psiElement current element
* @param processingContext context
* @return {@link PsiReference} list
*/
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
if (psiElement instanceof LatexInstruction) { | // Path: src/mobi/hsz/idea/latex/psi/impl/LatexInstructionExtImpl.java
// public abstract class LatexInstructionExtImpl extends LatexElementImpl implements LatexInstruction {
//
// /** {@link TokenSet} containing all identifier types. */
// private static final TokenSet IDENTIFIERS = TokenSet.create(IDENTIFIER, IDENTIFIER_BEGIN, IDENTIFIER_END);
//
// /** Default constructor. */
// LatexInstructionExtImpl(ASTNode node) {
// super(node);
// }
//
// /** Returns list of identifiers and identifiers subtypes. */
// @NotNull
// public PsiElement getIdentifier() {
// return findNotNullChildByType(IDENTIFIERS);
// }
//
// /**
// * Returns the {@link LatexInstruction} arguments list.
// *
// * @return {@link LatexArgument} instances list.
// */
// @Override
// @NotNull
// public List<LatexArgument> getArgumentList() {
// return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexArgument.class);
// }
//
// /**
// * Returns the {@link LatexInstruction} argument.
// *
// * @return {@link LatexArgument} instance.
// */
// @Nullable
// public LatexArgument getArgument() {
// return findChildByClass(LatexArgument.class);
// }
//
// }
// Path: src/mobi/hsz/idea/latex/reference/LatexReferenceContributor.java
import mobi.hsz.idea.latex.psi.impl.LatexInstructionExtImpl;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import static com.intellij.patterns.PlatformPatterns.psiElement;
import static com.intellij.patterns.PlatformPatterns.psiFile;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet;
import com.intellij.util.ProcessingContext;
import mobi.hsz.idea.latex.psi.LatexArgument;
import mobi.hsz.idea.latex.psi.LatexFile;
import mobi.hsz.idea.latex.psi.LatexInstruction;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.reference;
/**
* PSI elements references contributor.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexReferenceContributor extends PsiReferenceContributor {
/**
* Registers new references provider for PSI element.
*
* @param psiReferenceRegistrar reference provider
*/
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar psiReferenceRegistrar) {
psiReferenceRegistrar.registerReferenceProvider(psiElement().inFile(psiFile(LatexFile.class)), new LatexReferenceProvider());
}
/** Reference provider definition. */
private static class LatexReferenceProvider extends PsiReferenceProvider {
private static final String[] IDENTIFIERS = {"\\input", "\\include", "\\includeonly"};
/**
* Returns references for given @{link PsiElement}.
*
* @param psiElement current element
* @param processingContext context
* @return {@link PsiReference} list
*/
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
if (psiElement instanceof LatexInstruction) { | LatexInstructionExtImpl instruction = (LatexInstructionExtImpl) psiElement; |
hsz/idea-latex | src/mobi/hsz/idea/latex/ui/ImageEditorActionDialog.java | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
| import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import mobi.hsz.idea.latex.LatexBundle;
import org.jetbrains.annotations.NotNull; | /*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.ui;
public class ImageEditorActionDialog extends DialogWrapper {
private JPanel panel;
private TextFieldWithBrowseButton path;
private JTextField caption;
private JTextField label;
public ImageEditorActionDialog(@NotNull Project project) {
super(project);
| // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
// Path: src/mobi/hsz/idea/latex/ui/ImageEditorActionDialog.java
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import mobi.hsz.idea.latex.LatexBundle;
import org.jetbrains.annotations.NotNull;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.ui;
public class ImageEditorActionDialog extends DialogWrapper {
private JPanel panel;
private TextFieldWithBrowseButton path;
private JTextField caption;
private JTextField label;
public ImageEditorActionDialog(@NotNull Project project) {
super(project);
| path.addBrowseFolderListener(LatexBundle.message("editor.image.dialog.browse"), null, project, FileChooserDescriptorFactory.createSingleFileDescriptor()); |
hsz/idea-latex | src/mobi/hsz/idea/latex/file/LatexFileTypeFactory.java | // Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
| import com.intellij.openapi.fileTypes.FileTypeConsumer;
import com.intellij.openapi.fileTypes.FileTypeFactory;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import org.jetbrains.annotations.NotNull; | /*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.file;
/**
* Class that assigns file types with languages.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexFileTypeFactory extends FileTypeFactory {
/**
* Assigns file types with languages.
*
* @param consumer file types consumer
*/
@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer) { | // Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
// Path: src/mobi/hsz/idea/latex/file/LatexFileTypeFactory.java
import com.intellij.openapi.fileTypes.FileTypeConsumer;
import com.intellij.openapi.fileTypes.FileTypeFactory;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import org.jetbrains.annotations.NotNull;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.file;
/**
* Class that assigns file types with languages.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexFileTypeFactory extends FileTypeFactory {
/**
* Assigns file types with languages.
*
* @param consumer file types consumer
*/
@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer) { | consumer.consume(LatexFileType.INSTANCE, LatexLanguage.EXTENSION); |
hsz/idea-latex | src/mobi/hsz/idea/latex/actions/editor/base/EditorAction.java | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
| import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.psi.LatexFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*; | return false;
}
/**
* Checks if action related type matched to the given element in document.
*
* @param element to check
* @return element matches to the action related type
*/
@Nullable
protected PsiElement getMatchedElement(@Nullable PsiElement element) {
while (element != null && !(element instanceof LatexFile)) {
if (isMatching(element)) {
return element;
}
element = element.getParent();
}
return null;
}
/**
* Runs write action.
*
* @param project current project
* @param action to run
*/
final protected void runWriteAction(@NotNull final Project project, @NotNull final Runnable action) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() { | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
// Path: src/mobi/hsz/idea/latex/actions/editor/base/EditorAction.java
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.psi.LatexFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
return false;
}
/**
* Checks if action related type matched to the given element in document.
*
* @param element to check
* @return element matches to the action related type
*/
@Nullable
protected PsiElement getMatchedElement(@Nullable PsiElement element) {
while (element != null && !(element instanceof LatexFile)) {
if (isMatching(element)) {
return element;
}
element = element.getParent();
}
return null;
}
/**
* Runs write action.
*
* @param project current project
* @param action to run
*/
final protected void runWriteAction(@NotNull final Project project, @NotNull final Runnable action) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() { | CommandProcessor.getInstance().executeCommand(project, action, getName(), LatexBundle.NAME); |
hsz/idea-latex | src/mobi/hsz/idea/latex/ui/MatrixEditorActionDialog.java | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
| import javax.swing.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import mobi.hsz.idea.latex.LatexBundle;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; | /*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.ui;
public class MatrixEditorActionDialog extends DialogWrapper {
public enum Bracket {
NONE('\0'), PARENTHESES('p'), BRACKETS('b'), BRACES('B'), SINGLE_LINE('v'), DOUBLE_LINE('V');
private final char value;
Bracket(char value) {
this.value = value;
}
public char getValue() {
return value;
}
@Override
public String toString() { | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
// Path: src/mobi/hsz/idea/latex/ui/MatrixEditorActionDialog.java
import javax.swing.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import mobi.hsz.idea.latex.LatexBundle;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.ui;
public class MatrixEditorActionDialog extends DialogWrapper {
public enum Bracket {
NONE('\0'), PARENTHESES('p'), BRACKETS('b'), BRACES('B'), SINGLE_LINE('v'), DOUBLE_LINE('V');
private final char value;
Bracket(char value) {
this.value = value;
}
public char getValue() {
return value;
}
@Override
public String toString() { | return LatexBundle.message("form.bracket." + name().toLowerCase()); |
hsz/idea-latex | src/mobi/hsz/idea/latex/settings/LatexSettings.java | // Path: src/mobi/hsz/idea/latex/util/Listenable.java
// public interface Listenable<T> {
// /**
// * Add the given listener. The listener will be executed in the containing instance's thread.
// *
// * @param listener listener to add
// */
// void addListener(@NotNull T listener);
//
// /**
// * Remove the given listener.
// *
// * @param listener listener to remove
// */
// void removeListener(@NotNull T listener);
// }
| import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.containers.ContainerUtil;
import mobi.hsz.idea.latex.util.Listenable; | /*
* The MIT License (MIT)
*
* Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.settings;
/**
* Persistent global settings object for the LaTeX plugin.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3.0
*/
@State(
name = "LatexSettings",
storages = @Storage(id = "other", file = "$APP_CONFIG$/latex.xml")
) | // Path: src/mobi/hsz/idea/latex/util/Listenable.java
// public interface Listenable<T> {
// /**
// * Add the given listener. The listener will be executed in the containing instance's thread.
// *
// * @param listener listener to add
// */
// void addListener(@NotNull T listener);
//
// /**
// * Remove the given listener.
// *
// * @param listener listener to remove
// */
// void removeListener(@NotNull T listener);
// }
// Path: src/mobi/hsz/idea/latex/settings/LatexSettings.java
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.containers.ContainerUtil;
import mobi.hsz.idea.latex.util.Listenable;
/*
* The MIT License (MIT)
*
* Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.settings;
/**
* Persistent global settings object for the LaTeX plugin.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3.0
*/
@State(
name = "LatexSettings",
storages = @Storage(id = "other", file = "$APP_CONFIG$/latex.xml")
) | public class LatexSettings implements PersistentStateComponent<Element>, Listenable<LatexSettings.Listener> { |
hsz/idea-latex | src/mobi/hsz/idea/latex/psi/LatexTokenType.java | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
| import com.intellij.psi.tree.IElementType;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull; | /*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.psi;
/**
* Token type definition.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexTokenType extends IElementType {
/** Token debug name. */
private final String debugName;
/** Builds a new instance of @{link IgnoreTokenType}. */
LatexTokenType(@NotNull @NonNls String debugName) {
super(debugName, LatexLanguage.INSTANCE);
this.debugName = debugName;
}
/**
* String interpretation of the token type.
*
* @return string representation
*/
@Override
public String toString() { | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
// Path: src/mobi/hsz/idea/latex/psi/LatexTokenType.java
import com.intellij.psi.tree.IElementType;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.psi;
/**
* Token type definition.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexTokenType extends IElementType {
/** Token debug name. */
private final String debugName;
/** Builds a new instance of @{link IgnoreTokenType}. */
LatexTokenType(@NotNull @NonNls String debugName) {
super(debugName, LatexLanguage.INSTANCE);
this.debugName = debugName;
}
/**
* String interpretation of the token type.
*
* @return string representation
*/
@Override
public String toString() { | return LatexBundle.messageOrDefault("tokenType." + debugName, getLanguage().getDisplayName() + "TokenType." + super.toString()); |
hsz/idea-latex | src/mobi/hsz/idea/latex/util/Utils.java | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
| import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.util.text.StringUtil;
import mobi.hsz.idea.latex.LatexBundle; | /*
* The MIT License (MIT)
*
* Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.util;
/**
* {@link Utils} class that contains various methods.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3.0
*/
public class Utils {
/** Private constructor to prevent creating {@link Utils} instance. */
private Utils() {
}
/**
* Returns Gitignore plugin information.
*
* @return {@link IdeaPluginDescriptor}
*/
public static IdeaPluginDescriptor getPlugin() { | // Path: src/mobi/hsz/idea/latex/LatexBundle.java
// public class LatexBundle {
//
// /** Gitignore plugin ID. */
// @NonNls
// public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
//
// /** The {@link java.util.ResourceBundle} path. */
// @NonNls
// private static final String BUNDLE_NAME = "messages.LatexBundle";
//
// /** The {@link java.util.ResourceBundle} instance. */
// private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
//
// /** Plugin name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** {@link LatexBundle} is a non-instantiable static class. */
// private LatexBundle() {
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
// return CommonBundle.message(BUNDLE, key, params);
// }
//
// /**
// * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
// *
// * @param key the key of the resource
// * @param defaultValue the default value that will be returned if there is nothing set
// * @param params the optional parameters for the specific resource
// * @return the {@link String} value or {@code null} if no resource found for the key
// */
// public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
// return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
// }
//
// }
// Path: src/mobi/hsz/idea/latex/util/Utils.java
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.util.text.StringUtil;
import mobi.hsz.idea.latex.LatexBundle;
/*
* The MIT License (MIT)
*
* Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.util;
/**
* {@link Utils} class that contains various methods.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3.0
*/
public class Utils {
/** Private constructor to prevent creating {@link Utils} instance. */
private Utils() {
}
/**
* Returns Gitignore plugin information.
*
* @return {@link IdeaPluginDescriptor}
*/
public static IdeaPluginDescriptor getPlugin() { | return PluginManager.getPlugin(PluginId.getId(LatexBundle.PLUGIN_ID)); |
hsz/idea-latex | src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleMainPanel.java | // Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
| import com.intellij.application.options.TabbedLanguageCodeStylePanel;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import mobi.hsz.idea.latex.lang.LatexLanguage; | /*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.codeStyle;
/**
* LaTeX {@link TabbedLanguageCodeStylePanel} implementation of the main panel.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexCodeStyleMainPanel extends TabbedLanguageCodeStylePanel {
protected LatexCodeStyleMainPanel(CodeStyleSettings currentSettings, CodeStyleSettings settings) { | // Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
// Path: src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleMainPanel.java
import com.intellij.application.options.TabbedLanguageCodeStylePanel;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import mobi.hsz.idea.latex.lang.LatexLanguage;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.codeStyle;
/**
* LaTeX {@link TabbedLanguageCodeStylePanel} implementation of the main panel.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexCodeStyleMainPanel extends TabbedLanguageCodeStylePanel {
protected LatexCodeStyleMainPanel(CodeStyleSettings currentSettings, CodeStyleSettings settings) { | super(LatexLanguage.INSTANCE, currentSettings, settings); |
hsz/idea-latex | src/mobi/hsz/idea/latex/file/LatexFileType.java | // Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/util/Icons.java
// public class Icons {
//
// public static final Icon FILE = IconLoader.getIcon("/icons/tex.png");
//
// public static class Editor {
//
// public static final Icon ALIGN_LEFT = IconLoader.getIcon("/icons/editor/align_left.png");
// public static final Icon ALIGN_CENTER = IconLoader.getIcon("/icons/editor/align_center.png");
// public static final Icon ALIGN_RIGHT = IconLoader.getIcon("/icons/editor/align_right.png");
// public static final Icon BOLD = IconLoader.getIcon("/icons/editor/bold.png");
// public static final Icon IMAGE = IconLoader.getIcon("/icons/editor/image.png");
// public static final Icon ITALIC = IconLoader.getIcon("/icons/editor/italic.png");
// public static final Icon MATRIX = IconLoader.getIcon("/icons/editor/matrix.png");
// public static final Icon TABLE = IconLoader.getIcon("/icons/editor/table.png");
// public static final Icon UNDERLINE = IconLoader.getIcon("/icons/editor/underline.png");
//
// }
//
// }
| import javax.swing.*;
import com.intellij.openapi.fileTypes.LanguageFileType;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; | /*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.file;
/**
* Describes LaTeX file type.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexFileType extends LanguageFileType {
/** Contains {@link LatexFileType} singleton. */
public static final LatexFileType INSTANCE = new LatexFileType();
/** Private constructor to prevent direct object creation. */
private LatexFileType() {
super(LatexLanguage.INSTANCE);
}
/**
* Returns the name of the file type. The name must be unique among all file types registered in the system.
*
* @return The file type name.
*/
@NotNull
@Override
public String getName() {
return LatexLanguage.NAME + " file";
}
/**
* Returns the user-readable description of the file type.
*
* @return The file type description.
*/
@NotNull
@Override
public String getDescription() {
return LatexLanguage.NAME + " file";
}
/**
* Returns the default extension for files of the type.
*
* @return The extension, not including the leading '.'.
*/
@NotNull
@Override
public String getDefaultExtension() {
return LatexLanguage.EXTENSION;
}
/**
* Returns the icon used for showing files of the type.
*
* @return The icon instance, or null if no icon should be shown.
*/
@Nullable
@Override
public Icon getIcon() { | // Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/util/Icons.java
// public class Icons {
//
// public static final Icon FILE = IconLoader.getIcon("/icons/tex.png");
//
// public static class Editor {
//
// public static final Icon ALIGN_LEFT = IconLoader.getIcon("/icons/editor/align_left.png");
// public static final Icon ALIGN_CENTER = IconLoader.getIcon("/icons/editor/align_center.png");
// public static final Icon ALIGN_RIGHT = IconLoader.getIcon("/icons/editor/align_right.png");
// public static final Icon BOLD = IconLoader.getIcon("/icons/editor/bold.png");
// public static final Icon IMAGE = IconLoader.getIcon("/icons/editor/image.png");
// public static final Icon ITALIC = IconLoader.getIcon("/icons/editor/italic.png");
// public static final Icon MATRIX = IconLoader.getIcon("/icons/editor/matrix.png");
// public static final Icon TABLE = IconLoader.getIcon("/icons/editor/table.png");
// public static final Icon UNDERLINE = IconLoader.getIcon("/icons/editor/underline.png");
//
// }
//
// }
// Path: src/mobi/hsz/idea/latex/file/LatexFileType.java
import javax.swing.*;
import com.intellij.openapi.fileTypes.LanguageFileType;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.file;
/**
* Describes LaTeX file type.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexFileType extends LanguageFileType {
/** Contains {@link LatexFileType} singleton. */
public static final LatexFileType INSTANCE = new LatexFileType();
/** Private constructor to prevent direct object creation. */
private LatexFileType() {
super(LatexLanguage.INSTANCE);
}
/**
* Returns the name of the file type. The name must be unique among all file types registered in the system.
*
* @return The file type name.
*/
@NotNull
@Override
public String getName() {
return LatexLanguage.NAME + " file";
}
/**
* Returns the user-readable description of the file type.
*
* @return The file type description.
*/
@NotNull
@Override
public String getDescription() {
return LatexLanguage.NAME + " file";
}
/**
* Returns the default extension for files of the type.
*
* @return The extension, not including the leading '.'.
*/
@NotNull
@Override
public String getDefaultExtension() {
return LatexLanguage.EXTENSION;
}
/**
* Returns the icon used for showing files of the type.
*
* @return The icon instance, or null if no icon should be shown.
*/
@Nullable
@Override
public Icon getIcon() { | return Icons.FILE; |
hsz/idea-latex | src/mobi/hsz/idea/latex/editor/LatexEditorActionsLoaderComponent.java | // Path: src/mobi/hsz/idea/latex/file/LatexFileType.java
// public class LatexFileType extends LanguageFileType {
//
// /** Contains {@link LatexFileType} singleton. */
// public static final LatexFileType INSTANCE = new LatexFileType();
//
// /** Private constructor to prevent direct object creation. */
// private LatexFileType() {
// super(LatexLanguage.INSTANCE);
// }
//
// /**
// * Returns the name of the file type. The name must be unique among all file types registered in the system.
// *
// * @return The file type name.
// */
// @NotNull
// @Override
// public String getName() {
// return LatexLanguage.NAME + " file";
// }
//
// /**
// * Returns the user-readable description of the file type.
// *
// * @return The file type description.
// */
// @NotNull
// @Override
// public String getDescription() {
// return LatexLanguage.NAME + " file";
// }
//
// /**
// * Returns the default extension for files of the type.
// *
// * @return The extension, not including the leading '.'.
// */
// @NotNull
// @Override
// public String getDefaultExtension() {
// return LatexLanguage.EXTENSION;
// }
//
// /**
// * Returns the icon used for showing files of the type.
// *
// * @return The icon instance, or null if no icon should be shown.
// */
// @Nullable
// @Override
// public Icon getIcon() {
// return Icons.FILE;
// }
//
// }
| import com.intellij.openapi.vfs.VirtualFile;
import mobi.hsz.idea.latex.file.LatexFileType;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer; | /*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.editor;
/**
* Component loader for editor actions toolbar.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexEditorActionsLoaderComponent extends AbstractProjectComponent {
/** Constructor. */
public LatexEditorActionsLoaderComponent(@NotNull final Project project) {
super(project);
}
/**
* Returns component name.
*
* @return component name
*/
@Override
@NonNls
@NotNull
public String getComponentName() {
return "LatexEditorActionsLoaderComponent";
}
/** Initializes component. */
@Override
public void initComponent() {
myProject.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new LatexEditorManagerListener());
}
/** Listener for LaTeX editor manager. */
private static class LatexEditorManagerListener extends FileEditorManagerAdapter {
/**
* Handles file opening event and attaches LaTeX editor component.
*
* @param source editor manager
* @param file current file
*/
@Override
public void fileOpened(@NotNull final FileEditorManager source, @NotNull final VirtualFile file) {
FileType fileType = file.getFileType(); | // Path: src/mobi/hsz/idea/latex/file/LatexFileType.java
// public class LatexFileType extends LanguageFileType {
//
// /** Contains {@link LatexFileType} singleton. */
// public static final LatexFileType INSTANCE = new LatexFileType();
//
// /** Private constructor to prevent direct object creation. */
// private LatexFileType() {
// super(LatexLanguage.INSTANCE);
// }
//
// /**
// * Returns the name of the file type. The name must be unique among all file types registered in the system.
// *
// * @return The file type name.
// */
// @NotNull
// @Override
// public String getName() {
// return LatexLanguage.NAME + " file";
// }
//
// /**
// * Returns the user-readable description of the file type.
// *
// * @return The file type description.
// */
// @NotNull
// @Override
// public String getDescription() {
// return LatexLanguage.NAME + " file";
// }
//
// /**
// * Returns the default extension for files of the type.
// *
// * @return The extension, not including the leading '.'.
// */
// @NotNull
// @Override
// public String getDefaultExtension() {
// return LatexLanguage.EXTENSION;
// }
//
// /**
// * Returns the icon used for showing files of the type.
// *
// * @return The icon instance, or null if no icon should be shown.
// */
// @Nullable
// @Override
// public Icon getIcon() {
// return Icons.FILE;
// }
//
// }
// Path: src/mobi/hsz/idea/latex/editor/LatexEditorActionsLoaderComponent.java
import com.intellij.openapi.vfs.VirtualFile;
import mobi.hsz.idea.latex.file.LatexFileType;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.editor;
/**
* Component loader for editor actions toolbar.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexEditorActionsLoaderComponent extends AbstractProjectComponent {
/** Constructor. */
public LatexEditorActionsLoaderComponent(@NotNull final Project project) {
super(project);
}
/**
* Returns component name.
*
* @return component name
*/
@Override
@NonNls
@NotNull
public String getComponentName() {
return "LatexEditorActionsLoaderComponent";
}
/** Initializes component. */
@Override
public void initComponent() {
myProject.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new LatexEditorManagerListener());
}
/** Listener for LaTeX editor manager. */
private static class LatexEditorManagerListener extends FileEditorManagerAdapter {
/**
* Handles file opening event and attaches LaTeX editor component.
*
* @param source editor manager
* @param file current file
*/
@Override
public void fileOpened(@NotNull final FileEditorManager source, @NotNull final VirtualFile file) {
FileType fileType = file.getFileType(); | if (!(fileType instanceof LatexFileType)) { |
hsz/idea-latex | src/mobi/hsz/idea/latex/LatexUpdateComponent.java | // Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/util/Utils.java
// public class Utils {
// /** Private constructor to prevent creating {@link Utils} instance. */
// private Utils() {
// }
//
// /**
// * Returns Gitignore plugin information.
// *
// * @return {@link IdeaPluginDescriptor}
// */
// public static IdeaPluginDescriptor getPlugin() {
// return PluginManager.getPlugin(PluginId.getId(LatexBundle.PLUGIN_ID));
// }
//
// /**
// * Returns plugin major version.
// *
// * @return major version
// */
// public static String getMajorVersion() {
// return getVersion().split("\\.")[0];
// }
//
// /**
// * Returns plugin minor version.
// *
// * @return minor version
// */
// public static String getMinorVersion() {
// return StringUtil.join(getVersion().split("\\."), 0, 2, ".");
// }
//
// /**
// * Returns plugin version.
// *
// * @return version
// */
// public static String getVersion() {
// return getPlugin().getVersion();
// }
// }
| import org.jetbrains.annotations.NotNull;
import com.intellij.notification.*;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.project.Project;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.util.Utils; | /*
* The MIT License (MIT)
*
* Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex;
/**
* {@link ProjectComponent} instance to display plugin's update information.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3.0
*/
public class LatexUpdateComponent extends AbstractProjectComponent {
/** {@link LatexApplicationComponent} instance. */
private LatexApplicationComponent application;
/** Constructor. */
protected LatexUpdateComponent(Project project) {
super(project);
}
/** Component initialization method. */
@Override
public void initComponent() {
application = LatexApplicationComponent.getInstance();
}
/** Component dispose method. */
@Override
public void disposeComponent() {
}
/**
* Returns component's name.
*
* @return component's name
*/
@NotNull
@Override
public String getComponentName() {
return "LatexUpdateComponent";
}
/** Method called when project is opened. */
@Override
public void projectOpened() {
if (application.isUpdated() && !application.isUpdateNotificationShown()) {
application.setUpdateNotificationShown(true); | // Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/util/Utils.java
// public class Utils {
// /** Private constructor to prevent creating {@link Utils} instance. */
// private Utils() {
// }
//
// /**
// * Returns Gitignore plugin information.
// *
// * @return {@link IdeaPluginDescriptor}
// */
// public static IdeaPluginDescriptor getPlugin() {
// return PluginManager.getPlugin(PluginId.getId(LatexBundle.PLUGIN_ID));
// }
//
// /**
// * Returns plugin major version.
// *
// * @return major version
// */
// public static String getMajorVersion() {
// return getVersion().split("\\.")[0];
// }
//
// /**
// * Returns plugin minor version.
// *
// * @return minor version
// */
// public static String getMinorVersion() {
// return StringUtil.join(getVersion().split("\\."), 0, 2, ".");
// }
//
// /**
// * Returns plugin version.
// *
// * @return version
// */
// public static String getVersion() {
// return getPlugin().getVersion();
// }
// }
// Path: src/mobi/hsz/idea/latex/LatexUpdateComponent.java
import org.jetbrains.annotations.NotNull;
import com.intellij.notification.*;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.project.Project;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.util.Utils;
/*
* The MIT License (MIT)
*
* Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex;
/**
* {@link ProjectComponent} instance to display plugin's update information.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3.0
*/
public class LatexUpdateComponent extends AbstractProjectComponent {
/** {@link LatexApplicationComponent} instance. */
private LatexApplicationComponent application;
/** Constructor. */
protected LatexUpdateComponent(Project project) {
super(project);
}
/** Component initialization method. */
@Override
public void initComponent() {
application = LatexApplicationComponent.getInstance();
}
/** Component dispose method. */
@Override
public void disposeComponent() {
}
/**
* Returns component's name.
*
* @return component's name
*/
@NotNull
@Override
public String getComponentName() {
return "LatexUpdateComponent";
}
/** Method called when project is opened. */
@Override
public void projectOpened() {
if (application.isUpdated() && !application.isUpdateNotificationShown()) {
application.setUpdateNotificationShown(true); | NotificationGroup group = new NotificationGroup(LatexLanguage.GROUP, NotificationDisplayType.TOOL_WINDOW, true); |
hsz/idea-latex | src/mobi/hsz/idea/latex/LatexUpdateComponent.java | // Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/util/Utils.java
// public class Utils {
// /** Private constructor to prevent creating {@link Utils} instance. */
// private Utils() {
// }
//
// /**
// * Returns Gitignore plugin information.
// *
// * @return {@link IdeaPluginDescriptor}
// */
// public static IdeaPluginDescriptor getPlugin() {
// return PluginManager.getPlugin(PluginId.getId(LatexBundle.PLUGIN_ID));
// }
//
// /**
// * Returns plugin major version.
// *
// * @return major version
// */
// public static String getMajorVersion() {
// return getVersion().split("\\.")[0];
// }
//
// /**
// * Returns plugin minor version.
// *
// * @return minor version
// */
// public static String getMinorVersion() {
// return StringUtil.join(getVersion().split("\\."), 0, 2, ".");
// }
//
// /**
// * Returns plugin version.
// *
// * @return version
// */
// public static String getVersion() {
// return getPlugin().getVersion();
// }
// }
| import org.jetbrains.annotations.NotNull;
import com.intellij.notification.*;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.project.Project;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.util.Utils; | /*
* The MIT License (MIT)
*
* Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex;
/**
* {@link ProjectComponent} instance to display plugin's update information.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3.0
*/
public class LatexUpdateComponent extends AbstractProjectComponent {
/** {@link LatexApplicationComponent} instance. */
private LatexApplicationComponent application;
/** Constructor. */
protected LatexUpdateComponent(Project project) {
super(project);
}
/** Component initialization method. */
@Override
public void initComponent() {
application = LatexApplicationComponent.getInstance();
}
/** Component dispose method. */
@Override
public void disposeComponent() {
}
/**
* Returns component's name.
*
* @return component's name
*/
@NotNull
@Override
public String getComponentName() {
return "LatexUpdateComponent";
}
/** Method called when project is opened. */
@Override
public void projectOpened() {
if (application.isUpdated() && !application.isUpdateNotificationShown()) {
application.setUpdateNotificationShown(true);
NotificationGroup group = new NotificationGroup(LatexLanguage.GROUP, NotificationDisplayType.TOOL_WINDOW, true);
Notification notification = group.createNotification( | // Path: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
// public class LatexLanguage extends Language {
//
// /** The {@link LatexLanguage} instance. */
// public static final LatexLanguage INSTANCE = new LatexLanguage();
//
// /** The LaTeX language name. */
// @NonNls
// public static final String NAME = "LaTeX";
//
// /** The LaTeX file extension suffix. */
// @NonNls
// public static final String EXTENSION = "tex";
//
// /** LaTeX languages group name. */
// @NonNls
// public static final String GROUP = "LATEX_GROUP";
//
// /** {@link LatexLanguage} is a non-instantiable static class. */
// private LatexLanguage() {
// super(NAME);
// }
//
// }
//
// Path: src/mobi/hsz/idea/latex/util/Utils.java
// public class Utils {
// /** Private constructor to prevent creating {@link Utils} instance. */
// private Utils() {
// }
//
// /**
// * Returns Gitignore plugin information.
// *
// * @return {@link IdeaPluginDescriptor}
// */
// public static IdeaPluginDescriptor getPlugin() {
// return PluginManager.getPlugin(PluginId.getId(LatexBundle.PLUGIN_ID));
// }
//
// /**
// * Returns plugin major version.
// *
// * @return major version
// */
// public static String getMajorVersion() {
// return getVersion().split("\\.")[0];
// }
//
// /**
// * Returns plugin minor version.
// *
// * @return minor version
// */
// public static String getMinorVersion() {
// return StringUtil.join(getVersion().split("\\."), 0, 2, ".");
// }
//
// /**
// * Returns plugin version.
// *
// * @return version
// */
// public static String getVersion() {
// return getPlugin().getVersion();
// }
// }
// Path: src/mobi/hsz/idea/latex/LatexUpdateComponent.java
import org.jetbrains.annotations.NotNull;
import com.intellij.notification.*;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.project.Project;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.util.Utils;
/*
* The MIT License (MIT)
*
* Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex;
/**
* {@link ProjectComponent} instance to display plugin's update information.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3.0
*/
public class LatexUpdateComponent extends AbstractProjectComponent {
/** {@link LatexApplicationComponent} instance. */
private LatexApplicationComponent application;
/** Constructor. */
protected LatexUpdateComponent(Project project) {
super(project);
}
/** Component initialization method. */
@Override
public void initComponent() {
application = LatexApplicationComponent.getInstance();
}
/** Component dispose method. */
@Override
public void disposeComponent() {
}
/**
* Returns component's name.
*
* @return component's name
*/
@NotNull
@Override
public String getComponentName() {
return "LatexUpdateComponent";
}
/** Method called when project is opened. */
@Override
public void projectOpened() {
if (application.isUpdated() && !application.isUpdateNotificationShown()) {
application.setUpdateNotificationShown(true);
NotificationGroup group = new NotificationGroup(LatexLanguage.GROUP, NotificationDisplayType.TOOL_WINDOW, true);
Notification notification = group.createNotification( | LatexBundle.message("update.title", Utils.getVersion()), |
GoBelieveIO/voip_android | voip/src/main/java/com/beetle/voip/VOIPVideoActivity.java | // Path: imsdk/src/main/java/com/beetle/im/Timer.java
// public abstract class Timer {
// private static final int WHAT = 0;
//
// private long start;
// private long interval;
// private boolean active = false;
//
// class TimerHandler extends Handler {
// @Override
// public void handleMessage(Message msg) {
// if (!active) {
// return;
// }
//
// Timer.this.fire();
// if (Timer.this.interval != -1) {
// long t = uptimeMillis() + Timer.this.interval;
// boolean b = this.sendEmptyMessageAtTime(WHAT, t);
// }
// }
// }
// private Handler handler = new TimerHandler();
//
// public void setTimer(long start, long interval) {
// this.start = start;
// this.interval = interval;
// if (active) {
// handler.removeMessages(WHAT);
// handler.sendEmptyMessageAtTime(WHAT, start);
// }
// }
//
// public void setTimer(long start) {
// this.start = start;
// this.interval = -1;
// if (active) {
// handler.removeMessages(WHAT);
// handler.sendEmptyMessageAtTime(WHAT, start);
// }
// }
//
// public void resume() {
// active = true;
// handler.sendEmptyMessageAtTime(WHAT, start);
// }
//
// public void suspend() {
// active = false;
// handler.removeMessages(WHAT);
// }
//
// protected abstract void fire();
// }
| import android.Manifest;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import com.beetle.im.Timer;
import com.squareup.picasso.Picasso;
import org.webrtc.EglBase;
import org.webrtc.RendererCommon;
import org.webrtc.SurfaceViewRenderer;
import java.util.UUID;
import static android.os.SystemClock.uptimeMillis; | package com.beetle.voip;
/**
* Created by houxh on 15/9/8.
*/
public class VOIPVideoActivity extends CallActivity {
private static final int PERMISSIONS_REQUEST_CAMERA = 1;
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 2;
private static final int PERMISSIONS_REQUEST_MEDIA = 3;
// Local preview screen position before call is connected.
private static final int LOCAL_X_CONNECTING = 0;
private static final int LOCAL_Y_CONNECTING = 0;
private static final int LOCAL_WIDTH_CONNECTING = 100;
private static final int LOCAL_HEIGHT_CONNECTING = 100;
// Local preview screen position after call is connected.
private static final int LOCAL_X_CONNECTED = 72;
private static final int LOCAL_Y_CONNECTED = 72;
private static final int LOCAL_WIDTH_CONNECTED = 25;
private static final int LOCAL_HEIGHT_CONNECTED = 25;
// Remote video screen position
private static final int REMOTE_X = 0;
private static final int REMOTE_Y = 0;
private static final int REMOTE_WIDTH = 100;
private static final int REMOTE_HEIGHT = 100;
protected String peerName;
protected String peerAvatar;
protected int duration; | // Path: imsdk/src/main/java/com/beetle/im/Timer.java
// public abstract class Timer {
// private static final int WHAT = 0;
//
// private long start;
// private long interval;
// private boolean active = false;
//
// class TimerHandler extends Handler {
// @Override
// public void handleMessage(Message msg) {
// if (!active) {
// return;
// }
//
// Timer.this.fire();
// if (Timer.this.interval != -1) {
// long t = uptimeMillis() + Timer.this.interval;
// boolean b = this.sendEmptyMessageAtTime(WHAT, t);
// }
// }
// }
// private Handler handler = new TimerHandler();
//
// public void setTimer(long start, long interval) {
// this.start = start;
// this.interval = interval;
// if (active) {
// handler.removeMessages(WHAT);
// handler.sendEmptyMessageAtTime(WHAT, start);
// }
// }
//
// public void setTimer(long start) {
// this.start = start;
// this.interval = -1;
// if (active) {
// handler.removeMessages(WHAT);
// handler.sendEmptyMessageAtTime(WHAT, start);
// }
// }
//
// public void resume() {
// active = true;
// handler.sendEmptyMessageAtTime(WHAT, start);
// }
//
// public void suspend() {
// active = false;
// handler.removeMessages(WHAT);
// }
//
// protected abstract void fire();
// }
// Path: voip/src/main/java/com/beetle/voip/VOIPVideoActivity.java
import android.Manifest;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import com.beetle.im.Timer;
import com.squareup.picasso.Picasso;
import org.webrtc.EglBase;
import org.webrtc.RendererCommon;
import org.webrtc.SurfaceViewRenderer;
import java.util.UUID;
import static android.os.SystemClock.uptimeMillis;
package com.beetle.voip;
/**
* Created by houxh on 15/9/8.
*/
public class VOIPVideoActivity extends CallActivity {
private static final int PERMISSIONS_REQUEST_CAMERA = 1;
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 2;
private static final int PERMISSIONS_REQUEST_MEDIA = 3;
// Local preview screen position before call is connected.
private static final int LOCAL_X_CONNECTING = 0;
private static final int LOCAL_Y_CONNECTING = 0;
private static final int LOCAL_WIDTH_CONNECTING = 100;
private static final int LOCAL_HEIGHT_CONNECTING = 100;
// Local preview screen position after call is connected.
private static final int LOCAL_X_CONNECTED = 72;
private static final int LOCAL_Y_CONNECTED = 72;
private static final int LOCAL_WIDTH_CONNECTED = 25;
private static final int LOCAL_HEIGHT_CONNECTED = 25;
// Remote video screen position
private static final int REMOTE_X = 0;
private static final int REMOTE_Y = 0;
private static final int REMOTE_WIDTH = 100;
private static final int REMOTE_HEIGHT = 100;
protected String peerName;
protected String peerAvatar;
protected int duration; | protected Timer durationTimer; |
GoBelieveIO/voip_android | imsdk/src/main/java/com/beetle/im/IMService.java | // Path: asynctcp/src/main/java/com/beetle/AsyncTCP.java
// public class AsyncTCP {
// private int sock;
// private int events;
//
// private byte[] data;
// private boolean connecting;
//
// private TCPConnectCallback connectCallback;
// private TCPReadCallback readCallback;
// private long self;
//
//
// public void setConnectCallback(TCPConnectCallback cb) {
// connectCallback = cb;
// }
// public void setReadCallback(TCPReadCallback cb) {
// readCallback = cb;
// }
// public native boolean connect(String host, int port);
// public native void close();
//
// public native void writeData(byte[] bytes);
//
// public native void startRead();
//
//
// static {
// System.loadLibrary("async_tcp");
// }
// }
//
// Path: asynctcp/src/main/java/com/beetle/TCPConnectCallback.java
// public interface TCPConnectCallback {
//
// public void onConnect(Object tcp, int status);
//
// }
//
// Path: asynctcp/src/main/java/com/beetle/TCPReadCallback.java
// public interface TCPReadCallback {
//
// public void onRead(Object tcp, byte[] data);
//
// }
| import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.util.Log;
import com.beetle.AsyncTCP;
import com.beetle.TCPConnectCallback;
import com.beetle.TCPReadCallback;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import static android.os.SystemClock.uptimeMillis; | package com.beetle.im;
/**
* Created by houxh on 14-7-21.
*/
public class IMService {
private final String HOST = "imnode2.gobelieve.io";
private final int PORT = 23000;
public enum ConnectState {
STATE_UNCONNECTED,
STATE_CONNECTING,
STATE_CONNECTED,
STATE_CONNECTFAIL,
}
private final String TAG = "imservice";
private final int HEARTBEAT = 60*3; | // Path: asynctcp/src/main/java/com/beetle/AsyncTCP.java
// public class AsyncTCP {
// private int sock;
// private int events;
//
// private byte[] data;
// private boolean connecting;
//
// private TCPConnectCallback connectCallback;
// private TCPReadCallback readCallback;
// private long self;
//
//
// public void setConnectCallback(TCPConnectCallback cb) {
// connectCallback = cb;
// }
// public void setReadCallback(TCPReadCallback cb) {
// readCallback = cb;
// }
// public native boolean connect(String host, int port);
// public native void close();
//
// public native void writeData(byte[] bytes);
//
// public native void startRead();
//
//
// static {
// System.loadLibrary("async_tcp");
// }
// }
//
// Path: asynctcp/src/main/java/com/beetle/TCPConnectCallback.java
// public interface TCPConnectCallback {
//
// public void onConnect(Object tcp, int status);
//
// }
//
// Path: asynctcp/src/main/java/com/beetle/TCPReadCallback.java
// public interface TCPReadCallback {
//
// public void onRead(Object tcp, byte[] data);
//
// }
// Path: imsdk/src/main/java/com/beetle/im/IMService.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.util.Log;
import com.beetle.AsyncTCP;
import com.beetle.TCPConnectCallback;
import com.beetle.TCPReadCallback;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import static android.os.SystemClock.uptimeMillis;
package com.beetle.im;
/**
* Created by houxh on 14-7-21.
*/
public class IMService {
private final String HOST = "imnode2.gobelieve.io";
private final int PORT = 23000;
public enum ConnectState {
STATE_UNCONNECTED,
STATE_CONNECTING,
STATE_CONNECTED,
STATE_CONNECTFAIL,
}
private final String TAG = "imservice";
private final int HEARTBEAT = 60*3; | private AsyncTCP tcp; |
GoBelieveIO/voip_android | imsdk/src/main/java/com/beetle/im/IMService.java | // Path: asynctcp/src/main/java/com/beetle/AsyncTCP.java
// public class AsyncTCP {
// private int sock;
// private int events;
//
// private byte[] data;
// private boolean connecting;
//
// private TCPConnectCallback connectCallback;
// private TCPReadCallback readCallback;
// private long self;
//
//
// public void setConnectCallback(TCPConnectCallback cb) {
// connectCallback = cb;
// }
// public void setReadCallback(TCPReadCallback cb) {
// readCallback = cb;
// }
// public native boolean connect(String host, int port);
// public native void close();
//
// public native void writeData(byte[] bytes);
//
// public native void startRead();
//
//
// static {
// System.loadLibrary("async_tcp");
// }
// }
//
// Path: asynctcp/src/main/java/com/beetle/TCPConnectCallback.java
// public interface TCPConnectCallback {
//
// public void onConnect(Object tcp, int status);
//
// }
//
// Path: asynctcp/src/main/java/com/beetle/TCPReadCallback.java
// public interface TCPReadCallback {
//
// public void onRead(Object tcp, byte[] data);
//
// }
| import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.util.Log;
import com.beetle.AsyncTCP;
import com.beetle.TCPConnectCallback;
import com.beetle.TCPReadCallback;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import static android.os.SystemClock.uptimeMillis; | return;
}
if (hostIP == null || hostIP.length() == 0) {
refreshHost();
IMService.this.connectFailCount++;
Log.i(TAG, "host ip is't resolved");
long t;
if (this.connectFailCount > 60) {
t = uptimeMillis() + 60*1000;
} else {
t = uptimeMillis() + this.connectFailCount*1000;
}
connectTimer.setTimer(t);
return;
}
if (now() - timestamp > 5*60) {
refreshHost();
}
this.pingTimestamp = 0;
this.connectState = ConnectState.STATE_CONNECTING;
IMService.this.publishConnectState();
this.tcp = new AsyncTCP();
Log.i(TAG, "new tcp...");
| // Path: asynctcp/src/main/java/com/beetle/AsyncTCP.java
// public class AsyncTCP {
// private int sock;
// private int events;
//
// private byte[] data;
// private boolean connecting;
//
// private TCPConnectCallback connectCallback;
// private TCPReadCallback readCallback;
// private long self;
//
//
// public void setConnectCallback(TCPConnectCallback cb) {
// connectCallback = cb;
// }
// public void setReadCallback(TCPReadCallback cb) {
// readCallback = cb;
// }
// public native boolean connect(String host, int port);
// public native void close();
//
// public native void writeData(byte[] bytes);
//
// public native void startRead();
//
//
// static {
// System.loadLibrary("async_tcp");
// }
// }
//
// Path: asynctcp/src/main/java/com/beetle/TCPConnectCallback.java
// public interface TCPConnectCallback {
//
// public void onConnect(Object tcp, int status);
//
// }
//
// Path: asynctcp/src/main/java/com/beetle/TCPReadCallback.java
// public interface TCPReadCallback {
//
// public void onRead(Object tcp, byte[] data);
//
// }
// Path: imsdk/src/main/java/com/beetle/im/IMService.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.util.Log;
import com.beetle.AsyncTCP;
import com.beetle.TCPConnectCallback;
import com.beetle.TCPReadCallback;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import static android.os.SystemClock.uptimeMillis;
return;
}
if (hostIP == null || hostIP.length() == 0) {
refreshHost();
IMService.this.connectFailCount++;
Log.i(TAG, "host ip is't resolved");
long t;
if (this.connectFailCount > 60) {
t = uptimeMillis() + 60*1000;
} else {
t = uptimeMillis() + this.connectFailCount*1000;
}
connectTimer.setTimer(t);
return;
}
if (now() - timestamp > 5*60) {
refreshHost();
}
this.pingTimestamp = 0;
this.connectState = ConnectState.STATE_CONNECTING;
IMService.this.publishConnectState();
this.tcp = new AsyncTCP();
Log.i(TAG, "new tcp...");
| this.tcp.setConnectCallback(new TCPConnectCallback() { |
GoBelieveIO/voip_android | imsdk/src/main/java/com/beetle/im/IMService.java | // Path: asynctcp/src/main/java/com/beetle/AsyncTCP.java
// public class AsyncTCP {
// private int sock;
// private int events;
//
// private byte[] data;
// private boolean connecting;
//
// private TCPConnectCallback connectCallback;
// private TCPReadCallback readCallback;
// private long self;
//
//
// public void setConnectCallback(TCPConnectCallback cb) {
// connectCallback = cb;
// }
// public void setReadCallback(TCPReadCallback cb) {
// readCallback = cb;
// }
// public native boolean connect(String host, int port);
// public native void close();
//
// public native void writeData(byte[] bytes);
//
// public native void startRead();
//
//
// static {
// System.loadLibrary("async_tcp");
// }
// }
//
// Path: asynctcp/src/main/java/com/beetle/TCPConnectCallback.java
// public interface TCPConnectCallback {
//
// public void onConnect(Object tcp, int status);
//
// }
//
// Path: asynctcp/src/main/java/com/beetle/TCPReadCallback.java
// public interface TCPReadCallback {
//
// public void onRead(Object tcp, byte[] data);
//
// }
| import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.util.Log;
import com.beetle.AsyncTCP;
import com.beetle.TCPConnectCallback;
import com.beetle.TCPReadCallback;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import static android.os.SystemClock.uptimeMillis; | connectTimer.setTimer(t);
return;
}
if (now() - timestamp > 5*60) {
refreshHost();
}
this.pingTimestamp = 0;
this.connectState = ConnectState.STATE_CONNECTING;
IMService.this.publishConnectState();
this.tcp = new AsyncTCP();
Log.i(TAG, "new tcp...");
this.tcp.setConnectCallback(new TCPConnectCallback() {
@Override
public void onConnect(Object tcp, int status) {
if (status != 0) {
Log.i(TAG, "connect err:" + status);
IMService.this.connectFailCount++;
IMService.this.connectState = ConnectState.STATE_CONNECTFAIL;
IMService.this.publishConnectState();
IMService.this.close();
IMService.this.startConnectTimer();
} else {
IMService.this.onConnected();
}
}
});
| // Path: asynctcp/src/main/java/com/beetle/AsyncTCP.java
// public class AsyncTCP {
// private int sock;
// private int events;
//
// private byte[] data;
// private boolean connecting;
//
// private TCPConnectCallback connectCallback;
// private TCPReadCallback readCallback;
// private long self;
//
//
// public void setConnectCallback(TCPConnectCallback cb) {
// connectCallback = cb;
// }
// public void setReadCallback(TCPReadCallback cb) {
// readCallback = cb;
// }
// public native boolean connect(String host, int port);
// public native void close();
//
// public native void writeData(byte[] bytes);
//
// public native void startRead();
//
//
// static {
// System.loadLibrary("async_tcp");
// }
// }
//
// Path: asynctcp/src/main/java/com/beetle/TCPConnectCallback.java
// public interface TCPConnectCallback {
//
// public void onConnect(Object tcp, int status);
//
// }
//
// Path: asynctcp/src/main/java/com/beetle/TCPReadCallback.java
// public interface TCPReadCallback {
//
// public void onRead(Object tcp, byte[] data);
//
// }
// Path: imsdk/src/main/java/com/beetle/im/IMService.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.util.Log;
import com.beetle.AsyncTCP;
import com.beetle.TCPConnectCallback;
import com.beetle.TCPReadCallback;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import static android.os.SystemClock.uptimeMillis;
connectTimer.setTimer(t);
return;
}
if (now() - timestamp > 5*60) {
refreshHost();
}
this.pingTimestamp = 0;
this.connectState = ConnectState.STATE_CONNECTING;
IMService.this.publishConnectState();
this.tcp = new AsyncTCP();
Log.i(TAG, "new tcp...");
this.tcp.setConnectCallback(new TCPConnectCallback() {
@Override
public void onConnect(Object tcp, int status) {
if (status != 0) {
Log.i(TAG, "connect err:" + status);
IMService.this.connectFailCount++;
IMService.this.connectState = ConnectState.STATE_CONNECTFAIL;
IMService.this.publishConnectState();
IMService.this.close();
IMService.this.startConnectTimer();
} else {
IMService.this.onConnected();
}
}
});
| this.tcp.setReadCallback(new TCPReadCallback() { |
GoBelieveIO/voip_android | voip/src/main/java/com/beetle/voip/VOIPVoiceActivity.java | // Path: imsdk/src/main/java/com/beetle/im/Timer.java
// public abstract class Timer {
// private static final int WHAT = 0;
//
// private long start;
// private long interval;
// private boolean active = false;
//
// class TimerHandler extends Handler {
// @Override
// public void handleMessage(Message msg) {
// if (!active) {
// return;
// }
//
// Timer.this.fire();
// if (Timer.this.interval != -1) {
// long t = uptimeMillis() + Timer.this.interval;
// boolean b = this.sendEmptyMessageAtTime(WHAT, t);
// }
// }
// }
// private Handler handler = new TimerHandler();
//
// public void setTimer(long start, long interval) {
// this.start = start;
// this.interval = interval;
// if (active) {
// handler.removeMessages(WHAT);
// handler.sendEmptyMessageAtTime(WHAT, start);
// }
// }
//
// public void setTimer(long start) {
// this.start = start;
// this.interval = -1;
// if (active) {
// handler.removeMessages(WHAT);
// handler.sendEmptyMessageAtTime(WHAT, start);
// }
// }
//
// public void resume() {
// active = true;
// handler.sendEmptyMessageAtTime(WHAT, start);
// }
//
// public void suspend() {
// active = false;
// handler.removeMessages(WHAT);
// }
//
// protected abstract void fire();
// }
| import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import com.beetle.im.Timer;
import com.squareup.picasso.Picasso;
import org.webrtc.EglBase;
import java.util.UUID;
import static android.os.SystemClock.uptimeMillis; | package com.beetle.voip;
/**
* Created by houxh on 15/9/8.
*/
public class VOIPVoiceActivity extends CallActivity {
private static final int PERMISSIONS_REQUEST_CAMERA = 1;
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 2;
protected ImageView headView;
protected Button handUpButton;
protected ImageButton refuseButton;
protected ImageButton acceptButton;
protected TextView durationTextView;
protected int duration; | // Path: imsdk/src/main/java/com/beetle/im/Timer.java
// public abstract class Timer {
// private static final int WHAT = 0;
//
// private long start;
// private long interval;
// private boolean active = false;
//
// class TimerHandler extends Handler {
// @Override
// public void handleMessage(Message msg) {
// if (!active) {
// return;
// }
//
// Timer.this.fire();
// if (Timer.this.interval != -1) {
// long t = uptimeMillis() + Timer.this.interval;
// boolean b = this.sendEmptyMessageAtTime(WHAT, t);
// }
// }
// }
// private Handler handler = new TimerHandler();
//
// public void setTimer(long start, long interval) {
// this.start = start;
// this.interval = interval;
// if (active) {
// handler.removeMessages(WHAT);
// handler.sendEmptyMessageAtTime(WHAT, start);
// }
// }
//
// public void setTimer(long start) {
// this.start = start;
// this.interval = -1;
// if (active) {
// handler.removeMessages(WHAT);
// handler.sendEmptyMessageAtTime(WHAT, start);
// }
// }
//
// public void resume() {
// active = true;
// handler.sendEmptyMessageAtTime(WHAT, start);
// }
//
// public void suspend() {
// active = false;
// handler.removeMessages(WHAT);
// }
//
// protected abstract void fire();
// }
// Path: voip/src/main/java/com/beetle/voip/VOIPVoiceActivity.java
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import com.beetle.im.Timer;
import com.squareup.picasso.Picasso;
import org.webrtc.EglBase;
import java.util.UUID;
import static android.os.SystemClock.uptimeMillis;
package com.beetle.voip;
/**
* Created by houxh on 15/9/8.
*/
public class VOIPVoiceActivity extends CallActivity {
private static final int PERMISSIONS_REQUEST_CAMERA = 1;
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 2;
protected ImageView headView;
protected Button handUpButton;
protected ImageButton refuseButton;
protected ImageButton acceptButton;
protected TextView durationTextView;
protected int duration; | protected Timer durationTimer; |
fusesource/jansi | src/main/java/org/fusesource/jansi/WindowsSupport.java | // Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static int FORMAT_MESSAGE_FROM_SYSTEM;
//
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static native int FormatMessageW(
// int flags,
// long source,
// int messageId,
// int languageId,
// byte[] buffer,
// int size,
// long[] args
// );
//
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static native int GetLastError();
| import java.io.UnsupportedEncodingException;
import static org.fusesource.jansi.internal.Kernel32.FORMAT_MESSAGE_FROM_SYSTEM;
import static org.fusesource.jansi.internal.Kernel32.FormatMessageW;
import static org.fusesource.jansi.internal.Kernel32.GetLastError; | /*
* Copyright (C) 2009-2019 the original author(s).
*
* 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.fusesource.jansi;
public class WindowsSupport {
public static String getLastErrorMessage() { | // Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static int FORMAT_MESSAGE_FROM_SYSTEM;
//
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static native int FormatMessageW(
// int flags,
// long source,
// int messageId,
// int languageId,
// byte[] buffer,
// int size,
// long[] args
// );
//
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static native int GetLastError();
// Path: src/main/java/org/fusesource/jansi/WindowsSupport.java
import java.io.UnsupportedEncodingException;
import static org.fusesource.jansi.internal.Kernel32.FORMAT_MESSAGE_FROM_SYSTEM;
import static org.fusesource.jansi.internal.Kernel32.FormatMessageW;
import static org.fusesource.jansi.internal.Kernel32.GetLastError;
/*
* Copyright (C) 2009-2019 the original author(s).
*
* 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.fusesource.jansi;
public class WindowsSupport {
public static String getLastErrorMessage() { | int errorCode = GetLastError(); |
fusesource/jansi | src/main/java/org/fusesource/jansi/WindowsSupport.java | // Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static int FORMAT_MESSAGE_FROM_SYSTEM;
//
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static native int FormatMessageW(
// int flags,
// long source,
// int messageId,
// int languageId,
// byte[] buffer,
// int size,
// long[] args
// );
//
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static native int GetLastError();
| import java.io.UnsupportedEncodingException;
import static org.fusesource.jansi.internal.Kernel32.FORMAT_MESSAGE_FROM_SYSTEM;
import static org.fusesource.jansi.internal.Kernel32.FormatMessageW;
import static org.fusesource.jansi.internal.Kernel32.GetLastError; | /*
* Copyright (C) 2009-2019 the original author(s).
*
* 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.fusesource.jansi;
public class WindowsSupport {
public static String getLastErrorMessage() {
int errorCode = GetLastError();
return getErrorMessage(errorCode);
}
public static String getErrorMessage(int errorCode) {
int bufferSize = 160;
byte data[] = new byte[bufferSize]; | // Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static int FORMAT_MESSAGE_FROM_SYSTEM;
//
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static native int FormatMessageW(
// int flags,
// long source,
// int messageId,
// int languageId,
// byte[] buffer,
// int size,
// long[] args
// );
//
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static native int GetLastError();
// Path: src/main/java/org/fusesource/jansi/WindowsSupport.java
import java.io.UnsupportedEncodingException;
import static org.fusesource.jansi.internal.Kernel32.FORMAT_MESSAGE_FROM_SYSTEM;
import static org.fusesource.jansi.internal.Kernel32.FormatMessageW;
import static org.fusesource.jansi.internal.Kernel32.GetLastError;
/*
* Copyright (C) 2009-2019 the original author(s).
*
* 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.fusesource.jansi;
public class WindowsSupport {
public static String getLastErrorMessage() {
int errorCode = GetLastError();
return getErrorMessage(errorCode);
}
public static String getErrorMessage(int errorCode) {
int bufferSize = 160;
byte data[] = new byte[bufferSize]; | FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, 0, errorCode, 0, data, bufferSize, null); |
fusesource/jansi | src/main/java/org/fusesource/jansi/WindowsSupport.java | // Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static int FORMAT_MESSAGE_FROM_SYSTEM;
//
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static native int FormatMessageW(
// int flags,
// long source,
// int messageId,
// int languageId,
// byte[] buffer,
// int size,
// long[] args
// );
//
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static native int GetLastError();
| import java.io.UnsupportedEncodingException;
import static org.fusesource.jansi.internal.Kernel32.FORMAT_MESSAGE_FROM_SYSTEM;
import static org.fusesource.jansi.internal.Kernel32.FormatMessageW;
import static org.fusesource.jansi.internal.Kernel32.GetLastError; | /*
* Copyright (C) 2009-2019 the original author(s).
*
* 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.fusesource.jansi;
public class WindowsSupport {
public static String getLastErrorMessage() {
int errorCode = GetLastError();
return getErrorMessage(errorCode);
}
public static String getErrorMessage(int errorCode) {
int bufferSize = 160;
byte data[] = new byte[bufferSize]; | // Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static int FORMAT_MESSAGE_FROM_SYSTEM;
//
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static native int FormatMessageW(
// int flags,
// long source,
// int messageId,
// int languageId,
// byte[] buffer,
// int size,
// long[] args
// );
//
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
// public static native int GetLastError();
// Path: src/main/java/org/fusesource/jansi/WindowsSupport.java
import java.io.UnsupportedEncodingException;
import static org.fusesource.jansi.internal.Kernel32.FORMAT_MESSAGE_FROM_SYSTEM;
import static org.fusesource.jansi.internal.Kernel32.FormatMessageW;
import static org.fusesource.jansi.internal.Kernel32.GetLastError;
/*
* Copyright (C) 2009-2019 the original author(s).
*
* 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.fusesource.jansi;
public class WindowsSupport {
public static String getLastErrorMessage() {
int errorCode = GetLastError();
return getErrorMessage(errorCode);
}
public static String getErrorMessage(int errorCode) {
int bufferSize = 160;
byte data[] = new byte[bufferSize]; | FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, 0, errorCode, 0, data, bufferSize, null); |
fusesource/jansi | src/main/java/org/fusesource/jansi/internal/Kernel32.java | // Path: src/main/java/org/fusesource/jansi/WindowsSupport.java
// public class WindowsSupport {
//
// public static String getLastErrorMessage() {
// int errorCode = GetLastError();
// return getErrorMessage(errorCode);
// }
//
// public static String getErrorMessage(int errorCode) {
// int bufferSize = 160;
// byte data[] = new byte[bufferSize];
// FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, 0, errorCode, 0, data, bufferSize, null);
// try {
// return new String(data, "UTF-16LE").trim();
// } catch (UnsupportedEncodingException e) {
// throw new IllegalStateException(e);
// }
// }
//
// }
| import java.io.IOException;
import org.fusesource.jansi.WindowsSupport; | /**
* see: http://msdn.microsoft.com/en-us/library/ms683207(v=VS.85).aspx
*/
public static native int GetNumberOfConsoleInputEvents(
long handle,
int[] numberOfEvents);
/**
* see: http://msdn.microsoft.com/en-us/library/ms683147(v=VS.85).aspx
*/
public static native int FlushConsoleInputBuffer(
long handle);
/**
* Return console input events.
*/
public static INPUT_RECORD[] readConsoleInputHelper(
long handle, int count, boolean peek) throws IOException {
int[] length = new int[1];
int res;
long inputRecordPtr = 0;
try {
inputRecordPtr = malloc(INPUT_RECORD.SIZEOF * count);
if (inputRecordPtr == 0) {
throw new IOException("cannot allocate memory with JNI");
}
res = peek ?
PeekConsoleInputW(handle, inputRecordPtr, count, length)
: ReadConsoleInputW(handle, inputRecordPtr, count, length);
if (res == 0) { | // Path: src/main/java/org/fusesource/jansi/WindowsSupport.java
// public class WindowsSupport {
//
// public static String getLastErrorMessage() {
// int errorCode = GetLastError();
// return getErrorMessage(errorCode);
// }
//
// public static String getErrorMessage(int errorCode) {
// int bufferSize = 160;
// byte data[] = new byte[bufferSize];
// FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, 0, errorCode, 0, data, bufferSize, null);
// try {
// return new String(data, "UTF-16LE").trim();
// } catch (UnsupportedEncodingException e) {
// throw new IllegalStateException(e);
// }
// }
//
// }
// Path: src/main/java/org/fusesource/jansi/internal/Kernel32.java
import java.io.IOException;
import org.fusesource.jansi.WindowsSupport;
/**
* see: http://msdn.microsoft.com/en-us/library/ms683207(v=VS.85).aspx
*/
public static native int GetNumberOfConsoleInputEvents(
long handle,
int[] numberOfEvents);
/**
* see: http://msdn.microsoft.com/en-us/library/ms683147(v=VS.85).aspx
*/
public static native int FlushConsoleInputBuffer(
long handle);
/**
* Return console input events.
*/
public static INPUT_RECORD[] readConsoleInputHelper(
long handle, int count, boolean peek) throws IOException {
int[] length = new int[1];
int res;
long inputRecordPtr = 0;
try {
inputRecordPtr = malloc(INPUT_RECORD.SIZEOF * count);
if (inputRecordPtr == 0) {
throw new IOException("cannot allocate memory with JNI");
}
res = peek ?
PeekConsoleInputW(handle, inputRecordPtr, count, length)
: ReadConsoleInputW(handle, inputRecordPtr, count, length);
if (res == 0) { | throw new IOException("ReadConsoleInputW failed: " + WindowsSupport.getLastErrorMessage()); |
fusesource/jansi | src/main/java/org/fusesource/jansi/AnsiRenderer.java | // Path: src/main/java/org/fusesource/jansi/Ansi.java
// public enum Attribute {
// RESET(0, "RESET"),
// INTENSITY_BOLD(1, "INTENSITY_BOLD"),
// INTENSITY_FAINT(2, "INTENSITY_FAINT"),
// ITALIC(3, "ITALIC_ON"),
// UNDERLINE(4, "UNDERLINE_ON"),
// BLINK_SLOW(5, "BLINK_SLOW"),
// BLINK_FAST(6, "BLINK_FAST"),
// NEGATIVE_ON(7, "NEGATIVE_ON"),
// CONCEAL_ON(8, "CONCEAL_ON"),
// STRIKETHROUGH_ON(9, "STRIKETHROUGH_ON"),
// UNDERLINE_DOUBLE(21, "UNDERLINE_DOUBLE"),
// INTENSITY_BOLD_OFF(22, "INTENSITY_BOLD_OFF"),
// ITALIC_OFF(23, "ITALIC_OFF"),
// UNDERLINE_OFF(24, "UNDERLINE_OFF"),
// BLINK_OFF(25, "BLINK_OFF"),
// NEGATIVE_OFF(27, "NEGATIVE_OFF"),
// CONCEAL_OFF(28, "CONCEAL_OFF"),
// STRIKETHROUGH_OFF(29, "STRIKETHROUGH_OFF");
//
// private final int value;
// private final String name;
//
// Attribute(int index, String name) {
// this.value = index;
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// public int value() {
// return value;
// }
//
// }
//
// Path: src/main/java/org/fusesource/jansi/Ansi.java
// public enum Color {
// BLACK(0, "BLACK"),
// RED(1, "RED"),
// GREEN(2, "GREEN"),
// YELLOW(3, "YELLOW"),
// BLUE(4, "BLUE"),
// MAGENTA(5, "MAGENTA"),
// CYAN(6, "CYAN"),
// WHITE(7, "WHITE"),
// DEFAULT(9, "DEFAULT");
//
// private final int value;
// private final String name;
//
// Color(int index, String name) {
// this.value = index;
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// public int value() {
// return value;
// }
//
// public int fg() {
// return value + 30;
// }
//
// public int bg() {
// return value + 40;
// }
//
// public int fgBright() {
// return value + 90;
// }
//
// public int bgBright() {
// return value + 100;
// }
// }
| import java.io.IOException;
import java.util.Locale;
import org.fusesource.jansi.Ansi.Attribute;
import org.fusesource.jansi.Ansi.Color; | return renderCodes(codes.split("\\s"));
}
private static Ansi render(Ansi ansi, String... names) {
for (String name : names) {
Code code = Code.valueOf(name.toUpperCase(Locale.ENGLISH));
if (code.isColor()) {
if (code.isBackground()) {
ansi.bg(code.getColor());
} else {
ansi.fg(code.getColor());
}
} else if (code.isAttribute()) {
ansi.a(code.getAttribute());
}
}
return ansi;
}
public static boolean test(final String text) {
return text != null && text.contains(BEGIN_TOKEN);
}
@SuppressWarnings("unused")
public enum Code {
//
// TODO: Find a better way to keep Code in sync with Color/Attribute/Erase
//
// Colors | // Path: src/main/java/org/fusesource/jansi/Ansi.java
// public enum Attribute {
// RESET(0, "RESET"),
// INTENSITY_BOLD(1, "INTENSITY_BOLD"),
// INTENSITY_FAINT(2, "INTENSITY_FAINT"),
// ITALIC(3, "ITALIC_ON"),
// UNDERLINE(4, "UNDERLINE_ON"),
// BLINK_SLOW(5, "BLINK_SLOW"),
// BLINK_FAST(6, "BLINK_FAST"),
// NEGATIVE_ON(7, "NEGATIVE_ON"),
// CONCEAL_ON(8, "CONCEAL_ON"),
// STRIKETHROUGH_ON(9, "STRIKETHROUGH_ON"),
// UNDERLINE_DOUBLE(21, "UNDERLINE_DOUBLE"),
// INTENSITY_BOLD_OFF(22, "INTENSITY_BOLD_OFF"),
// ITALIC_OFF(23, "ITALIC_OFF"),
// UNDERLINE_OFF(24, "UNDERLINE_OFF"),
// BLINK_OFF(25, "BLINK_OFF"),
// NEGATIVE_OFF(27, "NEGATIVE_OFF"),
// CONCEAL_OFF(28, "CONCEAL_OFF"),
// STRIKETHROUGH_OFF(29, "STRIKETHROUGH_OFF");
//
// private final int value;
// private final String name;
//
// Attribute(int index, String name) {
// this.value = index;
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// public int value() {
// return value;
// }
//
// }
//
// Path: src/main/java/org/fusesource/jansi/Ansi.java
// public enum Color {
// BLACK(0, "BLACK"),
// RED(1, "RED"),
// GREEN(2, "GREEN"),
// YELLOW(3, "YELLOW"),
// BLUE(4, "BLUE"),
// MAGENTA(5, "MAGENTA"),
// CYAN(6, "CYAN"),
// WHITE(7, "WHITE"),
// DEFAULT(9, "DEFAULT");
//
// private final int value;
// private final String name;
//
// Color(int index, String name) {
// this.value = index;
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// public int value() {
// return value;
// }
//
// public int fg() {
// return value + 30;
// }
//
// public int bg() {
// return value + 40;
// }
//
// public int fgBright() {
// return value + 90;
// }
//
// public int bgBright() {
// return value + 100;
// }
// }
// Path: src/main/java/org/fusesource/jansi/AnsiRenderer.java
import java.io.IOException;
import java.util.Locale;
import org.fusesource.jansi.Ansi.Attribute;
import org.fusesource.jansi.Ansi.Color;
return renderCodes(codes.split("\\s"));
}
private static Ansi render(Ansi ansi, String... names) {
for (String name : names) {
Code code = Code.valueOf(name.toUpperCase(Locale.ENGLISH));
if (code.isColor()) {
if (code.isBackground()) {
ansi.bg(code.getColor());
} else {
ansi.fg(code.getColor());
}
} else if (code.isAttribute()) {
ansi.a(code.getAttribute());
}
}
return ansi;
}
public static boolean test(final String text) {
return text != null && text.contains(BEGIN_TOKEN);
}
@SuppressWarnings("unused")
public enum Code {
//
// TODO: Find a better way to keep Code in sync with Color/Attribute/Erase
//
// Colors | BLACK(Color.BLACK), |
fusesource/jansi | src/main/java/org/fusesource/jansi/AnsiRenderer.java | // Path: src/main/java/org/fusesource/jansi/Ansi.java
// public enum Attribute {
// RESET(0, "RESET"),
// INTENSITY_BOLD(1, "INTENSITY_BOLD"),
// INTENSITY_FAINT(2, "INTENSITY_FAINT"),
// ITALIC(3, "ITALIC_ON"),
// UNDERLINE(4, "UNDERLINE_ON"),
// BLINK_SLOW(5, "BLINK_SLOW"),
// BLINK_FAST(6, "BLINK_FAST"),
// NEGATIVE_ON(7, "NEGATIVE_ON"),
// CONCEAL_ON(8, "CONCEAL_ON"),
// STRIKETHROUGH_ON(9, "STRIKETHROUGH_ON"),
// UNDERLINE_DOUBLE(21, "UNDERLINE_DOUBLE"),
// INTENSITY_BOLD_OFF(22, "INTENSITY_BOLD_OFF"),
// ITALIC_OFF(23, "ITALIC_OFF"),
// UNDERLINE_OFF(24, "UNDERLINE_OFF"),
// BLINK_OFF(25, "BLINK_OFF"),
// NEGATIVE_OFF(27, "NEGATIVE_OFF"),
// CONCEAL_OFF(28, "CONCEAL_OFF"),
// STRIKETHROUGH_OFF(29, "STRIKETHROUGH_OFF");
//
// private final int value;
// private final String name;
//
// Attribute(int index, String name) {
// this.value = index;
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// public int value() {
// return value;
// }
//
// }
//
// Path: src/main/java/org/fusesource/jansi/Ansi.java
// public enum Color {
// BLACK(0, "BLACK"),
// RED(1, "RED"),
// GREEN(2, "GREEN"),
// YELLOW(3, "YELLOW"),
// BLUE(4, "BLUE"),
// MAGENTA(5, "MAGENTA"),
// CYAN(6, "CYAN"),
// WHITE(7, "WHITE"),
// DEFAULT(9, "DEFAULT");
//
// private final int value;
// private final String name;
//
// Color(int index, String name) {
// this.value = index;
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// public int value() {
// return value;
// }
//
// public int fg() {
// return value + 30;
// }
//
// public int bg() {
// return value + 40;
// }
//
// public int fgBright() {
// return value + 90;
// }
//
// public int bgBright() {
// return value + 100;
// }
// }
| import java.io.IOException;
import java.util.Locale;
import org.fusesource.jansi.Ansi.Attribute;
import org.fusesource.jansi.Ansi.Color; | YELLOW(Color.YELLOW),
BLUE(Color.BLUE),
MAGENTA(Color.MAGENTA),
CYAN(Color.CYAN),
WHITE(Color.WHITE),
DEFAULT(Color.DEFAULT),
// Foreground Colors
FG_BLACK(Color.BLACK, false),
FG_RED(Color.RED, false),
FG_GREEN(Color.GREEN, false),
FG_YELLOW(Color.YELLOW, false),
FG_BLUE(Color.BLUE, false),
FG_MAGENTA(Color.MAGENTA, false),
FG_CYAN(Color.CYAN, false),
FG_WHITE(Color.WHITE, false),
FG_DEFAULT(Color.DEFAULT, false),
// Background Colors
BG_BLACK(Color.BLACK, true),
BG_RED(Color.RED, true),
BG_GREEN(Color.GREEN, true),
BG_YELLOW(Color.YELLOW, true),
BG_BLUE(Color.BLUE, true),
BG_MAGENTA(Color.MAGENTA, true),
BG_CYAN(Color.CYAN, true),
BG_WHITE(Color.WHITE, true),
BG_DEFAULT(Color.DEFAULT, true),
// Attributes | // Path: src/main/java/org/fusesource/jansi/Ansi.java
// public enum Attribute {
// RESET(0, "RESET"),
// INTENSITY_BOLD(1, "INTENSITY_BOLD"),
// INTENSITY_FAINT(2, "INTENSITY_FAINT"),
// ITALIC(3, "ITALIC_ON"),
// UNDERLINE(4, "UNDERLINE_ON"),
// BLINK_SLOW(5, "BLINK_SLOW"),
// BLINK_FAST(6, "BLINK_FAST"),
// NEGATIVE_ON(7, "NEGATIVE_ON"),
// CONCEAL_ON(8, "CONCEAL_ON"),
// STRIKETHROUGH_ON(9, "STRIKETHROUGH_ON"),
// UNDERLINE_DOUBLE(21, "UNDERLINE_DOUBLE"),
// INTENSITY_BOLD_OFF(22, "INTENSITY_BOLD_OFF"),
// ITALIC_OFF(23, "ITALIC_OFF"),
// UNDERLINE_OFF(24, "UNDERLINE_OFF"),
// BLINK_OFF(25, "BLINK_OFF"),
// NEGATIVE_OFF(27, "NEGATIVE_OFF"),
// CONCEAL_OFF(28, "CONCEAL_OFF"),
// STRIKETHROUGH_OFF(29, "STRIKETHROUGH_OFF");
//
// private final int value;
// private final String name;
//
// Attribute(int index, String name) {
// this.value = index;
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// public int value() {
// return value;
// }
//
// }
//
// Path: src/main/java/org/fusesource/jansi/Ansi.java
// public enum Color {
// BLACK(0, "BLACK"),
// RED(1, "RED"),
// GREEN(2, "GREEN"),
// YELLOW(3, "YELLOW"),
// BLUE(4, "BLUE"),
// MAGENTA(5, "MAGENTA"),
// CYAN(6, "CYAN"),
// WHITE(7, "WHITE"),
// DEFAULT(9, "DEFAULT");
//
// private final int value;
// private final String name;
//
// Color(int index, String name) {
// this.value = index;
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// public int value() {
// return value;
// }
//
// public int fg() {
// return value + 30;
// }
//
// public int bg() {
// return value + 40;
// }
//
// public int fgBright() {
// return value + 90;
// }
//
// public int bgBright() {
// return value + 100;
// }
// }
// Path: src/main/java/org/fusesource/jansi/AnsiRenderer.java
import java.io.IOException;
import java.util.Locale;
import org.fusesource.jansi.Ansi.Attribute;
import org.fusesource.jansi.Ansi.Color;
YELLOW(Color.YELLOW),
BLUE(Color.BLUE),
MAGENTA(Color.MAGENTA),
CYAN(Color.CYAN),
WHITE(Color.WHITE),
DEFAULT(Color.DEFAULT),
// Foreground Colors
FG_BLACK(Color.BLACK, false),
FG_RED(Color.RED, false),
FG_GREEN(Color.GREEN, false),
FG_YELLOW(Color.YELLOW, false),
FG_BLUE(Color.BLUE, false),
FG_MAGENTA(Color.MAGENTA, false),
FG_CYAN(Color.CYAN, false),
FG_WHITE(Color.WHITE, false),
FG_DEFAULT(Color.DEFAULT, false),
// Background Colors
BG_BLACK(Color.BLACK, true),
BG_RED(Color.RED, true),
BG_GREEN(Color.GREEN, true),
BG_YELLOW(Color.YELLOW, true),
BG_BLUE(Color.BLUE, true),
BG_MAGENTA(Color.MAGENTA, true),
BG_CYAN(Color.CYAN, true),
BG_WHITE(Color.WHITE, true),
BG_DEFAULT(Color.DEFAULT, true),
// Attributes | RESET(Attribute.RESET), |
fusesource/jansi | src/test/java/org/fusesource/jansi/io/AnsiOutputStreamTest.java | // Path: src/main/java/org/fusesource/jansi/AnsiColors.java
// public enum AnsiColors {
//
// Colors16("16 colors"),
// Colors256("256 colors"),
// TrueColor("24-bit colors");
//
// private final String description;
//
// AnsiColors(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiMode.java
// public enum AnsiMode {
//
// Strip("Strip all ansi sequences"),
// Default("Print ansi sequences if the stream is a terminal"),
// Force("Always print ansi sequences, even if the stream is redirected");
//
// private final String description;
//
// AnsiMode(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiType.java
// public enum AnsiType {
//
// Native("Supports ansi sequences natively"),
// Unsupported("Ansi sequences are stripped out"),
// VirtualTerminal("Supported through windows virtual terminal"),
// Emulation("Emulated through using windows API console commands"),
// Redirected("The stream is redirected to a file or a pipe");
//
// private final String description;
//
// AnsiType(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
| import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiMode;
import org.fusesource.jansi.AnsiType;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import static org.junit.jupiter.api.Assertions.assertEquals; | /*
* Copyright (C) 2009-2021 the original author(s).
*
* 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.fusesource.jansi.io;
class AnsiOutputStreamTest {
@Test
void canHandleSgrsWithMultipleOptions() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); | // Path: src/main/java/org/fusesource/jansi/AnsiColors.java
// public enum AnsiColors {
//
// Colors16("16 colors"),
// Colors256("256 colors"),
// TrueColor("24-bit colors");
//
// private final String description;
//
// AnsiColors(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiMode.java
// public enum AnsiMode {
//
// Strip("Strip all ansi sequences"),
// Default("Print ansi sequences if the stream is a terminal"),
// Force("Always print ansi sequences, even if the stream is redirected");
//
// private final String description;
//
// AnsiMode(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiType.java
// public enum AnsiType {
//
// Native("Supports ansi sequences natively"),
// Unsupported("Ansi sequences are stripped out"),
// VirtualTerminal("Supported through windows virtual terminal"),
// Emulation("Emulated through using windows API console commands"),
// Redirected("The stream is redirected to a file or a pipe");
//
// private final String description;
//
// AnsiType(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
// Path: src/test/java/org/fusesource/jansi/io/AnsiOutputStreamTest.java
import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiMode;
import org.fusesource.jansi.AnsiType;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import static org.junit.jupiter.api.Assertions.assertEquals;
/*
* Copyright (C) 2009-2021 the original author(s).
*
* 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.fusesource.jansi.io;
class AnsiOutputStreamTest {
@Test
void canHandleSgrsWithMultipleOptions() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); | final AnsiOutputStream ansiOutput = new AnsiOutputStream(baos, null, AnsiMode.Strip, null, AnsiType.Emulation, |
fusesource/jansi | src/test/java/org/fusesource/jansi/io/AnsiOutputStreamTest.java | // Path: src/main/java/org/fusesource/jansi/AnsiColors.java
// public enum AnsiColors {
//
// Colors16("16 colors"),
// Colors256("256 colors"),
// TrueColor("24-bit colors");
//
// private final String description;
//
// AnsiColors(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiMode.java
// public enum AnsiMode {
//
// Strip("Strip all ansi sequences"),
// Default("Print ansi sequences if the stream is a terminal"),
// Force("Always print ansi sequences, even if the stream is redirected");
//
// private final String description;
//
// AnsiMode(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiType.java
// public enum AnsiType {
//
// Native("Supports ansi sequences natively"),
// Unsupported("Ansi sequences are stripped out"),
// VirtualTerminal("Supported through windows virtual terminal"),
// Emulation("Emulated through using windows API console commands"),
// Redirected("The stream is redirected to a file or a pipe");
//
// private final String description;
//
// AnsiType(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
| import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiMode;
import org.fusesource.jansi.AnsiType;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import static org.junit.jupiter.api.Assertions.assertEquals; | /*
* Copyright (C) 2009-2021 the original author(s).
*
* 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.fusesource.jansi.io;
class AnsiOutputStreamTest {
@Test
void canHandleSgrsWithMultipleOptions() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); | // Path: src/main/java/org/fusesource/jansi/AnsiColors.java
// public enum AnsiColors {
//
// Colors16("16 colors"),
// Colors256("256 colors"),
// TrueColor("24-bit colors");
//
// private final String description;
//
// AnsiColors(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiMode.java
// public enum AnsiMode {
//
// Strip("Strip all ansi sequences"),
// Default("Print ansi sequences if the stream is a terminal"),
// Force("Always print ansi sequences, even if the stream is redirected");
//
// private final String description;
//
// AnsiMode(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiType.java
// public enum AnsiType {
//
// Native("Supports ansi sequences natively"),
// Unsupported("Ansi sequences are stripped out"),
// VirtualTerminal("Supported through windows virtual terminal"),
// Emulation("Emulated through using windows API console commands"),
// Redirected("The stream is redirected to a file or a pipe");
//
// private final String description;
//
// AnsiType(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
// Path: src/test/java/org/fusesource/jansi/io/AnsiOutputStreamTest.java
import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiMode;
import org.fusesource.jansi.AnsiType;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import static org.junit.jupiter.api.Assertions.assertEquals;
/*
* Copyright (C) 2009-2021 the original author(s).
*
* 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.fusesource.jansi.io;
class AnsiOutputStreamTest {
@Test
void canHandleSgrsWithMultipleOptions() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); | final AnsiOutputStream ansiOutput = new AnsiOutputStream(baos, null, AnsiMode.Strip, null, AnsiType.Emulation, |
fusesource/jansi | src/test/java/org/fusesource/jansi/io/AnsiOutputStreamTest.java | // Path: src/main/java/org/fusesource/jansi/AnsiColors.java
// public enum AnsiColors {
//
// Colors16("16 colors"),
// Colors256("256 colors"),
// TrueColor("24-bit colors");
//
// private final String description;
//
// AnsiColors(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiMode.java
// public enum AnsiMode {
//
// Strip("Strip all ansi sequences"),
// Default("Print ansi sequences if the stream is a terminal"),
// Force("Always print ansi sequences, even if the stream is redirected");
//
// private final String description;
//
// AnsiMode(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiType.java
// public enum AnsiType {
//
// Native("Supports ansi sequences natively"),
// Unsupported("Ansi sequences are stripped out"),
// VirtualTerminal("Supported through windows virtual terminal"),
// Emulation("Emulated through using windows API console commands"),
// Redirected("The stream is redirected to a file or a pipe");
//
// private final String description;
//
// AnsiType(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
| import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiMode;
import org.fusesource.jansi.AnsiType;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import static org.junit.jupiter.api.Assertions.assertEquals; | /*
* Copyright (C) 2009-2021 the original author(s).
*
* 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.fusesource.jansi.io;
class AnsiOutputStreamTest {
@Test
void canHandleSgrsWithMultipleOptions() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final AnsiOutputStream ansiOutput = new AnsiOutputStream(baos, null, AnsiMode.Strip, null, AnsiType.Emulation, | // Path: src/main/java/org/fusesource/jansi/AnsiColors.java
// public enum AnsiColors {
//
// Colors16("16 colors"),
// Colors256("256 colors"),
// TrueColor("24-bit colors");
//
// private final String description;
//
// AnsiColors(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiMode.java
// public enum AnsiMode {
//
// Strip("Strip all ansi sequences"),
// Default("Print ansi sequences if the stream is a terminal"),
// Force("Always print ansi sequences, even if the stream is redirected");
//
// private final String description;
//
// AnsiMode(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiType.java
// public enum AnsiType {
//
// Native("Supports ansi sequences natively"),
// Unsupported("Ansi sequences are stripped out"),
// VirtualTerminal("Supported through windows virtual terminal"),
// Emulation("Emulated through using windows API console commands"),
// Redirected("The stream is redirected to a file or a pipe");
//
// private final String description;
//
// AnsiType(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
// Path: src/test/java/org/fusesource/jansi/io/AnsiOutputStreamTest.java
import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiMode;
import org.fusesource.jansi.AnsiType;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import static org.junit.jupiter.api.Assertions.assertEquals;
/*
* Copyright (C) 2009-2021 the original author(s).
*
* 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.fusesource.jansi.io;
class AnsiOutputStreamTest {
@Test
void canHandleSgrsWithMultipleOptions() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final AnsiOutputStream ansiOutput = new AnsiOutputStream(baos, null, AnsiMode.Strip, null, AnsiType.Emulation, | AnsiColors.TrueColor, Charset.forName("UTF-8"), null, null, false); |
fusesource/jansi | src/test/java/org/fusesource/jansi/AnsiTest.java | // Path: src/main/java/org/fusesource/jansi/Ansi.java
// public enum Color {
// BLACK(0, "BLACK"),
// RED(1, "RED"),
// GREEN(2, "GREEN"),
// YELLOW(3, "YELLOW"),
// BLUE(4, "BLUE"),
// MAGENTA(5, "MAGENTA"),
// CYAN(6, "CYAN"),
// WHITE(7, "WHITE"),
// DEFAULT(9, "DEFAULT");
//
// private final int value;
// private final String name;
//
// Color(int index, String name) {
// this.value = index;
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// public int value() {
// return value;
// }
//
// public int fg() {
// return value + 30;
// }
//
// public int bg() {
// return value + 40;
// }
//
// public int fgBright() {
// return value + 90;
// }
//
// public int bgBright() {
// return value + 100;
// }
// }
| import org.fusesource.jansi.Ansi.Color;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import static org.junit.jupiter.api.Assertions.assertEquals; | /*
* Copyright (C) 2009-2017 the original author(s).
*
* 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.fusesource.jansi;
/**
* Tests for the {@link Ansi} class.
*
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
*/
public class AnsiTest {
@Test
public void testSetEnabled() throws Exception {
Ansi.setEnabled(false);
new Thread() {
@Override
public void run() {
assertEquals(false, Ansi.isEnabled());
}
}.run();
Ansi.setEnabled(true);
new Thread() {
@Override
public void run() {
assertEquals(true, Ansi.isEnabled());
}
}.run();
}
@Test
public void testClone() throws CloneNotSupportedException { | // Path: src/main/java/org/fusesource/jansi/Ansi.java
// public enum Color {
// BLACK(0, "BLACK"),
// RED(1, "RED"),
// GREEN(2, "GREEN"),
// YELLOW(3, "YELLOW"),
// BLUE(4, "BLUE"),
// MAGENTA(5, "MAGENTA"),
// CYAN(6, "CYAN"),
// WHITE(7, "WHITE"),
// DEFAULT(9, "DEFAULT");
//
// private final int value;
// private final String name;
//
// Color(int index, String name) {
// this.value = index;
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// public int value() {
// return value;
// }
//
// public int fg() {
// return value + 30;
// }
//
// public int bg() {
// return value + 40;
// }
//
// public int fgBright() {
// return value + 90;
// }
//
// public int bgBright() {
// return value + 100;
// }
// }
// Path: src/test/java/org/fusesource/jansi/AnsiTest.java
import org.fusesource.jansi.Ansi.Color;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
/*
* Copyright (C) 2009-2017 the original author(s).
*
* 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.fusesource.jansi;
/**
* Tests for the {@link Ansi} class.
*
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
*/
public class AnsiTest {
@Test
public void testSetEnabled() throws Exception {
Ansi.setEnabled(false);
new Thread() {
@Override
public void run() {
assertEquals(false, Ansi.isEnabled());
}
}.run();
Ansi.setEnabled(true);
new Thread() {
@Override
public void run() {
assertEquals(true, Ansi.isEnabled());
}
}.run();
}
@Test
public void testClone() throws CloneNotSupportedException { | Ansi ansi = Ansi.ansi().a("Some text").bg(Color.BLACK).fg(Color.WHITE); |
fusesource/jansi | src/main/java/org/fusesource/jansi/io/AnsiOutputStream.java | // Path: src/main/java/org/fusesource/jansi/AnsiColors.java
// public enum AnsiColors {
//
// Colors16("16 colors"),
// Colors256("256 colors"),
// TrueColor("24-bit colors");
//
// private final String description;
//
// AnsiColors(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiMode.java
// public enum AnsiMode {
//
// Strip("Strip all ansi sequences"),
// Default("Print ansi sequences if the stream is a terminal"),
// Force("Always print ansi sequences, even if the stream is redirected");
//
// private final String description;
//
// AnsiMode(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiType.java
// public enum AnsiType {
//
// Native("Supports ansi sequences natively"),
// Unsupported("Ansi sequences are stripped out"),
// VirtualTerminal("Supported through windows virtual terminal"),
// Emulation("Emulated through using windows API console commands"),
// Redirected("The stream is redirected to a file or a pipe");
//
// private final String description;
//
// AnsiType(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
| import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiMode;
import org.fusesource.jansi.AnsiType; | private static final int LOOKING_FOR_FIRST_ESC_CHAR = 0;
private static final int LOOKING_FOR_SECOND_ESC_CHAR = 1;
private static final int LOOKING_FOR_NEXT_ARG = 2;
private static final int LOOKING_FOR_STR_ARG_END = 3;
private static final int LOOKING_FOR_INT_ARG_END = 4;
private static final int LOOKING_FOR_OSC_COMMAND = 5;
private static final int LOOKING_FOR_OSC_COMMAND_END = 6;
private static final int LOOKING_FOR_OSC_PARAM = 7;
private static final int LOOKING_FOR_ST = 8;
private static final int LOOKING_FOR_CHARSET = 9;
private static final int FIRST_ESC_CHAR = 27;
private static final int SECOND_ESC_CHAR = '[';
private static final int SECOND_OSC_CHAR = ']';
private static final int BEL = 7;
private static final int SECOND_ST_CHAR = '\\';
private static final int SECOND_CHARSET0_CHAR = '(';
private static final int SECOND_CHARSET1_CHAR = ')';
private AnsiProcessor ap;
private final static int MAX_ESCAPE_SEQUENCE_LENGTH = 100;
private final byte[] buffer = new byte[MAX_ESCAPE_SEQUENCE_LENGTH];
private int pos = 0;
private int startOfValue;
private final ArrayList<Object> options = new ArrayList<Object>();
private int state = LOOKING_FOR_FIRST_ESC_CHAR;
private final Charset cs;
private final WidthSupplier width;
private final AnsiProcessor processor; | // Path: src/main/java/org/fusesource/jansi/AnsiColors.java
// public enum AnsiColors {
//
// Colors16("16 colors"),
// Colors256("256 colors"),
// TrueColor("24-bit colors");
//
// private final String description;
//
// AnsiColors(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiMode.java
// public enum AnsiMode {
//
// Strip("Strip all ansi sequences"),
// Default("Print ansi sequences if the stream is a terminal"),
// Force("Always print ansi sequences, even if the stream is redirected");
//
// private final String description;
//
// AnsiMode(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiType.java
// public enum AnsiType {
//
// Native("Supports ansi sequences natively"),
// Unsupported("Ansi sequences are stripped out"),
// VirtualTerminal("Supported through windows virtual terminal"),
// Emulation("Emulated through using windows API console commands"),
// Redirected("The stream is redirected to a file or a pipe");
//
// private final String description;
//
// AnsiType(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
// Path: src/main/java/org/fusesource/jansi/io/AnsiOutputStream.java
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiMode;
import org.fusesource.jansi.AnsiType;
private static final int LOOKING_FOR_FIRST_ESC_CHAR = 0;
private static final int LOOKING_FOR_SECOND_ESC_CHAR = 1;
private static final int LOOKING_FOR_NEXT_ARG = 2;
private static final int LOOKING_FOR_STR_ARG_END = 3;
private static final int LOOKING_FOR_INT_ARG_END = 4;
private static final int LOOKING_FOR_OSC_COMMAND = 5;
private static final int LOOKING_FOR_OSC_COMMAND_END = 6;
private static final int LOOKING_FOR_OSC_PARAM = 7;
private static final int LOOKING_FOR_ST = 8;
private static final int LOOKING_FOR_CHARSET = 9;
private static final int FIRST_ESC_CHAR = 27;
private static final int SECOND_ESC_CHAR = '[';
private static final int SECOND_OSC_CHAR = ']';
private static final int BEL = 7;
private static final int SECOND_ST_CHAR = '\\';
private static final int SECOND_CHARSET0_CHAR = '(';
private static final int SECOND_CHARSET1_CHAR = ')';
private AnsiProcessor ap;
private final static int MAX_ESCAPE_SEQUENCE_LENGTH = 100;
private final byte[] buffer = new byte[MAX_ESCAPE_SEQUENCE_LENGTH];
private int pos = 0;
private int startOfValue;
private final ArrayList<Object> options = new ArrayList<Object>();
private int state = LOOKING_FOR_FIRST_ESC_CHAR;
private final Charset cs;
private final WidthSupplier width;
private final AnsiProcessor processor; | private final AnsiType type; |
fusesource/jansi | src/main/java/org/fusesource/jansi/io/AnsiOutputStream.java | // Path: src/main/java/org/fusesource/jansi/AnsiColors.java
// public enum AnsiColors {
//
// Colors16("16 colors"),
// Colors256("256 colors"),
// TrueColor("24-bit colors");
//
// private final String description;
//
// AnsiColors(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiMode.java
// public enum AnsiMode {
//
// Strip("Strip all ansi sequences"),
// Default("Print ansi sequences if the stream is a terminal"),
// Force("Always print ansi sequences, even if the stream is redirected");
//
// private final String description;
//
// AnsiMode(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiType.java
// public enum AnsiType {
//
// Native("Supports ansi sequences natively"),
// Unsupported("Ansi sequences are stripped out"),
// VirtualTerminal("Supported through windows virtual terminal"),
// Emulation("Emulated through using windows API console commands"),
// Redirected("The stream is redirected to a file or a pipe");
//
// private final String description;
//
// AnsiType(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
| import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiMode;
import org.fusesource.jansi.AnsiType; | private static final int LOOKING_FOR_SECOND_ESC_CHAR = 1;
private static final int LOOKING_FOR_NEXT_ARG = 2;
private static final int LOOKING_FOR_STR_ARG_END = 3;
private static final int LOOKING_FOR_INT_ARG_END = 4;
private static final int LOOKING_FOR_OSC_COMMAND = 5;
private static final int LOOKING_FOR_OSC_COMMAND_END = 6;
private static final int LOOKING_FOR_OSC_PARAM = 7;
private static final int LOOKING_FOR_ST = 8;
private static final int LOOKING_FOR_CHARSET = 9;
private static final int FIRST_ESC_CHAR = 27;
private static final int SECOND_ESC_CHAR = '[';
private static final int SECOND_OSC_CHAR = ']';
private static final int BEL = 7;
private static final int SECOND_ST_CHAR = '\\';
private static final int SECOND_CHARSET0_CHAR = '(';
private static final int SECOND_CHARSET1_CHAR = ')';
private AnsiProcessor ap;
private final static int MAX_ESCAPE_SEQUENCE_LENGTH = 100;
private final byte[] buffer = new byte[MAX_ESCAPE_SEQUENCE_LENGTH];
private int pos = 0;
private int startOfValue;
private final ArrayList<Object> options = new ArrayList<Object>();
private int state = LOOKING_FOR_FIRST_ESC_CHAR;
private final Charset cs;
private final WidthSupplier width;
private final AnsiProcessor processor;
private final AnsiType type; | // Path: src/main/java/org/fusesource/jansi/AnsiColors.java
// public enum AnsiColors {
//
// Colors16("16 colors"),
// Colors256("256 colors"),
// TrueColor("24-bit colors");
//
// private final String description;
//
// AnsiColors(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiMode.java
// public enum AnsiMode {
//
// Strip("Strip all ansi sequences"),
// Default("Print ansi sequences if the stream is a terminal"),
// Force("Always print ansi sequences, even if the stream is redirected");
//
// private final String description;
//
// AnsiMode(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiType.java
// public enum AnsiType {
//
// Native("Supports ansi sequences natively"),
// Unsupported("Ansi sequences are stripped out"),
// VirtualTerminal("Supported through windows virtual terminal"),
// Emulation("Emulated through using windows API console commands"),
// Redirected("The stream is redirected to a file or a pipe");
//
// private final String description;
//
// AnsiType(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
// Path: src/main/java/org/fusesource/jansi/io/AnsiOutputStream.java
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiMode;
import org.fusesource.jansi.AnsiType;
private static final int LOOKING_FOR_SECOND_ESC_CHAR = 1;
private static final int LOOKING_FOR_NEXT_ARG = 2;
private static final int LOOKING_FOR_STR_ARG_END = 3;
private static final int LOOKING_FOR_INT_ARG_END = 4;
private static final int LOOKING_FOR_OSC_COMMAND = 5;
private static final int LOOKING_FOR_OSC_COMMAND_END = 6;
private static final int LOOKING_FOR_OSC_PARAM = 7;
private static final int LOOKING_FOR_ST = 8;
private static final int LOOKING_FOR_CHARSET = 9;
private static final int FIRST_ESC_CHAR = 27;
private static final int SECOND_ESC_CHAR = '[';
private static final int SECOND_OSC_CHAR = ']';
private static final int BEL = 7;
private static final int SECOND_ST_CHAR = '\\';
private static final int SECOND_CHARSET0_CHAR = '(';
private static final int SECOND_CHARSET1_CHAR = ')';
private AnsiProcessor ap;
private final static int MAX_ESCAPE_SEQUENCE_LENGTH = 100;
private final byte[] buffer = new byte[MAX_ESCAPE_SEQUENCE_LENGTH];
private int pos = 0;
private int startOfValue;
private final ArrayList<Object> options = new ArrayList<Object>();
private int state = LOOKING_FOR_FIRST_ESC_CHAR;
private final Charset cs;
private final WidthSupplier width;
private final AnsiProcessor processor;
private final AnsiType type; | private final AnsiColors colors; |
fusesource/jansi | src/main/java/org/fusesource/jansi/io/AnsiOutputStream.java | // Path: src/main/java/org/fusesource/jansi/AnsiColors.java
// public enum AnsiColors {
//
// Colors16("16 colors"),
// Colors256("256 colors"),
// TrueColor("24-bit colors");
//
// private final String description;
//
// AnsiColors(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiMode.java
// public enum AnsiMode {
//
// Strip("Strip all ansi sequences"),
// Default("Print ansi sequences if the stream is a terminal"),
// Force("Always print ansi sequences, even if the stream is redirected");
//
// private final String description;
//
// AnsiMode(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiType.java
// public enum AnsiType {
//
// Native("Supports ansi sequences natively"),
// Unsupported("Ansi sequences are stripped out"),
// VirtualTerminal("Supported through windows virtual terminal"),
// Emulation("Emulated through using windows API console commands"),
// Redirected("The stream is redirected to a file or a pipe");
//
// private final String description;
//
// AnsiType(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
| import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiMode;
import org.fusesource.jansi.AnsiType; | private static final int LOOKING_FOR_INT_ARG_END = 4;
private static final int LOOKING_FOR_OSC_COMMAND = 5;
private static final int LOOKING_FOR_OSC_COMMAND_END = 6;
private static final int LOOKING_FOR_OSC_PARAM = 7;
private static final int LOOKING_FOR_ST = 8;
private static final int LOOKING_FOR_CHARSET = 9;
private static final int FIRST_ESC_CHAR = 27;
private static final int SECOND_ESC_CHAR = '[';
private static final int SECOND_OSC_CHAR = ']';
private static final int BEL = 7;
private static final int SECOND_ST_CHAR = '\\';
private static final int SECOND_CHARSET0_CHAR = '(';
private static final int SECOND_CHARSET1_CHAR = ')';
private AnsiProcessor ap;
private final static int MAX_ESCAPE_SEQUENCE_LENGTH = 100;
private final byte[] buffer = new byte[MAX_ESCAPE_SEQUENCE_LENGTH];
private int pos = 0;
private int startOfValue;
private final ArrayList<Object> options = new ArrayList<Object>();
private int state = LOOKING_FOR_FIRST_ESC_CHAR;
private final Charset cs;
private final WidthSupplier width;
private final AnsiProcessor processor;
private final AnsiType type;
private final AnsiColors colors;
private final IoRunnable installer;
private final IoRunnable uninstaller; | // Path: src/main/java/org/fusesource/jansi/AnsiColors.java
// public enum AnsiColors {
//
// Colors16("16 colors"),
// Colors256("256 colors"),
// TrueColor("24-bit colors");
//
// private final String description;
//
// AnsiColors(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiMode.java
// public enum AnsiMode {
//
// Strip("Strip all ansi sequences"),
// Default("Print ansi sequences if the stream is a terminal"),
// Force("Always print ansi sequences, even if the stream is redirected");
//
// private final String description;
//
// AnsiMode(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/org/fusesource/jansi/AnsiType.java
// public enum AnsiType {
//
// Native("Supports ansi sequences natively"),
// Unsupported("Ansi sequences are stripped out"),
// VirtualTerminal("Supported through windows virtual terminal"),
// Emulation("Emulated through using windows API console commands"),
// Redirected("The stream is redirected to a file or a pipe");
//
// private final String description;
//
// AnsiType(String description) {
// this.description = description;
// }
//
// String getDescription() {
// return description;
// }
// }
// Path: src/main/java/org/fusesource/jansi/io/AnsiOutputStream.java
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import org.fusesource.jansi.AnsiColors;
import org.fusesource.jansi.AnsiMode;
import org.fusesource.jansi.AnsiType;
private static final int LOOKING_FOR_INT_ARG_END = 4;
private static final int LOOKING_FOR_OSC_COMMAND = 5;
private static final int LOOKING_FOR_OSC_COMMAND_END = 6;
private static final int LOOKING_FOR_OSC_PARAM = 7;
private static final int LOOKING_FOR_ST = 8;
private static final int LOOKING_FOR_CHARSET = 9;
private static final int FIRST_ESC_CHAR = 27;
private static final int SECOND_ESC_CHAR = '[';
private static final int SECOND_OSC_CHAR = ']';
private static final int BEL = 7;
private static final int SECOND_ST_CHAR = '\\';
private static final int SECOND_CHARSET0_CHAR = '(';
private static final int SECOND_CHARSET1_CHAR = ')';
private AnsiProcessor ap;
private final static int MAX_ESCAPE_SEQUENCE_LENGTH = 100;
private final byte[] buffer = new byte[MAX_ESCAPE_SEQUENCE_LENGTH];
private int pos = 0;
private int startOfValue;
private final ArrayList<Object> options = new ArrayList<Object>();
private int state = LOOKING_FOR_FIRST_ESC_CHAR;
private final Charset cs;
private final WidthSupplier width;
private final AnsiProcessor processor;
private final AnsiType type;
private final AnsiColors colors;
private final IoRunnable installer;
private final IoRunnable uninstaller; | private AnsiMode mode; |
virustotalop/ObsidianAuctions | src/main/java/com/gmail/virustotalop/obsidianauctions/nbt/NBTCompound.java | // Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/VersionUtil.java
// @ApiStatus.Internal
// public final class VersionUtil {
//
// private static final String VERSION;
//
// static {
// if (Bukkit.getServer() == null) {
// VERSION = null;
// } else {
// String name = Bukkit.getServer().getClass().getPackage().getName();
// VERSION = name.substring(name.lastIndexOf('.') + 1);
// }
// }
//
// public synchronized static String getVersion() {
// return VERSION;
// }
//
// private VersionUtil() {
// }
// }
| import com.gmail.virustotalop.obsidianauctions.util.VersionUtil;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Set; | package com.gmail.virustotalop.obsidianauctions.nbt;
public class NBTCompound {
private static final String version;
private static Class<?> compoundClass;
private static Method parse;
private static Method getKeys;
private static Method get;
static { | // Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/VersionUtil.java
// @ApiStatus.Internal
// public final class VersionUtil {
//
// private static final String VERSION;
//
// static {
// if (Bukkit.getServer() == null) {
// VERSION = null;
// } else {
// String name = Bukkit.getServer().getClass().getPackage().getName();
// VERSION = name.substring(name.lastIndexOf('.') + 1);
// }
// }
//
// public synchronized static String getVersion() {
// return VERSION;
// }
//
// private VersionUtil() {
// }
// }
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/nbt/NBTCompound.java
import com.gmail.virustotalop.obsidianauctions.util.VersionUtil;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Set;
package com.gmail.virustotalop.obsidianauctions.nbt;
public class NBTCompound {
private static final String version;
private static Class<?> compoundClass;
private static Method parse;
private static Method getKeys;
private static Method get;
static { | version = VersionUtil.getVersion(); |
virustotalop/ObsidianAuctions | src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
| import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.google.inject.Binder;
import com.google.inject.Module; | package com.github.virustotalop.obsidianauctions.test.util.mock;
public class MockInjectorModule implements Module {
@Override
public void configure(Binder binder) { | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.google.inject.Binder;
import com.google.inject.Module;
package com.github.virustotalop.obsidianauctions.test.util.mock;
public class MockInjectorModule implements Module {
@Override
public void configure(Binder binder) { | binder.bind(MockListenerOne.class).toInstance(new MockListenerOne()); |
virustotalop/ObsidianAuctions | src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
| import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.google.inject.Binder;
import com.google.inject.Module; | package com.github.virustotalop.obsidianauctions.test.util.mock;
public class MockInjectorModule implements Module {
@Override
public void configure(Binder binder) {
binder.bind(MockListenerOne.class).toInstance(new MockListenerOne()); | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.google.inject.Binder;
import com.google.inject.Module;
package com.github.virustotalop.obsidianauctions.test.util.mock;
public class MockInjectorModule implements Module {
@Override
public void configure(Binder binder) {
binder.bind(MockListenerOne.class).toInstance(new MockListenerOne()); | binder.bind(MockListenerTwo.class).toInstance(new MockListenerTwo()); |
virustotalop/ObsidianAuctions | src/test/java/com/github/virustotalop/obsidianauctions/test/util/InjectUtilTest.java | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java
// public class MockInjectorModule implements Module {
// @Override
// public void configure(Binder binder) {
// binder.bind(MockListenerOne.class).toInstance(new MockListenerOne());
// binder.bind(MockListenerTwo.class).toInstance(new MockListenerTwo());
// }
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockListener.java
// public interface MockListener {
//
//
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
//
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/InjectUtil.java
// @ApiStatus.Internal
// @ApiStatus.NonExtendable
// public final class InjectUtil {
//
// public static <T> List<T> collect(@NotNull Class<T> superClazz, @NotNull Injector injector) {
// List<T> bindings = new ArrayList<>();
// injector.getAllBindings().values().forEach(binding -> {
// Class<?> bindingClazz = binding.getKey().getTypeLiteral().getRawType();
// if (superClazz.isAssignableFrom(bindingClazz)) {
// bindings.add((T) binding.getProvider().get());
// }
// });
// return bindings;
// }
//
// private InjectUtil() {
// }
// }
| import com.github.virustotalop.obsidianauctions.test.util.mock.MockInjectorModule;
import com.github.virustotalop.obsidianauctions.test.util.mock.MockListener;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.gmail.virustotalop.obsidianauctions.util.InjectUtil;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals; | package com.github.virustotalop.obsidianauctions.test.util;
public class InjectUtilTest {
@Test
public void testCollect() { | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java
// public class MockInjectorModule implements Module {
// @Override
// public void configure(Binder binder) {
// binder.bind(MockListenerOne.class).toInstance(new MockListenerOne());
// binder.bind(MockListenerTwo.class).toInstance(new MockListenerTwo());
// }
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockListener.java
// public interface MockListener {
//
//
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
//
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/InjectUtil.java
// @ApiStatus.Internal
// @ApiStatus.NonExtendable
// public final class InjectUtil {
//
// public static <T> List<T> collect(@NotNull Class<T> superClazz, @NotNull Injector injector) {
// List<T> bindings = new ArrayList<>();
// injector.getAllBindings().values().forEach(binding -> {
// Class<?> bindingClazz = binding.getKey().getTypeLiteral().getRawType();
// if (superClazz.isAssignableFrom(bindingClazz)) {
// bindings.add((T) binding.getProvider().get());
// }
// });
// return bindings;
// }
//
// private InjectUtil() {
// }
// }
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/InjectUtilTest.java
import com.github.virustotalop.obsidianauctions.test.util.mock.MockInjectorModule;
import com.github.virustotalop.obsidianauctions.test.util.mock.MockListener;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.gmail.virustotalop.obsidianauctions.util.InjectUtil;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
package com.github.virustotalop.obsidianauctions.test.util;
public class InjectUtilTest {
@Test
public void testCollect() { | Injector injector = Guice.createInjector(new MockInjectorModule()); |
virustotalop/ObsidianAuctions | src/test/java/com/github/virustotalop/obsidianauctions/test/util/InjectUtilTest.java | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java
// public class MockInjectorModule implements Module {
// @Override
// public void configure(Binder binder) {
// binder.bind(MockListenerOne.class).toInstance(new MockListenerOne());
// binder.bind(MockListenerTwo.class).toInstance(new MockListenerTwo());
// }
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockListener.java
// public interface MockListener {
//
//
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
//
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/InjectUtil.java
// @ApiStatus.Internal
// @ApiStatus.NonExtendable
// public final class InjectUtil {
//
// public static <T> List<T> collect(@NotNull Class<T> superClazz, @NotNull Injector injector) {
// List<T> bindings = new ArrayList<>();
// injector.getAllBindings().values().forEach(binding -> {
// Class<?> bindingClazz = binding.getKey().getTypeLiteral().getRawType();
// if (superClazz.isAssignableFrom(bindingClazz)) {
// bindings.add((T) binding.getProvider().get());
// }
// });
// return bindings;
// }
//
// private InjectUtil() {
// }
// }
| import com.github.virustotalop.obsidianauctions.test.util.mock.MockInjectorModule;
import com.github.virustotalop.obsidianauctions.test.util.mock.MockListener;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.gmail.virustotalop.obsidianauctions.util.InjectUtil;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals; | package com.github.virustotalop.obsidianauctions.test.util;
public class InjectUtilTest {
@Test
public void testCollect() {
Injector injector = Guice.createInjector(new MockInjectorModule()); | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java
// public class MockInjectorModule implements Module {
// @Override
// public void configure(Binder binder) {
// binder.bind(MockListenerOne.class).toInstance(new MockListenerOne());
// binder.bind(MockListenerTwo.class).toInstance(new MockListenerTwo());
// }
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockListener.java
// public interface MockListener {
//
//
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
//
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/InjectUtil.java
// @ApiStatus.Internal
// @ApiStatus.NonExtendable
// public final class InjectUtil {
//
// public static <T> List<T> collect(@NotNull Class<T> superClazz, @NotNull Injector injector) {
// List<T> bindings = new ArrayList<>();
// injector.getAllBindings().values().forEach(binding -> {
// Class<?> bindingClazz = binding.getKey().getTypeLiteral().getRawType();
// if (superClazz.isAssignableFrom(bindingClazz)) {
// bindings.add((T) binding.getProvider().get());
// }
// });
// return bindings;
// }
//
// private InjectUtil() {
// }
// }
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/InjectUtilTest.java
import com.github.virustotalop.obsidianauctions.test.util.mock.MockInjectorModule;
import com.github.virustotalop.obsidianauctions.test.util.mock.MockListener;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.gmail.virustotalop.obsidianauctions.util.InjectUtil;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
package com.github.virustotalop.obsidianauctions.test.util;
public class InjectUtilTest {
@Test
public void testCollect() {
Injector injector = Guice.createInjector(new MockInjectorModule()); | List<MockListener> collected = InjectUtil.collect(MockListener.class, injector); |
virustotalop/ObsidianAuctions | src/test/java/com/github/virustotalop/obsidianauctions/test/util/InjectUtilTest.java | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java
// public class MockInjectorModule implements Module {
// @Override
// public void configure(Binder binder) {
// binder.bind(MockListenerOne.class).toInstance(new MockListenerOne());
// binder.bind(MockListenerTwo.class).toInstance(new MockListenerTwo());
// }
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockListener.java
// public interface MockListener {
//
//
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
//
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/InjectUtil.java
// @ApiStatus.Internal
// @ApiStatus.NonExtendable
// public final class InjectUtil {
//
// public static <T> List<T> collect(@NotNull Class<T> superClazz, @NotNull Injector injector) {
// List<T> bindings = new ArrayList<>();
// injector.getAllBindings().values().forEach(binding -> {
// Class<?> bindingClazz = binding.getKey().getTypeLiteral().getRawType();
// if (superClazz.isAssignableFrom(bindingClazz)) {
// bindings.add((T) binding.getProvider().get());
// }
// });
// return bindings;
// }
//
// private InjectUtil() {
// }
// }
| import com.github.virustotalop.obsidianauctions.test.util.mock.MockInjectorModule;
import com.github.virustotalop.obsidianauctions.test.util.mock.MockListener;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.gmail.virustotalop.obsidianauctions.util.InjectUtil;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals; | package com.github.virustotalop.obsidianauctions.test.util;
public class InjectUtilTest {
@Test
public void testCollect() {
Injector injector = Guice.createInjector(new MockInjectorModule()); | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java
// public class MockInjectorModule implements Module {
// @Override
// public void configure(Binder binder) {
// binder.bind(MockListenerOne.class).toInstance(new MockListenerOne());
// binder.bind(MockListenerTwo.class).toInstance(new MockListenerTwo());
// }
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockListener.java
// public interface MockListener {
//
//
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
//
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/InjectUtil.java
// @ApiStatus.Internal
// @ApiStatus.NonExtendable
// public final class InjectUtil {
//
// public static <T> List<T> collect(@NotNull Class<T> superClazz, @NotNull Injector injector) {
// List<T> bindings = new ArrayList<>();
// injector.getAllBindings().values().forEach(binding -> {
// Class<?> bindingClazz = binding.getKey().getTypeLiteral().getRawType();
// if (superClazz.isAssignableFrom(bindingClazz)) {
// bindings.add((T) binding.getProvider().get());
// }
// });
// return bindings;
// }
//
// private InjectUtil() {
// }
// }
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/InjectUtilTest.java
import com.github.virustotalop.obsidianauctions.test.util.mock.MockInjectorModule;
import com.github.virustotalop.obsidianauctions.test.util.mock.MockListener;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.gmail.virustotalop.obsidianauctions.util.InjectUtil;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
package com.github.virustotalop.obsidianauctions.test.util;
public class InjectUtilTest {
@Test
public void testCollect() {
Injector injector = Guice.createInjector(new MockInjectorModule()); | List<MockListener> collected = InjectUtil.collect(MockListener.class, injector); |
virustotalop/ObsidianAuctions | src/test/java/com/github/virustotalop/obsidianauctions/test/util/InjectUtilTest.java | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java
// public class MockInjectorModule implements Module {
// @Override
// public void configure(Binder binder) {
// binder.bind(MockListenerOne.class).toInstance(new MockListenerOne());
// binder.bind(MockListenerTwo.class).toInstance(new MockListenerTwo());
// }
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockListener.java
// public interface MockListener {
//
//
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
//
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/InjectUtil.java
// @ApiStatus.Internal
// @ApiStatus.NonExtendable
// public final class InjectUtil {
//
// public static <T> List<T> collect(@NotNull Class<T> superClazz, @NotNull Injector injector) {
// List<T> bindings = new ArrayList<>();
// injector.getAllBindings().values().forEach(binding -> {
// Class<?> bindingClazz = binding.getKey().getTypeLiteral().getRawType();
// if (superClazz.isAssignableFrom(bindingClazz)) {
// bindings.add((T) binding.getProvider().get());
// }
// });
// return bindings;
// }
//
// private InjectUtil() {
// }
// }
| import com.github.virustotalop.obsidianauctions.test.util.mock.MockInjectorModule;
import com.github.virustotalop.obsidianauctions.test.util.mock.MockListener;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.gmail.virustotalop.obsidianauctions.util.InjectUtil;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals; | package com.github.virustotalop.obsidianauctions.test.util;
public class InjectUtilTest {
@Test
public void testCollect() {
Injector injector = Guice.createInjector(new MockInjectorModule());
List<MockListener> collected = InjectUtil.collect(MockListener.class, injector);
assertEquals(2, collected.size()); | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java
// public class MockInjectorModule implements Module {
// @Override
// public void configure(Binder binder) {
// binder.bind(MockListenerOne.class).toInstance(new MockListenerOne());
// binder.bind(MockListenerTwo.class).toInstance(new MockListenerTwo());
// }
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockListener.java
// public interface MockListener {
//
//
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
//
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/InjectUtil.java
// @ApiStatus.Internal
// @ApiStatus.NonExtendable
// public final class InjectUtil {
//
// public static <T> List<T> collect(@NotNull Class<T> superClazz, @NotNull Injector injector) {
// List<T> bindings = new ArrayList<>();
// injector.getAllBindings().values().forEach(binding -> {
// Class<?> bindingClazz = binding.getKey().getTypeLiteral().getRawType();
// if (superClazz.isAssignableFrom(bindingClazz)) {
// bindings.add((T) binding.getProvider().get());
// }
// });
// return bindings;
// }
//
// private InjectUtil() {
// }
// }
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/InjectUtilTest.java
import com.github.virustotalop.obsidianauctions.test.util.mock.MockInjectorModule;
import com.github.virustotalop.obsidianauctions.test.util.mock.MockListener;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.gmail.virustotalop.obsidianauctions.util.InjectUtil;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
package com.github.virustotalop.obsidianauctions.test.util;
public class InjectUtilTest {
@Test
public void testCollect() {
Injector injector = Guice.createInjector(new MockInjectorModule());
List<MockListener> collected = InjectUtil.collect(MockListener.class, injector);
assertEquals(2, collected.size()); | assertEquals(MockListenerOne.class, collected.get(0).getClass()); |
virustotalop/ObsidianAuctions | src/test/java/com/github/virustotalop/obsidianauctions/test/util/InjectUtilTest.java | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java
// public class MockInjectorModule implements Module {
// @Override
// public void configure(Binder binder) {
// binder.bind(MockListenerOne.class).toInstance(new MockListenerOne());
// binder.bind(MockListenerTwo.class).toInstance(new MockListenerTwo());
// }
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockListener.java
// public interface MockListener {
//
//
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
//
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/InjectUtil.java
// @ApiStatus.Internal
// @ApiStatus.NonExtendable
// public final class InjectUtil {
//
// public static <T> List<T> collect(@NotNull Class<T> superClazz, @NotNull Injector injector) {
// List<T> bindings = new ArrayList<>();
// injector.getAllBindings().values().forEach(binding -> {
// Class<?> bindingClazz = binding.getKey().getTypeLiteral().getRawType();
// if (superClazz.isAssignableFrom(bindingClazz)) {
// bindings.add((T) binding.getProvider().get());
// }
// });
// return bindings;
// }
//
// private InjectUtil() {
// }
// }
| import com.github.virustotalop.obsidianauctions.test.util.mock.MockInjectorModule;
import com.github.virustotalop.obsidianauctions.test.util.mock.MockListener;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.gmail.virustotalop.obsidianauctions.util.InjectUtil;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals; | package com.github.virustotalop.obsidianauctions.test.util;
public class InjectUtilTest {
@Test
public void testCollect() {
Injector injector = Guice.createInjector(new MockInjectorModule());
List<MockListener> collected = InjectUtil.collect(MockListener.class, injector);
assertEquals(2, collected.size());
assertEquals(MockListenerOne.class, collected.get(0).getClass()); | // Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockInjectorModule.java
// public class MockInjectorModule implements Module {
// @Override
// public void configure(Binder binder) {
// binder.bind(MockListenerOne.class).toInstance(new MockListenerOne());
// binder.bind(MockListenerTwo.class).toInstance(new MockListenerTwo());
// }
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/MockListener.java
// public interface MockListener {
//
//
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerOne.java
// public class MockListenerOne implements MockListener {
// }
//
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/mock/listener/MockListenerTwo.java
// public class MockListenerTwo implements MockListener {
// }
//
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/InjectUtil.java
// @ApiStatus.Internal
// @ApiStatus.NonExtendable
// public final class InjectUtil {
//
// public static <T> List<T> collect(@NotNull Class<T> superClazz, @NotNull Injector injector) {
// List<T> bindings = new ArrayList<>();
// injector.getAllBindings().values().forEach(binding -> {
// Class<?> bindingClazz = binding.getKey().getTypeLiteral().getRawType();
// if (superClazz.isAssignableFrom(bindingClazz)) {
// bindings.add((T) binding.getProvider().get());
// }
// });
// return bindings;
// }
//
// private InjectUtil() {
// }
// }
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/util/InjectUtilTest.java
import com.github.virustotalop.obsidianauctions.test.util.mock.MockInjectorModule;
import com.github.virustotalop.obsidianauctions.test.util.mock.MockListener;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerOne;
import com.github.virustotalop.obsidianauctions.test.util.mock.listener.MockListenerTwo;
import com.gmail.virustotalop.obsidianauctions.util.InjectUtil;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
package com.github.virustotalop.obsidianauctions.test.util;
public class InjectUtilTest {
@Test
public void testCollect() {
Injector injector = Guice.createInjector(new MockInjectorModule());
List<MockListener> collected = InjectUtil.collect(MockListener.class, injector);
assertEquals(2, collected.size());
assertEquals(MockListenerOne.class, collected.get(0).getClass()); | assertEquals(MockListenerTwo.class, collected.get(1).getClass()); |
virustotalop/ObsidianAuctions | src/test/java/com/github/virustotalop/obsidianauctions/test/bukkit/plugin/PapiTest.java | // Path: src/main/java/com/gmail/virustotalop/obsidianauctions/placeholder/NoPlaceholderImpl.java
// public class NoPlaceholderImpl implements Placeholder {
//
// @Override
// public String replace(Player player, String message) {
// return message;
// }
// }
| import com.gmail.virustotalop.obsidianauctions.placeholder.NoPlaceholderImpl;
import org.bukkit.entity.Player;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import static org.junit.Assert.assertEquals; | package com.github.virustotalop.obsidianauctions.test.bukkit.plugin;
public class PapiTest {
@Test
public void testNoImplPapi() {
Player player = Mockito.mock(Player.class); | // Path: src/main/java/com/gmail/virustotalop/obsidianauctions/placeholder/NoPlaceholderImpl.java
// public class NoPlaceholderImpl implements Placeholder {
//
// @Override
// public String replace(Player player, String message) {
// return message;
// }
// }
// Path: src/test/java/com/github/virustotalop/obsidianauctions/test/bukkit/plugin/PapiTest.java
import com.gmail.virustotalop.obsidianauctions.placeholder.NoPlaceholderImpl;
import org.bukkit.entity.Player;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import static org.junit.Assert.assertEquals;
package com.github.virustotalop.obsidianauctions.test.bukkit.plugin;
public class PapiTest {
@Test
public void testNoImplPapi() {
Player player = Mockito.mock(Player.class); | NoPlaceholderImpl papi = new NoPlaceholderImpl(); |
virustotalop/ObsidianAuctions | src/main/java/com/gmail/virustotalop/obsidianauctions/language/LanguageItem.java | // Path: src/main/java/com/gmail/virustotalop/obsidianauctions/nbt/NBTCompound.java
// public class NBTCompound {
//
// private static final String version;
//
// private static Class<?> compoundClass;
//
// private static Method parse;
// private static Method getKeys;
// private static Method get;
//
// static {
// version = VersionUtil.getVersion();
// try {
// Class<?> parser = findParserClass();
// parse = parser.getDeclaredMethod("parse", String.class);
// compoundClass = findCompoundClass();
// for (Method method : compoundClass.getDeclaredMethods()) {
// if (method.getReturnType().equals(Set.class)) {
// getKeys = method;
// break;
// }
// }
// get = compoundClass.getDeclaredMethod("get", String.class);
// } catch (NoSuchMethodException e) {
// e.printStackTrace();
// }
// }
//
// private static Class<?> findCompoundClass() {
// try {
// return Class.forName("net.minecraft.server." + version + ".NBTTagCompound");
// } catch (ClassNotFoundException ex) {
// try {
// return Class.forName("net.minecraft.nbt.NBTTagCompound");
// } catch (ClassNotFoundException e) {
// return null;
// }
// }
// }
//
// private static Class<?> findParserClass() {
// try {
// return Class.forName("net.minecraft.server." + version + ".MojangsonParser");
// } catch (ClassNotFoundException ex) {
// try {
// return Class.forName("net.minecraft.nbt.MojangsonParser");
// } catch (ClassNotFoundException e) {
// return null;
// }
// }
// }
//
// public static boolean isCompound(Object compound) {
// if (compound == null) {
// return false;
// }
// return compound.getClass().equals(compoundClass);
// }
//
// public static boolean fuzzyMatches(NBTCompound compare, NBTCompound compound) {
// for (String key : compare.getKeys()) {
// Object get = compound.get(key);
// if (get == null) {
// return false;
// } else if (isCompound(get)) {
// Object compareCompound = compare.get(key);
// if (!isCompound(compareCompound)) {
// return false;
// }
// return fuzzyMatches(new NBTCompound(compareCompound), new NBTCompound(get));
// } else if (!compare.get(key).equals(compound.get(key))) {
// return false;
// }
// }
// return true;
// }
//
// private final Object inner;
//
// public NBTCompound(Object compound) {
// this.inner = isCompound(compound) ? compound : null;
// }
//
// public NBTCompound(String json) throws Exception {
// this.inner = this.parseNBTCompoundFromJson(json);
// }
//
// public NBTCompound(ItemStack itemStack) {
// this.inner = this.retrieveNBTCompoundFromItem(itemStack);
// }
//
// public Object getNMSCompound() {
// return this.inner;
// }
//
// public Set<String> getKeys() {
// try {
// return (Set<String>) getKeys.invoke(this.inner);
// } catch (InvocationTargetException | IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// public boolean hasKey(String key) {
// return this.getKeys().contains(key);
// }
//
// public Object get(String key) {
// try {
// if (!this.hasKey(key)) {
// return null;
// }
// return get.invoke(this.inner, key);
// } catch (IllegalAccessException | InvocationTargetException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// private Object parseNBTCompoundFromJson(String json) throws Exception {
// return parse.invoke(null, json);
// }
//
// private Object retrieveNBTCompoundFromItem(ItemStack itemStack) {
// try {
// Class<?> craftItemStack = Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftItemStack");
// Method asCraftCopy = craftItemStack.getMethod("asCraftCopy", ItemStack.class);
// Method asNMSCopy = craftItemStack.getMethod("asNMSCopy", ItemStack.class);
// Object craftCopy = asCraftCopy.invoke(null, itemStack);
// Object nmsStack = asNMSCopy.invoke(null, craftCopy);
// Method tagField = nmsStack.getClass().getMethod("getTag");
// return tagField.invoke(nmsStack);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public String toString() {
// return "NBTCompound{" +
// "inner=" + this.inner +
// '}';
// }
// }
//
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/LegacyUtil.java
// @ApiStatus.Internal
// public final class LegacyUtil {
//
// private static final boolean durabilityExists = methodExists(ItemStack.class, "getDurability");
// private static final boolean mainHandExists = methodExists(PlayerInventory.class, "getItemInMainHand");
//
// public static short getDurability(ItemStack itemStack) {
// if (durabilityExists) {
// return itemStack.getDurability();
// }
// return 0;
// }
//
// public static ItemStack getItemInMainHand(Player player) {
// if (mainHandExists) {
// return player.getInventory().getItemInMainHand();
// }
// return player.getItemInHand();
// }
//
// private static boolean methodExists(Class<?> clazz, String methodName) {
// for (Method method : clazz.getDeclaredMethods()) {
// if (method.getName().equals(methodName)) {
// return true;
// }
// }
// return false;
// }
// }
| import com.gmail.virustotalop.obsidianauctions.nbt.NBTCompound;
import com.gmail.virustotalop.obsidianauctions.util.LegacyUtil;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.ApiStatus; | package com.gmail.virustotalop.obsidianauctions.language;
@ApiStatus.Internal
public class LanguageItem {
private final Material type;
private final short durability; | // Path: src/main/java/com/gmail/virustotalop/obsidianauctions/nbt/NBTCompound.java
// public class NBTCompound {
//
// private static final String version;
//
// private static Class<?> compoundClass;
//
// private static Method parse;
// private static Method getKeys;
// private static Method get;
//
// static {
// version = VersionUtil.getVersion();
// try {
// Class<?> parser = findParserClass();
// parse = parser.getDeclaredMethod("parse", String.class);
// compoundClass = findCompoundClass();
// for (Method method : compoundClass.getDeclaredMethods()) {
// if (method.getReturnType().equals(Set.class)) {
// getKeys = method;
// break;
// }
// }
// get = compoundClass.getDeclaredMethod("get", String.class);
// } catch (NoSuchMethodException e) {
// e.printStackTrace();
// }
// }
//
// private static Class<?> findCompoundClass() {
// try {
// return Class.forName("net.minecraft.server." + version + ".NBTTagCompound");
// } catch (ClassNotFoundException ex) {
// try {
// return Class.forName("net.minecraft.nbt.NBTTagCompound");
// } catch (ClassNotFoundException e) {
// return null;
// }
// }
// }
//
// private static Class<?> findParserClass() {
// try {
// return Class.forName("net.minecraft.server." + version + ".MojangsonParser");
// } catch (ClassNotFoundException ex) {
// try {
// return Class.forName("net.minecraft.nbt.MojangsonParser");
// } catch (ClassNotFoundException e) {
// return null;
// }
// }
// }
//
// public static boolean isCompound(Object compound) {
// if (compound == null) {
// return false;
// }
// return compound.getClass().equals(compoundClass);
// }
//
// public static boolean fuzzyMatches(NBTCompound compare, NBTCompound compound) {
// for (String key : compare.getKeys()) {
// Object get = compound.get(key);
// if (get == null) {
// return false;
// } else if (isCompound(get)) {
// Object compareCompound = compare.get(key);
// if (!isCompound(compareCompound)) {
// return false;
// }
// return fuzzyMatches(new NBTCompound(compareCompound), new NBTCompound(get));
// } else if (!compare.get(key).equals(compound.get(key))) {
// return false;
// }
// }
// return true;
// }
//
// private final Object inner;
//
// public NBTCompound(Object compound) {
// this.inner = isCompound(compound) ? compound : null;
// }
//
// public NBTCompound(String json) throws Exception {
// this.inner = this.parseNBTCompoundFromJson(json);
// }
//
// public NBTCompound(ItemStack itemStack) {
// this.inner = this.retrieveNBTCompoundFromItem(itemStack);
// }
//
// public Object getNMSCompound() {
// return this.inner;
// }
//
// public Set<String> getKeys() {
// try {
// return (Set<String>) getKeys.invoke(this.inner);
// } catch (InvocationTargetException | IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// public boolean hasKey(String key) {
// return this.getKeys().contains(key);
// }
//
// public Object get(String key) {
// try {
// if (!this.hasKey(key)) {
// return null;
// }
// return get.invoke(this.inner, key);
// } catch (IllegalAccessException | InvocationTargetException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// private Object parseNBTCompoundFromJson(String json) throws Exception {
// return parse.invoke(null, json);
// }
//
// private Object retrieveNBTCompoundFromItem(ItemStack itemStack) {
// try {
// Class<?> craftItemStack = Class.forName("org.bukkit.craftbukkit." + version + ".inventory.CraftItemStack");
// Method asCraftCopy = craftItemStack.getMethod("asCraftCopy", ItemStack.class);
// Method asNMSCopy = craftItemStack.getMethod("asNMSCopy", ItemStack.class);
// Object craftCopy = asCraftCopy.invoke(null, itemStack);
// Object nmsStack = asNMSCopy.invoke(null, craftCopy);
// Method tagField = nmsStack.getClass().getMethod("getTag");
// return tagField.invoke(nmsStack);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public String toString() {
// return "NBTCompound{" +
// "inner=" + this.inner +
// '}';
// }
// }
//
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/util/LegacyUtil.java
// @ApiStatus.Internal
// public final class LegacyUtil {
//
// private static final boolean durabilityExists = methodExists(ItemStack.class, "getDurability");
// private static final boolean mainHandExists = methodExists(PlayerInventory.class, "getItemInMainHand");
//
// public static short getDurability(ItemStack itemStack) {
// if (durabilityExists) {
// return itemStack.getDurability();
// }
// return 0;
// }
//
// public static ItemStack getItemInMainHand(Player player) {
// if (mainHandExists) {
// return player.getInventory().getItemInMainHand();
// }
// return player.getItemInHand();
// }
//
// private static boolean methodExists(Class<?> clazz, String methodName) {
// for (Method method : clazz.getDeclaredMethods()) {
// if (method.getName().equals(methodName)) {
// return true;
// }
// }
// return false;
// }
// }
// Path: src/main/java/com/gmail/virustotalop/obsidianauctions/language/LanguageItem.java
import com.gmail.virustotalop.obsidianauctions.nbt.NBTCompound;
import com.gmail.virustotalop.obsidianauctions.util.LegacyUtil;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.ApiStatus;
package com.gmail.virustotalop.obsidianauctions.language;
@ApiStatus.Internal
public class LanguageItem {
private final Material type;
private final short durability; | private final NBTCompound compound; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.