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 |
|---|---|---|---|---|---|---|
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/indexers/IndexerTest.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/Env.java
// public class Env {
// public final static Env instance = new Env();
//
// private Map<String, String> properties = Maps.newHashMap();
//
// public Optional<String> get(String key) {
// return Optional.ofNullable(properties.getOrDefault(key, System.getenv(key)));
// }
//
// public Env register(String key, String value) {
// properties.put(key, value);
//
// return this;
// }
// }
//
// Path: src/test/java/com/coding4people/mosquitoreport/api/WithService.java
// abstract public class WithService implements BaseTest {
// @Before
// public void initialize() {
// MockitoAnnotations.initMocks(this);
// }
//
// protected ResourceConfig configure() {
// return new Config().configureFramework().register(new MockBinder(this));
// }
//
// protected <T> T getService(Class<T> clazz) {
// return new ApplicationHandler(configure().register(new GenericBinder<T>() {
// public Class<T> getType() {
// return clazz;
// }
// })).getServiceLocator().getService(clazz);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Searchable.java
// public interface Searchable {
// public String getSearchId();
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.ExecutorService;
import javax.inject.Inject;
import org.glassfish.hk2.api.MultiException;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomain;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient;
import com.amazonaws.services.cloudsearchdomain.model.Hit;
import com.amazonaws.services.cloudsearchdomain.model.Hits;
import com.amazonaws.services.cloudsearchdomain.model.SearchRequest;
import com.amazonaws.services.cloudsearchdomain.model.SearchResult;
import com.amazonaws.services.cloudsearchdomain.model.UploadDocumentsRequest;
import com.amazonaws.services.cloudsearchv2.AmazonCloudSearch;
import com.amazonaws.services.cloudsearchv2.model.DescribeDomainsResult;
import com.amazonaws.services.cloudsearchv2.model.DomainStatus;
import com.amazonaws.services.cloudsearchv2.model.ServiceEndpoint;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
import com.coding4people.mosquitoreport.api.Env;
import com.coding4people.mosquitoreport.api.WithService;
import com.coding4people.mosquitoreport.api.models.Searchable;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import jersey.repackaged.com.google.common.collect.Lists;
import jersey.repackaged.com.google.common.collect.Maps; | @Test
public void testIndexJsonProcessingException() throws Exception {
when(amazonCloudSearch.describeDomains(any())).thenReturn(new DescribeDomainsResult()
.withDomainStatusList(Lists.newArrayList(new DomainStatus().withSearchService(new ServiceEndpoint().withEndpoint("http://localhost")))));
Model model = new Model();
model.setGuid("00000000-0000-0000-0000-000000000000");
ArgumentCaptor<Runnable> runnableCaptor = ArgumentCaptor.forClass(Runnable.class);
getService(ModelIndexer.class).index(Lists.newArrayList(model));
verify(executor).submit(runnableCaptor.capture());
when(objectMapper.writeValueAsString(any())).thenThrow(new StubJsonProcessingException());
runnableCaptor.getValue().run();
verify(domain, never()).uploadDocuments(any());
}
public static class StubJsonProcessingException extends JsonProcessingException {
private static final long serialVersionUID = -3023763421872884564L;
public StubJsonProcessingException() {
super("");
}
}
@DynamoDBTable(tableName = "model") | // Path: src/main/java/com/coding4people/mosquitoreport/api/Env.java
// public class Env {
// public final static Env instance = new Env();
//
// private Map<String, String> properties = Maps.newHashMap();
//
// public Optional<String> get(String key) {
// return Optional.ofNullable(properties.getOrDefault(key, System.getenv(key)));
// }
//
// public Env register(String key, String value) {
// properties.put(key, value);
//
// return this;
// }
// }
//
// Path: src/test/java/com/coding4people/mosquitoreport/api/WithService.java
// abstract public class WithService implements BaseTest {
// @Before
// public void initialize() {
// MockitoAnnotations.initMocks(this);
// }
//
// protected ResourceConfig configure() {
// return new Config().configureFramework().register(new MockBinder(this));
// }
//
// protected <T> T getService(Class<T> clazz) {
// return new ApplicationHandler(configure().register(new GenericBinder<T>() {
// public Class<T> getType() {
// return clazz;
// }
// })).getServiceLocator().getService(clazz);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Searchable.java
// public interface Searchable {
// public String getSearchId();
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/indexers/IndexerTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.ExecutorService;
import javax.inject.Inject;
import org.glassfish.hk2.api.MultiException;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomain;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient;
import com.amazonaws.services.cloudsearchdomain.model.Hit;
import com.amazonaws.services.cloudsearchdomain.model.Hits;
import com.amazonaws.services.cloudsearchdomain.model.SearchRequest;
import com.amazonaws.services.cloudsearchdomain.model.SearchResult;
import com.amazonaws.services.cloudsearchdomain.model.UploadDocumentsRequest;
import com.amazonaws.services.cloudsearchv2.AmazonCloudSearch;
import com.amazonaws.services.cloudsearchv2.model.DescribeDomainsResult;
import com.amazonaws.services.cloudsearchv2.model.DomainStatus;
import com.amazonaws.services.cloudsearchv2.model.ServiceEndpoint;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
import com.coding4people.mosquitoreport.api.Env;
import com.coding4people.mosquitoreport.api.WithService;
import com.coding4people.mosquitoreport.api.models.Searchable;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import jersey.repackaged.com.google.common.collect.Lists;
import jersey.repackaged.com.google.common.collect.Maps;
@Test
public void testIndexJsonProcessingException() throws Exception {
when(amazonCloudSearch.describeDomains(any())).thenReturn(new DescribeDomainsResult()
.withDomainStatusList(Lists.newArrayList(new DomainStatus().withSearchService(new ServiceEndpoint().withEndpoint("http://localhost")))));
Model model = new Model();
model.setGuid("00000000-0000-0000-0000-000000000000");
ArgumentCaptor<Runnable> runnableCaptor = ArgumentCaptor.forClass(Runnable.class);
getService(ModelIndexer.class).index(Lists.newArrayList(model));
verify(executor).submit(runnableCaptor.capture());
when(objectMapper.writeValueAsString(any())).thenThrow(new StubJsonProcessingException());
runnableCaptor.getValue().run();
verify(domain, never()).uploadDocuments(any());
}
public static class StubJsonProcessingException extends JsonProcessingException {
private static final long serialVersionUID = -3023763421872884564L;
public StubJsonProcessingException() {
super("");
}
}
@DynamoDBTable(tableName = "model") | public static class Model implements Searchable { |
coding4people/mosquito-report-api | src/main/java/com/coding4people/mosquitoreport/api/controllers/FocusController.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/indexers/FocusIndexer.java
// @Singleton
// public class FocusIndexer extends Indexer<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Focus.java
// @DynamoDBTable(tableName = "focus")
// public class Focus implements Searchable {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String createdat;
//
// @DynamoDBAttribute
// private String latlon;
//
// @DynamoDBAttribute
// private String notes;
//
// @DynamoDBAttribute
// private Integer thumbsup;
//
// @DynamoDBAttribute
// private String authoruserguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getCreatedat() {
// return createdat;
// }
//
// public void setCreatedat(String createdat) {
// this.createdat = createdat;
// }
//
// public String getLatlon() {
// return latlon;
// }
//
// public void setLatlon(String latLon) {
// this.latlon = latLon;
// }
//
// public String getNotes() {
// return notes;
// }
//
// public void setNotes(String notes) {
// this.notes = notes;
// }
//
// public Integer getThumbsup() {
// return thumbsup;
// }
//
// public void setThumbsup(Integer thumbsup) {
// this.thumbsup = thumbsup;
// }
//
// @JsonIgnore
// @DynamoDBIgnore
// public Focus thumbsup() {
// thumbsup += 1;
//
// return this;
// }
//
// public String getAuthoruserguid() {
// return authoruserguid;
// }
//
// public void setAuthoruserguid(String authoruserguid) {
// this.authoruserguid = authoruserguid;
// }
//
// @Override
// @JsonIgnore
// @DynamoDBIgnore
// public String getSearchId() {
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/FocusRepository.java
// @Singleton
// public class FocusRepository extends Repository<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
| import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import com.coding4people.mosquitoreport.api.indexers.FocusIndexer;
import com.coding4people.mosquitoreport.api.models.Focus;
import com.coding4people.mosquitoreport.api.repositories.FocusRepository;
| package com.coding4people.mosquitoreport.api.controllers;
@Path("/focus")
public class FocusController {
| // Path: src/main/java/com/coding4people/mosquitoreport/api/indexers/FocusIndexer.java
// @Singleton
// public class FocusIndexer extends Indexer<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Focus.java
// @DynamoDBTable(tableName = "focus")
// public class Focus implements Searchable {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String createdat;
//
// @DynamoDBAttribute
// private String latlon;
//
// @DynamoDBAttribute
// private String notes;
//
// @DynamoDBAttribute
// private Integer thumbsup;
//
// @DynamoDBAttribute
// private String authoruserguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getCreatedat() {
// return createdat;
// }
//
// public void setCreatedat(String createdat) {
// this.createdat = createdat;
// }
//
// public String getLatlon() {
// return latlon;
// }
//
// public void setLatlon(String latLon) {
// this.latlon = latLon;
// }
//
// public String getNotes() {
// return notes;
// }
//
// public void setNotes(String notes) {
// this.notes = notes;
// }
//
// public Integer getThumbsup() {
// return thumbsup;
// }
//
// public void setThumbsup(Integer thumbsup) {
// this.thumbsup = thumbsup;
// }
//
// @JsonIgnore
// @DynamoDBIgnore
// public Focus thumbsup() {
// thumbsup += 1;
//
// return this;
// }
//
// public String getAuthoruserguid() {
// return authoruserguid;
// }
//
// public void setAuthoruserguid(String authoruserguid) {
// this.authoruserguid = authoruserguid;
// }
//
// @Override
// @JsonIgnore
// @DynamoDBIgnore
// public String getSearchId() {
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/FocusRepository.java
// @Singleton
// public class FocusRepository extends Repository<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/FocusController.java
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import com.coding4people.mosquitoreport.api.indexers.FocusIndexer;
import com.coding4people.mosquitoreport.api.models.Focus;
import com.coding4people.mosquitoreport.api.repositories.FocusRepository;
package com.coding4people.mosquitoreport.api.controllers;
@Path("/focus")
public class FocusController {
| @Inject FocusIndexer focusIndexer;
|
coding4people/mosquito-report-api | src/main/java/com/coding4people/mosquitoreport/api/controllers/FocusController.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/indexers/FocusIndexer.java
// @Singleton
// public class FocusIndexer extends Indexer<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Focus.java
// @DynamoDBTable(tableName = "focus")
// public class Focus implements Searchable {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String createdat;
//
// @DynamoDBAttribute
// private String latlon;
//
// @DynamoDBAttribute
// private String notes;
//
// @DynamoDBAttribute
// private Integer thumbsup;
//
// @DynamoDBAttribute
// private String authoruserguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getCreatedat() {
// return createdat;
// }
//
// public void setCreatedat(String createdat) {
// this.createdat = createdat;
// }
//
// public String getLatlon() {
// return latlon;
// }
//
// public void setLatlon(String latLon) {
// this.latlon = latLon;
// }
//
// public String getNotes() {
// return notes;
// }
//
// public void setNotes(String notes) {
// this.notes = notes;
// }
//
// public Integer getThumbsup() {
// return thumbsup;
// }
//
// public void setThumbsup(Integer thumbsup) {
// this.thumbsup = thumbsup;
// }
//
// @JsonIgnore
// @DynamoDBIgnore
// public Focus thumbsup() {
// thumbsup += 1;
//
// return this;
// }
//
// public String getAuthoruserguid() {
// return authoruserguid;
// }
//
// public void setAuthoruserguid(String authoruserguid) {
// this.authoruserguid = authoruserguid;
// }
//
// @Override
// @JsonIgnore
// @DynamoDBIgnore
// public String getSearchId() {
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/FocusRepository.java
// @Singleton
// public class FocusRepository extends Repository<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
| import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import com.coding4people.mosquitoreport.api.indexers.FocusIndexer;
import com.coding4people.mosquitoreport.api.models.Focus;
import com.coding4people.mosquitoreport.api.repositories.FocusRepository;
| package com.coding4people.mosquitoreport.api.controllers;
@Path("/focus")
public class FocusController {
@Inject FocusIndexer focusIndexer;
| // Path: src/main/java/com/coding4people/mosquitoreport/api/indexers/FocusIndexer.java
// @Singleton
// public class FocusIndexer extends Indexer<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Focus.java
// @DynamoDBTable(tableName = "focus")
// public class Focus implements Searchable {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String createdat;
//
// @DynamoDBAttribute
// private String latlon;
//
// @DynamoDBAttribute
// private String notes;
//
// @DynamoDBAttribute
// private Integer thumbsup;
//
// @DynamoDBAttribute
// private String authoruserguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getCreatedat() {
// return createdat;
// }
//
// public void setCreatedat(String createdat) {
// this.createdat = createdat;
// }
//
// public String getLatlon() {
// return latlon;
// }
//
// public void setLatlon(String latLon) {
// this.latlon = latLon;
// }
//
// public String getNotes() {
// return notes;
// }
//
// public void setNotes(String notes) {
// this.notes = notes;
// }
//
// public Integer getThumbsup() {
// return thumbsup;
// }
//
// public void setThumbsup(Integer thumbsup) {
// this.thumbsup = thumbsup;
// }
//
// @JsonIgnore
// @DynamoDBIgnore
// public Focus thumbsup() {
// thumbsup += 1;
//
// return this;
// }
//
// public String getAuthoruserguid() {
// return authoruserguid;
// }
//
// public void setAuthoruserguid(String authoruserguid) {
// this.authoruserguid = authoruserguid;
// }
//
// @Override
// @JsonIgnore
// @DynamoDBIgnore
// public String getSearchId() {
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/FocusRepository.java
// @Singleton
// public class FocusRepository extends Repository<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/FocusController.java
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import com.coding4people.mosquitoreport.api.indexers.FocusIndexer;
import com.coding4people.mosquitoreport.api.models.Focus;
import com.coding4people.mosquitoreport.api.repositories.FocusRepository;
package com.coding4people.mosquitoreport.api.controllers;
@Path("/focus")
public class FocusController {
@Inject FocusIndexer focusIndexer;
| @Inject FocusRepository focusRepository;
|
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/model/FocusTest.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/Focus.java
// @DynamoDBTable(tableName = "focus")
// public class Focus implements Searchable {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String createdat;
//
// @DynamoDBAttribute
// private String latlon;
//
// @DynamoDBAttribute
// private String notes;
//
// @DynamoDBAttribute
// private Integer thumbsup;
//
// @DynamoDBAttribute
// private String authoruserguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getCreatedat() {
// return createdat;
// }
//
// public void setCreatedat(String createdat) {
// this.createdat = createdat;
// }
//
// public String getLatlon() {
// return latlon;
// }
//
// public void setLatlon(String latLon) {
// this.latlon = latLon;
// }
//
// public String getNotes() {
// return notes;
// }
//
// public void setNotes(String notes) {
// this.notes = notes;
// }
//
// public Integer getThumbsup() {
// return thumbsup;
// }
//
// public void setThumbsup(Integer thumbsup) {
// this.thumbsup = thumbsup;
// }
//
// @JsonIgnore
// @DynamoDBIgnore
// public Focus thumbsup() {
// thumbsup += 1;
//
// return this;
// }
//
// public String getAuthoruserguid() {
// return authoruserguid;
// }
//
// public void setAuthoruserguid(String authoruserguid) {
// this.authoruserguid = authoruserguid;
// }
//
// @Override
// @JsonIgnore
// @DynamoDBIgnore
// public String getSearchId() {
// return guid;
// }
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.coding4people.mosquitoreport.api.models.Focus; | package com.coding4people.mosquitoreport.api.model;
public class FocusTest {
@Test
public void testGetSearchId() { | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/Focus.java
// @DynamoDBTable(tableName = "focus")
// public class Focus implements Searchable {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String createdat;
//
// @DynamoDBAttribute
// private String latlon;
//
// @DynamoDBAttribute
// private String notes;
//
// @DynamoDBAttribute
// private Integer thumbsup;
//
// @DynamoDBAttribute
// private String authoruserguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getCreatedat() {
// return createdat;
// }
//
// public void setCreatedat(String createdat) {
// this.createdat = createdat;
// }
//
// public String getLatlon() {
// return latlon;
// }
//
// public void setLatlon(String latLon) {
// this.latlon = latLon;
// }
//
// public String getNotes() {
// return notes;
// }
//
// public void setNotes(String notes) {
// this.notes = notes;
// }
//
// public Integer getThumbsup() {
// return thumbsup;
// }
//
// public void setThumbsup(Integer thumbsup) {
// this.thumbsup = thumbsup;
// }
//
// @JsonIgnore
// @DynamoDBIgnore
// public Focus thumbsup() {
// thumbsup += 1;
//
// return this;
// }
//
// public String getAuthoruserguid() {
// return authoruserguid;
// }
//
// public void setAuthoruserguid(String authoruserguid) {
// this.authoruserguid = authoruserguid;
// }
//
// @Override
// @JsonIgnore
// @DynamoDBIgnore
// public String getSearchId() {
// return guid;
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/model/FocusTest.java
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.coding4people.mosquitoreport.api.models.Focus;
package com.coding4people.mosquitoreport.api.model;
public class FocusTest {
@Test
public void testGetSearchId() { | Focus focus = new Focus(); |
coding4people/mosquito-report-api | src/main/java/com/coding4people/mosquitoreport/api/controllers/SignUpController.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/EmailRepository.java
// @Singleton
// public class EmailRepository extends Repository<Email> {
// @Override
// protected Class<Email> getType() {
// return Email.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/UserRepository.java
// @Singleton
// public class UserRepository extends Repository<User> {
// @Override
// protected Class<User> getType() {
// return User.class;
// }
// }
| import java.util.UUID;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import com.coding4people.mosquitoreport.api.models.Email;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.EmailRepository;
import com.coding4people.mosquitoreport.api.repositories.UserRepository;
| package com.coding4people.mosquitoreport.api.controllers;
@Path("/signup/email")
public class SignUpController {
| // Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/EmailRepository.java
// @Singleton
// public class EmailRepository extends Repository<Email> {
// @Override
// protected Class<Email> getType() {
// return Email.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/UserRepository.java
// @Singleton
// public class UserRepository extends Repository<User> {
// @Override
// protected Class<User> getType() {
// return User.class;
// }
// }
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/SignUpController.java
import java.util.UUID;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import com.coding4people.mosquitoreport.api.models.Email;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.EmailRepository;
import com.coding4people.mosquitoreport.api.repositories.UserRepository;
package com.coding4people.mosquitoreport.api.controllers;
@Path("/signup/email")
public class SignUpController {
| @Inject EmailRepository emailRepository;
|
coding4people/mosquito-report-api | src/main/java/com/coding4people/mosquitoreport/api/controllers/SignUpController.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/EmailRepository.java
// @Singleton
// public class EmailRepository extends Repository<Email> {
// @Override
// protected Class<Email> getType() {
// return Email.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/UserRepository.java
// @Singleton
// public class UserRepository extends Repository<User> {
// @Override
// protected Class<User> getType() {
// return User.class;
// }
// }
| import java.util.UUID;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import com.coding4people.mosquitoreport.api.models.Email;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.EmailRepository;
import com.coding4people.mosquitoreport.api.repositories.UserRepository;
| package com.coding4people.mosquitoreport.api.controllers;
@Path("/signup/email")
public class SignUpController {
@Inject EmailRepository emailRepository;
| // Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/EmailRepository.java
// @Singleton
// public class EmailRepository extends Repository<Email> {
// @Override
// protected Class<Email> getType() {
// return Email.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/UserRepository.java
// @Singleton
// public class UserRepository extends Repository<User> {
// @Override
// protected Class<User> getType() {
// return User.class;
// }
// }
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/SignUpController.java
import java.util.UUID;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import com.coding4people.mosquitoreport.api.models.Email;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.EmailRepository;
import com.coding4people.mosquitoreport.api.repositories.UserRepository;
package com.coding4people.mosquitoreport.api.controllers;
@Path("/signup/email")
public class SignUpController {
@Inject EmailRepository emailRepository;
| @Inject UserRepository userRepository;
|
coding4people/mosquito-report-api | src/main/java/com/coding4people/mosquitoreport/api/controllers/PostFocusController.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/indexers/FocusIndexer.java
// @Singleton
// public class FocusIndexer extends Indexer<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Focus.java
// @DynamoDBTable(tableName = "focus")
// public class Focus implements Searchable {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String createdat;
//
// @DynamoDBAttribute
// private String latlon;
//
// @DynamoDBAttribute
// private String notes;
//
// @DynamoDBAttribute
// private Integer thumbsup;
//
// @DynamoDBAttribute
// private String authoruserguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getCreatedat() {
// return createdat;
// }
//
// public void setCreatedat(String createdat) {
// this.createdat = createdat;
// }
//
// public String getLatlon() {
// return latlon;
// }
//
// public void setLatlon(String latLon) {
// this.latlon = latLon;
// }
//
// public String getNotes() {
// return notes;
// }
//
// public void setNotes(String notes) {
// this.notes = notes;
// }
//
// public Integer getThumbsup() {
// return thumbsup;
// }
//
// public void setThumbsup(Integer thumbsup) {
// this.thumbsup = thumbsup;
// }
//
// @JsonIgnore
// @DynamoDBIgnore
// public Focus thumbsup() {
// thumbsup += 1;
//
// return this;
// }
//
// public String getAuthoruserguid() {
// return authoruserguid;
// }
//
// public void setAuthoruserguid(String authoruserguid) {
// this.authoruserguid = authoruserguid;
// }
//
// @Override
// @JsonIgnore
// @DynamoDBIgnore
// public String getSearchId() {
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/FocusRepository.java
// @Singleton
// public class FocusRepository extends Repository<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
| import java.util.Date;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import com.coding4people.mosquitoreport.api.indexers.FocusIndexer;
import com.coding4people.mosquitoreport.api.models.Focus;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.FocusRepository;
| package com.coding4people.mosquitoreport.api.controllers;
@Path("/focus")
public class PostFocusController {
@Inject
| // Path: src/main/java/com/coding4people/mosquitoreport/api/indexers/FocusIndexer.java
// @Singleton
// public class FocusIndexer extends Indexer<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Focus.java
// @DynamoDBTable(tableName = "focus")
// public class Focus implements Searchable {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String createdat;
//
// @DynamoDBAttribute
// private String latlon;
//
// @DynamoDBAttribute
// private String notes;
//
// @DynamoDBAttribute
// private Integer thumbsup;
//
// @DynamoDBAttribute
// private String authoruserguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getCreatedat() {
// return createdat;
// }
//
// public void setCreatedat(String createdat) {
// this.createdat = createdat;
// }
//
// public String getLatlon() {
// return latlon;
// }
//
// public void setLatlon(String latLon) {
// this.latlon = latLon;
// }
//
// public String getNotes() {
// return notes;
// }
//
// public void setNotes(String notes) {
// this.notes = notes;
// }
//
// public Integer getThumbsup() {
// return thumbsup;
// }
//
// public void setThumbsup(Integer thumbsup) {
// this.thumbsup = thumbsup;
// }
//
// @JsonIgnore
// @DynamoDBIgnore
// public Focus thumbsup() {
// thumbsup += 1;
//
// return this;
// }
//
// public String getAuthoruserguid() {
// return authoruserguid;
// }
//
// public void setAuthoruserguid(String authoruserguid) {
// this.authoruserguid = authoruserguid;
// }
//
// @Override
// @JsonIgnore
// @DynamoDBIgnore
// public String getSearchId() {
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/FocusRepository.java
// @Singleton
// public class FocusRepository extends Repository<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/PostFocusController.java
import java.util.Date;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import com.coding4people.mosquitoreport.api.indexers.FocusIndexer;
import com.coding4people.mosquitoreport.api.models.Focus;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.FocusRepository;
package com.coding4people.mosquitoreport.api.controllers;
@Path("/focus")
public class PostFocusController {
@Inject
| FocusRepository focusRepository;
|
coding4people/mosquito-report-api | src/main/java/com/coding4people/mosquitoreport/api/controllers/PostFocusController.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/indexers/FocusIndexer.java
// @Singleton
// public class FocusIndexer extends Indexer<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Focus.java
// @DynamoDBTable(tableName = "focus")
// public class Focus implements Searchable {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String createdat;
//
// @DynamoDBAttribute
// private String latlon;
//
// @DynamoDBAttribute
// private String notes;
//
// @DynamoDBAttribute
// private Integer thumbsup;
//
// @DynamoDBAttribute
// private String authoruserguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getCreatedat() {
// return createdat;
// }
//
// public void setCreatedat(String createdat) {
// this.createdat = createdat;
// }
//
// public String getLatlon() {
// return latlon;
// }
//
// public void setLatlon(String latLon) {
// this.latlon = latLon;
// }
//
// public String getNotes() {
// return notes;
// }
//
// public void setNotes(String notes) {
// this.notes = notes;
// }
//
// public Integer getThumbsup() {
// return thumbsup;
// }
//
// public void setThumbsup(Integer thumbsup) {
// this.thumbsup = thumbsup;
// }
//
// @JsonIgnore
// @DynamoDBIgnore
// public Focus thumbsup() {
// thumbsup += 1;
//
// return this;
// }
//
// public String getAuthoruserguid() {
// return authoruserguid;
// }
//
// public void setAuthoruserguid(String authoruserguid) {
// this.authoruserguid = authoruserguid;
// }
//
// @Override
// @JsonIgnore
// @DynamoDBIgnore
// public String getSearchId() {
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/FocusRepository.java
// @Singleton
// public class FocusRepository extends Repository<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
| import java.util.Date;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import com.coding4people.mosquitoreport.api.indexers.FocusIndexer;
import com.coding4people.mosquitoreport.api.models.Focus;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.FocusRepository;
| package com.coding4people.mosquitoreport.api.controllers;
@Path("/focus")
public class PostFocusController {
@Inject
FocusRepository focusRepository;
@Inject
| // Path: src/main/java/com/coding4people/mosquitoreport/api/indexers/FocusIndexer.java
// @Singleton
// public class FocusIndexer extends Indexer<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Focus.java
// @DynamoDBTable(tableName = "focus")
// public class Focus implements Searchable {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String createdat;
//
// @DynamoDBAttribute
// private String latlon;
//
// @DynamoDBAttribute
// private String notes;
//
// @DynamoDBAttribute
// private Integer thumbsup;
//
// @DynamoDBAttribute
// private String authoruserguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getCreatedat() {
// return createdat;
// }
//
// public void setCreatedat(String createdat) {
// this.createdat = createdat;
// }
//
// public String getLatlon() {
// return latlon;
// }
//
// public void setLatlon(String latLon) {
// this.latlon = latLon;
// }
//
// public String getNotes() {
// return notes;
// }
//
// public void setNotes(String notes) {
// this.notes = notes;
// }
//
// public Integer getThumbsup() {
// return thumbsup;
// }
//
// public void setThumbsup(Integer thumbsup) {
// this.thumbsup = thumbsup;
// }
//
// @JsonIgnore
// @DynamoDBIgnore
// public Focus thumbsup() {
// thumbsup += 1;
//
// return this;
// }
//
// public String getAuthoruserguid() {
// return authoruserguid;
// }
//
// public void setAuthoruserguid(String authoruserguid) {
// this.authoruserguid = authoruserguid;
// }
//
// @Override
// @JsonIgnore
// @DynamoDBIgnore
// public String getSearchId() {
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/FocusRepository.java
// @Singleton
// public class FocusRepository extends Repository<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/PostFocusController.java
import java.util.Date;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import com.coding4people.mosquitoreport.api.indexers.FocusIndexer;
import com.coding4people.mosquitoreport.api.models.Focus;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.FocusRepository;
package com.coding4people.mosquitoreport.api.controllers;
@Path("/focus")
public class PostFocusController {
@Inject
FocusRepository focusRepository;
@Inject
| FocusIndexer focusIndexer;
|
coding4people/mosquito-report-api | src/main/java/com/coding4people/mosquitoreport/api/controllers/PostFocusController.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/indexers/FocusIndexer.java
// @Singleton
// public class FocusIndexer extends Indexer<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Focus.java
// @DynamoDBTable(tableName = "focus")
// public class Focus implements Searchable {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String createdat;
//
// @DynamoDBAttribute
// private String latlon;
//
// @DynamoDBAttribute
// private String notes;
//
// @DynamoDBAttribute
// private Integer thumbsup;
//
// @DynamoDBAttribute
// private String authoruserguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getCreatedat() {
// return createdat;
// }
//
// public void setCreatedat(String createdat) {
// this.createdat = createdat;
// }
//
// public String getLatlon() {
// return latlon;
// }
//
// public void setLatlon(String latLon) {
// this.latlon = latLon;
// }
//
// public String getNotes() {
// return notes;
// }
//
// public void setNotes(String notes) {
// this.notes = notes;
// }
//
// public Integer getThumbsup() {
// return thumbsup;
// }
//
// public void setThumbsup(Integer thumbsup) {
// this.thumbsup = thumbsup;
// }
//
// @JsonIgnore
// @DynamoDBIgnore
// public Focus thumbsup() {
// thumbsup += 1;
//
// return this;
// }
//
// public String getAuthoruserguid() {
// return authoruserguid;
// }
//
// public void setAuthoruserguid(String authoruserguid) {
// this.authoruserguid = authoruserguid;
// }
//
// @Override
// @JsonIgnore
// @DynamoDBIgnore
// public String getSearchId() {
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/FocusRepository.java
// @Singleton
// public class FocusRepository extends Repository<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
| import java.util.Date;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import com.coding4people.mosquitoreport.api.indexers.FocusIndexer;
import com.coding4people.mosquitoreport.api.models.Focus;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.FocusRepository;
| package com.coding4people.mosquitoreport.api.controllers;
@Path("/focus")
public class PostFocusController {
@Inject
FocusRepository focusRepository;
@Inject
FocusIndexer focusIndexer;
@Inject
| // Path: src/main/java/com/coding4people/mosquitoreport/api/indexers/FocusIndexer.java
// @Singleton
// public class FocusIndexer extends Indexer<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Focus.java
// @DynamoDBTable(tableName = "focus")
// public class Focus implements Searchable {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String createdat;
//
// @DynamoDBAttribute
// private String latlon;
//
// @DynamoDBAttribute
// private String notes;
//
// @DynamoDBAttribute
// private Integer thumbsup;
//
// @DynamoDBAttribute
// private String authoruserguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getCreatedat() {
// return createdat;
// }
//
// public void setCreatedat(String createdat) {
// this.createdat = createdat;
// }
//
// public String getLatlon() {
// return latlon;
// }
//
// public void setLatlon(String latLon) {
// this.latlon = latLon;
// }
//
// public String getNotes() {
// return notes;
// }
//
// public void setNotes(String notes) {
// this.notes = notes;
// }
//
// public Integer getThumbsup() {
// return thumbsup;
// }
//
// public void setThumbsup(Integer thumbsup) {
// this.thumbsup = thumbsup;
// }
//
// @JsonIgnore
// @DynamoDBIgnore
// public Focus thumbsup() {
// thumbsup += 1;
//
// return this;
// }
//
// public String getAuthoruserguid() {
// return authoruserguid;
// }
//
// public void setAuthoruserguid(String authoruserguid) {
// this.authoruserguid = authoruserguid;
// }
//
// @Override
// @JsonIgnore
// @DynamoDBIgnore
// public String getSearchId() {
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/FocusRepository.java
// @Singleton
// public class FocusRepository extends Repository<Focus> {
// @Override
// protected Class<Focus> getType() {
// return Focus.class;
// }
// }
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/PostFocusController.java
import java.util.Date;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import com.coding4people.mosquitoreport.api.indexers.FocusIndexer;
import com.coding4people.mosquitoreport.api.models.Focus;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.FocusRepository;
package com.coding4people.mosquitoreport.api.controllers;
@Path("/focus")
public class PostFocusController {
@Inject
FocusRepository focusRepository;
@Inject
FocusIndexer focusIndexer;
@Inject
| User currentUser;
|
coding4people/mosquito-report-api | src/main/java/com/coding4people/mosquitoreport/api/auth/AuthenticationService.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/Env.java
// public class Env {
// public final static Env instance = new Env();
//
// private Map<String, String> properties = Maps.newHashMap();
//
// public Optional<String> get(String key) {
// return Optional.ofNullable(properties.getOrDefault(key, System.getenv(key)));
// }
//
// public Env register(String key, String value) {
// properties.put(key, value);
//
// return this;
// }
// }
| import java.util.Base64;
import javax.inject.Inject;
import javax.ws.rs.ForbiddenException;
import org.mindrot.jbcrypt.BCrypt;
import com.coding4people.mosquitoreport.api.Env; | package com.coding4people.mosquitoreport.api.auth;
public class AuthenticationService {
@Inject | // Path: src/main/java/com/coding4people/mosquitoreport/api/Env.java
// public class Env {
// public final static Env instance = new Env();
//
// private Map<String, String> properties = Maps.newHashMap();
//
// public Optional<String> get(String key) {
// return Optional.ofNullable(properties.getOrDefault(key, System.getenv(key)));
// }
//
// public Env register(String key, String value) {
// properties.put(key, value);
//
// return this;
// }
// }
// Path: src/main/java/com/coding4people/mosquitoreport/api/auth/AuthenticationService.java
import java.util.Base64;
import javax.inject.Inject;
import javax.ws.rs.ForbiddenException;
import org.mindrot.jbcrypt.BCrypt;
import com.coding4people.mosquitoreport.api.Env;
package com.coding4people.mosquitoreport.api.auth;
public class AuthenticationService {
@Inject | Env env; |
coding4people/mosquito-report-api | src/main/java/com/coding4people/mosquitoreport/api/factories/DynamoDBMapperFactory.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/Env.java
// public class Env {
// public final static Env instance = new Env();
//
// private Map<String, String> properties = Maps.newHashMap();
//
// public Optional<String> get(String key) {
// return Optional.ofNullable(properties.getOrDefault(key, System.getenv(key)));
// }
//
// public Env register(String key, String value) {
// properties.put(key, value);
//
// return this;
// }
// }
| import javax.inject.Inject;
import org.glassfish.hk2.api.Factory;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig.TableNameOverride;
import com.coding4people.mosquitoreport.api.Env; | package com.coding4people.mosquitoreport.api.factories;
public class DynamoDBMapperFactory implements Factory<DynamoDBMapper> {
DynamoDBMapper mapper;
@Inject | // Path: src/main/java/com/coding4people/mosquitoreport/api/Env.java
// public class Env {
// public final static Env instance = new Env();
//
// private Map<String, String> properties = Maps.newHashMap();
//
// public Optional<String> get(String key) {
// return Optional.ofNullable(properties.getOrDefault(key, System.getenv(key)));
// }
//
// public Env register(String key, String value) {
// properties.put(key, value);
//
// return this;
// }
// }
// Path: src/main/java/com/coding4people/mosquitoreport/api/factories/DynamoDBMapperFactory.java
import javax.inject.Inject;
import org.glassfish.hk2.api.Factory;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig.TableNameOverride;
import com.coding4people.mosquitoreport.api.Env;
package com.coding4people.mosquitoreport.api.factories;
public class DynamoDBMapperFactory implements Factory<DynamoDBMapper> {
DynamoDBMapper mapper;
@Inject | public DynamoDBMapperFactory(AmazonDynamoDB client, Env env) { |
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/repositories/FacebookUserRepositoryTest.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/FacebookUser.java
// @DynamoDBTable(tableName = "facebookuser")
// public class FacebookUser {
// @DynamoDBHashKey
// private String token;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// private String id;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String link;
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.coding4people.mosquitoreport.api.models.FacebookUser; | package com.coding4people.mosquitoreport.api.repositories;
public class FacebookUserRepositoryTest {
@Test
public void testGetType() { | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/FacebookUser.java
// @DynamoDBTable(tableName = "facebookuser")
// public class FacebookUser {
// @DynamoDBHashKey
// private String token;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// private String id;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String link;
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getLink() {
// return link;
// }
//
// public void setLink(String link) {
// this.link = link;
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/repositories/FacebookUserRepositoryTest.java
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.coding4people.mosquitoreport.api.models.FacebookUser;
package com.coding4people.mosquitoreport.api.repositories;
public class FacebookUserRepositoryTest {
@Test
public void testGetType() { | assertEquals(FacebookUser.class, new FacebookUserRepository().getType()); |
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/factories/DynamoDBMapperFactoryTest.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/Env.java
// public class Env {
// public final static Env instance = new Env();
//
// private Map<String, String> properties = Maps.newHashMap();
//
// public Optional<String> get(String key) {
// return Optional.ofNullable(properties.getOrDefault(key, System.getenv(key)));
// }
//
// public Env register(String key, String value) {
// properties.put(key, value);
//
// return this;
// }
// }
| import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Optional;
import org.junit.Test;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.coding4people.mosquitoreport.api.Env; | package com.coding4people.mosquitoreport.api.factories;
public class DynamoDBMapperFactoryTest {
@Test
public void testProvide() {
AmazonDynamoDB amazonDynamoDB = mock(AmazonDynamoDB.class); | // Path: src/main/java/com/coding4people/mosquitoreport/api/Env.java
// public class Env {
// public final static Env instance = new Env();
//
// private Map<String, String> properties = Maps.newHashMap();
//
// public Optional<String> get(String key) {
// return Optional.ofNullable(properties.getOrDefault(key, System.getenv(key)));
// }
//
// public Env register(String key, String value) {
// properties.put(key, value);
//
// return this;
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/factories/DynamoDBMapperFactoryTest.java
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Optional;
import org.junit.Test;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.coding4people.mosquitoreport.api.Env;
package com.coding4people.mosquitoreport.api.factories;
public class DynamoDBMapperFactoryTest {
@Test
public void testProvide() {
AmazonDynamoDB amazonDynamoDB = mock(AmazonDynamoDB.class); | Env env = mock(Env.class); |
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/repositories/ThumbsUpRepositoryTest.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/ThumbsUp.java
// @DynamoDBTable(tableName = "thumbsup")
// public class ThumbsUp {
// @DynamoDBHashKey
// private String focusguid;
//
// @DynamoDBRangeKey
// private String userguid;
//
// public String getFocusguid() {
// return focusguid;
// }
//
// public void setFocusguid(String focusguid) {
// this.focusguid = focusguid;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.coding4people.mosquitoreport.api.models.ThumbsUp; | package com.coding4people.mosquitoreport.api.repositories;
public class ThumbsUpRepositoryTest {
@Test
public void testGetType() { | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/ThumbsUp.java
// @DynamoDBTable(tableName = "thumbsup")
// public class ThumbsUp {
// @DynamoDBHashKey
// private String focusguid;
//
// @DynamoDBRangeKey
// private String userguid;
//
// public String getFocusguid() {
// return focusguid;
// }
//
// public void setFocusguid(String focusguid) {
// this.focusguid = focusguid;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/repositories/ThumbsUpRepositoryTest.java
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.coding4people.mosquitoreport.api.models.ThumbsUp;
package com.coding4people.mosquitoreport.api.repositories;
public class ThumbsUpRepositoryTest {
@Test
public void testGetType() { | assertEquals(ThumbsUp.class, new ThumbsUpRepository().getType()); |
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailControllerTest.java | // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/auth/AuthenticationService.java
// public class AuthenticationService {
// @Inject
// Env env;
//
// public String generateToken(String userGuid) {
// return Base64.getEncoder().encodeToString(
// (userGuid + '.' + BCrypt.hashpw(env.get("SECRET").orElse("") + userGuid, BCrypt.gensalt(12)))
// .getBytes());
// }
//
// public String identify(String token) {
// final String raw;
//
// try {
// raw = new String(Base64.getDecoder().decode(token));
// } catch (Throwable t) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (raw.length() <= 37) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// String guid = raw.substring(0, 36);
// String hash = raw.substring(37);
//
// boolean valid;
//
// try {
// valid = BCrypt.checkpw(env.get("SECRET").orElse("") + guid, hash);
// } catch (IllegalArgumentException e) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (!valid) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailController.java
// public static class AuthInput {
// @NotNull
// private String email;
//
// @NotNull
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/EmailRepository.java
// @Singleton
// public class EmailRepository extends Repository<Email> {
// @Override
// protected Class<Email> getType() {
// return Email.class;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.auth.AuthenticationService;
import com.coding4people.mosquitoreport.api.controllers.AuthEmailController.AuthInput;
import com.coding4people.mosquitoreport.api.models.Email;
import com.coding4people.mosquitoreport.api.repositories.EmailRepository;
import com.fasterxml.jackson.databind.node.ObjectNode;
| package com.coding4people.mosquitoreport.api.controllers;
public class AuthEmailControllerTest extends WithServer {
@Mock
| // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/auth/AuthenticationService.java
// public class AuthenticationService {
// @Inject
// Env env;
//
// public String generateToken(String userGuid) {
// return Base64.getEncoder().encodeToString(
// (userGuid + '.' + BCrypt.hashpw(env.get("SECRET").orElse("") + userGuid, BCrypt.gensalt(12)))
// .getBytes());
// }
//
// public String identify(String token) {
// final String raw;
//
// try {
// raw = new String(Base64.getDecoder().decode(token));
// } catch (Throwable t) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (raw.length() <= 37) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// String guid = raw.substring(0, 36);
// String hash = raw.substring(37);
//
// boolean valid;
//
// try {
// valid = BCrypt.checkpw(env.get("SECRET").orElse("") + guid, hash);
// } catch (IllegalArgumentException e) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (!valid) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailController.java
// public static class AuthInput {
// @NotNull
// private String email;
//
// @NotNull
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/EmailRepository.java
// @Singleton
// public class EmailRepository extends Repository<Email> {
// @Override
// protected Class<Email> getType() {
// return Email.class;
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailControllerTest.java
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.auth.AuthenticationService;
import com.coding4people.mosquitoreport.api.controllers.AuthEmailController.AuthInput;
import com.coding4people.mosquitoreport.api.models.Email;
import com.coding4people.mosquitoreport.api.repositories.EmailRepository;
import com.fasterxml.jackson.databind.node.ObjectNode;
package com.coding4people.mosquitoreport.api.controllers;
public class AuthEmailControllerTest extends WithServer {
@Mock
| private EmailRepository emailRepository;
|
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailControllerTest.java | // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/auth/AuthenticationService.java
// public class AuthenticationService {
// @Inject
// Env env;
//
// public String generateToken(String userGuid) {
// return Base64.getEncoder().encodeToString(
// (userGuid + '.' + BCrypt.hashpw(env.get("SECRET").orElse("") + userGuid, BCrypt.gensalt(12)))
// .getBytes());
// }
//
// public String identify(String token) {
// final String raw;
//
// try {
// raw = new String(Base64.getDecoder().decode(token));
// } catch (Throwable t) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (raw.length() <= 37) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// String guid = raw.substring(0, 36);
// String hash = raw.substring(37);
//
// boolean valid;
//
// try {
// valid = BCrypt.checkpw(env.get("SECRET").orElse("") + guid, hash);
// } catch (IllegalArgumentException e) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (!valid) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailController.java
// public static class AuthInput {
// @NotNull
// private String email;
//
// @NotNull
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/EmailRepository.java
// @Singleton
// public class EmailRepository extends Repository<Email> {
// @Override
// protected Class<Email> getType() {
// return Email.class;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.auth.AuthenticationService;
import com.coding4people.mosquitoreport.api.controllers.AuthEmailController.AuthInput;
import com.coding4people.mosquitoreport.api.models.Email;
import com.coding4people.mosquitoreport.api.repositories.EmailRepository;
import com.fasterxml.jackson.databind.node.ObjectNode;
| package com.coding4people.mosquitoreport.api.controllers;
public class AuthEmailControllerTest extends WithServer {
@Mock
private EmailRepository emailRepository;
@Mock
| // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/auth/AuthenticationService.java
// public class AuthenticationService {
// @Inject
// Env env;
//
// public String generateToken(String userGuid) {
// return Base64.getEncoder().encodeToString(
// (userGuid + '.' + BCrypt.hashpw(env.get("SECRET").orElse("") + userGuid, BCrypt.gensalt(12)))
// .getBytes());
// }
//
// public String identify(String token) {
// final String raw;
//
// try {
// raw = new String(Base64.getDecoder().decode(token));
// } catch (Throwable t) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (raw.length() <= 37) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// String guid = raw.substring(0, 36);
// String hash = raw.substring(37);
//
// boolean valid;
//
// try {
// valid = BCrypt.checkpw(env.get("SECRET").orElse("") + guid, hash);
// } catch (IllegalArgumentException e) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (!valid) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailController.java
// public static class AuthInput {
// @NotNull
// private String email;
//
// @NotNull
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/EmailRepository.java
// @Singleton
// public class EmailRepository extends Repository<Email> {
// @Override
// protected Class<Email> getType() {
// return Email.class;
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailControllerTest.java
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.auth.AuthenticationService;
import com.coding4people.mosquitoreport.api.controllers.AuthEmailController.AuthInput;
import com.coding4people.mosquitoreport.api.models.Email;
import com.coding4people.mosquitoreport.api.repositories.EmailRepository;
import com.fasterxml.jackson.databind.node.ObjectNode;
package com.coding4people.mosquitoreport.api.controllers;
public class AuthEmailControllerTest extends WithServer {
@Mock
private EmailRepository emailRepository;
@Mock
| AuthenticationService authenticationService;
|
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailControllerTest.java | // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/auth/AuthenticationService.java
// public class AuthenticationService {
// @Inject
// Env env;
//
// public String generateToken(String userGuid) {
// return Base64.getEncoder().encodeToString(
// (userGuid + '.' + BCrypt.hashpw(env.get("SECRET").orElse("") + userGuid, BCrypt.gensalt(12)))
// .getBytes());
// }
//
// public String identify(String token) {
// final String raw;
//
// try {
// raw = new String(Base64.getDecoder().decode(token));
// } catch (Throwable t) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (raw.length() <= 37) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// String guid = raw.substring(0, 36);
// String hash = raw.substring(37);
//
// boolean valid;
//
// try {
// valid = BCrypt.checkpw(env.get("SECRET").orElse("") + guid, hash);
// } catch (IllegalArgumentException e) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (!valid) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailController.java
// public static class AuthInput {
// @NotNull
// private String email;
//
// @NotNull
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/EmailRepository.java
// @Singleton
// public class EmailRepository extends Repository<Email> {
// @Override
// protected Class<Email> getType() {
// return Email.class;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.auth.AuthenticationService;
import com.coding4people.mosquitoreport.api.controllers.AuthEmailController.AuthInput;
import com.coding4people.mosquitoreport.api.models.Email;
import com.coding4people.mosquitoreport.api.repositories.EmailRepository;
import com.fasterxml.jackson.databind.node.ObjectNode;
| package com.coding4people.mosquitoreport.api.controllers;
public class AuthEmailControllerTest extends WithServer {
@Mock
private EmailRepository emailRepository;
@Mock
AuthenticationService authenticationService;
| // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/auth/AuthenticationService.java
// public class AuthenticationService {
// @Inject
// Env env;
//
// public String generateToken(String userGuid) {
// return Base64.getEncoder().encodeToString(
// (userGuid + '.' + BCrypt.hashpw(env.get("SECRET").orElse("") + userGuid, BCrypt.gensalt(12)))
// .getBytes());
// }
//
// public String identify(String token) {
// final String raw;
//
// try {
// raw = new String(Base64.getDecoder().decode(token));
// } catch (Throwable t) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (raw.length() <= 37) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// String guid = raw.substring(0, 36);
// String hash = raw.substring(37);
//
// boolean valid;
//
// try {
// valid = BCrypt.checkpw(env.get("SECRET").orElse("") + guid, hash);
// } catch (IllegalArgumentException e) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (!valid) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailController.java
// public static class AuthInput {
// @NotNull
// private String email;
//
// @NotNull
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/EmailRepository.java
// @Singleton
// public class EmailRepository extends Repository<Email> {
// @Override
// protected Class<Email> getType() {
// return Email.class;
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailControllerTest.java
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.auth.AuthenticationService;
import com.coding4people.mosquitoreport.api.controllers.AuthEmailController.AuthInput;
import com.coding4people.mosquitoreport.api.models.Email;
import com.coding4people.mosquitoreport.api.repositories.EmailRepository;
import com.fasterxml.jackson.databind.node.ObjectNode;
package com.coding4people.mosquitoreport.api.controllers;
public class AuthEmailControllerTest extends WithServer {
@Mock
private EmailRepository emailRepository;
@Mock
AuthenticationService authenticationService;
| private Email email;
|
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailControllerTest.java | // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/auth/AuthenticationService.java
// public class AuthenticationService {
// @Inject
// Env env;
//
// public String generateToken(String userGuid) {
// return Base64.getEncoder().encodeToString(
// (userGuid + '.' + BCrypt.hashpw(env.get("SECRET").orElse("") + userGuid, BCrypt.gensalt(12)))
// .getBytes());
// }
//
// public String identify(String token) {
// final String raw;
//
// try {
// raw = new String(Base64.getDecoder().decode(token));
// } catch (Throwable t) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (raw.length() <= 37) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// String guid = raw.substring(0, 36);
// String hash = raw.substring(37);
//
// boolean valid;
//
// try {
// valid = BCrypt.checkpw(env.get("SECRET").orElse("") + guid, hash);
// } catch (IllegalArgumentException e) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (!valid) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailController.java
// public static class AuthInput {
// @NotNull
// private String email;
//
// @NotNull
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/EmailRepository.java
// @Singleton
// public class EmailRepository extends Repository<Email> {
// @Override
// protected Class<Email> getType() {
// return Email.class;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.auth.AuthenticationService;
import com.coding4people.mosquitoreport.api.controllers.AuthEmailController.AuthInput;
import com.coding4people.mosquitoreport.api.models.Email;
import com.coding4people.mosquitoreport.api.repositories.EmailRepository;
import com.fasterxml.jackson.databind.node.ObjectNode;
| package com.coding4people.mosquitoreport.api.controllers;
public class AuthEmailControllerTest extends WithServer {
@Mock
private EmailRepository emailRepository;
@Mock
AuthenticationService authenticationService;
private Email email;
@Override
protected ResourceConfig configure() {
return super.configure().register(AuthEmailController.class);
}
@Before
public void setUp() throws Exception {
super.setUp();
email = new Email();
email.setUserguid("00000000-0000-0000-0000-000000000000");
email.setEmail("test@test.org");
email.setPassword("$2a$12$6XwAD7Zr62LpR7lcJ4Ulk.D.PieyA2eRPLpFSA0bQ5hsVZU0tcDta");
}
@Test
public void testAuthFailed() {
| // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/auth/AuthenticationService.java
// public class AuthenticationService {
// @Inject
// Env env;
//
// public String generateToken(String userGuid) {
// return Base64.getEncoder().encodeToString(
// (userGuid + '.' + BCrypt.hashpw(env.get("SECRET").orElse("") + userGuid, BCrypt.gensalt(12)))
// .getBytes());
// }
//
// public String identify(String token) {
// final String raw;
//
// try {
// raw = new String(Base64.getDecoder().decode(token));
// } catch (Throwable t) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (raw.length() <= 37) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// String guid = raw.substring(0, 36);
// String hash = raw.substring(37);
//
// boolean valid;
//
// try {
// valid = BCrypt.checkpw(env.get("SECRET").orElse("") + guid, hash);
// } catch (IllegalArgumentException e) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// if (!valid) {
// throw new ForbiddenException("Invalid authorization token");
// }
//
// return guid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailController.java
// public static class AuthInput {
// @NotNull
// private String email;
//
// @NotNull
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/EmailRepository.java
// @Singleton
// public class EmailRepository extends Repository<Email> {
// @Override
// protected Class<Email> getType() {
// return Email.class;
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/controllers/AuthEmailControllerTest.java
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.auth.AuthenticationService;
import com.coding4people.mosquitoreport.api.controllers.AuthEmailController.AuthInput;
import com.coding4people.mosquitoreport.api.models.Email;
import com.coding4people.mosquitoreport.api.repositories.EmailRepository;
import com.fasterxml.jackson.databind.node.ObjectNode;
package com.coding4people.mosquitoreport.api.controllers;
public class AuthEmailControllerTest extends WithServer {
@Mock
private EmailRepository emailRepository;
@Mock
AuthenticationService authenticationService;
private Email email;
@Override
protected ResourceConfig configure() {
return super.configure().register(AuthEmailController.class);
}
@Before
public void setUp() throws Exception {
super.setUp();
email = new Email();
email.setUserguid("00000000-0000-0000-0000-000000000000");
email.setEmail("test@test.org");
email.setPassword("$2a$12$6XwAD7Zr62LpR7lcJ4Ulk.D.PieyA2eRPLpFSA0bQ5hsVZU0tcDta");
}
@Test
public void testAuthFailed() {
| AuthInput data = new AuthInput();
|
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/repositories/EmailRepositoryTest.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.coding4people.mosquitoreport.api.models.Email; | package com.coding4people.mosquitoreport.api.repositories;
public class EmailRepositoryTest {
@Test
public void testGetType() { | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/repositories/EmailRepositoryTest.java
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.coding4people.mosquitoreport.api.models.Email;
package com.coding4people.mosquitoreport.api.repositories;
public class EmailRepositoryTest {
@Test
public void testGetType() { | assertEquals(Email.class, new EmailRepository().getType()); |
coding4people/mosquito-report-api | src/main/java/com/coding4people/mosquitoreport/api/indexers/Indexer.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/Env.java
// public class Env {
// public final static Env instance = new Env();
//
// private Map<String, String> properties = Maps.newHashMap();
//
// public Optional<String> get(String key) {
// return Optional.ofNullable(properties.getOrDefault(key, System.getenv(key)));
// }
//
// public Env register(String key, String value) {
// properties.put(key, value);
//
// return this;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/collectors/EntrySetStringStringSetToObjectNodeCollector.java
// public class EntrySetStringStringSetToObjectNodeCollector implements Collector<Entry<String, List<String>>, ObjectNode, ObjectNode> {
//
// private static final ObjectMapper mapper = new ObjectMapper();
//
// @Override
// public Supplier<ObjectNode> supplier() {
// return mapper::createObjectNode;
// }
//
// @Override
// public BiConsumer<ObjectNode, Entry<String, List<String>>> accumulator() {
// return (x, y) -> {
// if (!y.getValue().isEmpty())
// x.put(y.getKey(), y.getValue().get(0));
// };
// }
//
// @Override
// public BinaryOperator<ObjectNode> combiner() {
// return (x, y) -> {
// final Iterator<String> iterator = x.fieldNames();
//
// while (iterator.hasNext()) {
// String fieldName = iterator.next();
// y.put(fieldName, x.get(fieldName).asText());
// }
//
// return y;
// };
// }
//
// @Override
// public Function<ObjectNode, ObjectNode> finisher() {
// return x -> x;
// }
//
// @Override
// public Set<java.util.stream.Collector.Characteristics> characteristics() {
// return EnumSet.of(Characteristics.UNORDERED);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Searchable.java
// public interface Searchable {
// public String getSearchId();
// }
| import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.InternalServerErrorException;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomain;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient;
import com.amazonaws.services.cloudsearchdomain.model.QueryParser;
import com.amazonaws.services.cloudsearchdomain.model.SearchRequest;
import com.amazonaws.services.cloudsearchdomain.model.SearchResult;
import com.amazonaws.services.cloudsearchdomain.model.UploadDocumentsRequest;
import com.amazonaws.services.cloudsearchv2.AmazonCloudSearch;
import com.amazonaws.services.cloudsearchv2.model.DescribeDomainsRequest;
import com.amazonaws.services.cloudsearchv2.model.DomainStatus;
import com.amazonaws.services.cloudsearchv2.model.ServiceEndpoint;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
import com.coding4people.mosquitoreport.api.Env;
import com.coding4people.mosquitoreport.api.collectors.EntrySetStringStringSetToObjectNodeCollector;
import com.coding4people.mosquitoreport.api.models.Searchable;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode; | package com.coding4people.mosquitoreport.api.indexers;
@Singleton
abstract public class Indexer<T extends Searchable> {
@Inject
AmazonCloudSearch amazonCloudSearch;
@Inject | // Path: src/main/java/com/coding4people/mosquitoreport/api/Env.java
// public class Env {
// public final static Env instance = new Env();
//
// private Map<String, String> properties = Maps.newHashMap();
//
// public Optional<String> get(String key) {
// return Optional.ofNullable(properties.getOrDefault(key, System.getenv(key)));
// }
//
// public Env register(String key, String value) {
// properties.put(key, value);
//
// return this;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/collectors/EntrySetStringStringSetToObjectNodeCollector.java
// public class EntrySetStringStringSetToObjectNodeCollector implements Collector<Entry<String, List<String>>, ObjectNode, ObjectNode> {
//
// private static final ObjectMapper mapper = new ObjectMapper();
//
// @Override
// public Supplier<ObjectNode> supplier() {
// return mapper::createObjectNode;
// }
//
// @Override
// public BiConsumer<ObjectNode, Entry<String, List<String>>> accumulator() {
// return (x, y) -> {
// if (!y.getValue().isEmpty())
// x.put(y.getKey(), y.getValue().get(0));
// };
// }
//
// @Override
// public BinaryOperator<ObjectNode> combiner() {
// return (x, y) -> {
// final Iterator<String> iterator = x.fieldNames();
//
// while (iterator.hasNext()) {
// String fieldName = iterator.next();
// y.put(fieldName, x.get(fieldName).asText());
// }
//
// return y;
// };
// }
//
// @Override
// public Function<ObjectNode, ObjectNode> finisher() {
// return x -> x;
// }
//
// @Override
// public Set<java.util.stream.Collector.Characteristics> characteristics() {
// return EnumSet.of(Characteristics.UNORDERED);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Searchable.java
// public interface Searchable {
// public String getSearchId();
// }
// Path: src/main/java/com/coding4people/mosquitoreport/api/indexers/Indexer.java
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.InternalServerErrorException;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomain;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient;
import com.amazonaws.services.cloudsearchdomain.model.QueryParser;
import com.amazonaws.services.cloudsearchdomain.model.SearchRequest;
import com.amazonaws.services.cloudsearchdomain.model.SearchResult;
import com.amazonaws.services.cloudsearchdomain.model.UploadDocumentsRequest;
import com.amazonaws.services.cloudsearchv2.AmazonCloudSearch;
import com.amazonaws.services.cloudsearchv2.model.DescribeDomainsRequest;
import com.amazonaws.services.cloudsearchv2.model.DomainStatus;
import com.amazonaws.services.cloudsearchv2.model.ServiceEndpoint;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
import com.coding4people.mosquitoreport.api.Env;
import com.coding4people.mosquitoreport.api.collectors.EntrySetStringStringSetToObjectNodeCollector;
import com.coding4people.mosquitoreport.api.models.Searchable;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
package com.coding4people.mosquitoreport.api.indexers;
@Singleton
abstract public class Indexer<T extends Searchable> {
@Inject
AmazonCloudSearch amazonCloudSearch;
@Inject | Env env; |
coding4people/mosquito-report-api | src/main/java/com/coding4people/mosquitoreport/api/indexers/Indexer.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/Env.java
// public class Env {
// public final static Env instance = new Env();
//
// private Map<String, String> properties = Maps.newHashMap();
//
// public Optional<String> get(String key) {
// return Optional.ofNullable(properties.getOrDefault(key, System.getenv(key)));
// }
//
// public Env register(String key, String value) {
// properties.put(key, value);
//
// return this;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/collectors/EntrySetStringStringSetToObjectNodeCollector.java
// public class EntrySetStringStringSetToObjectNodeCollector implements Collector<Entry<String, List<String>>, ObjectNode, ObjectNode> {
//
// private static final ObjectMapper mapper = new ObjectMapper();
//
// @Override
// public Supplier<ObjectNode> supplier() {
// return mapper::createObjectNode;
// }
//
// @Override
// public BiConsumer<ObjectNode, Entry<String, List<String>>> accumulator() {
// return (x, y) -> {
// if (!y.getValue().isEmpty())
// x.put(y.getKey(), y.getValue().get(0));
// };
// }
//
// @Override
// public BinaryOperator<ObjectNode> combiner() {
// return (x, y) -> {
// final Iterator<String> iterator = x.fieldNames();
//
// while (iterator.hasNext()) {
// String fieldName = iterator.next();
// y.put(fieldName, x.get(fieldName).asText());
// }
//
// return y;
// };
// }
//
// @Override
// public Function<ObjectNode, ObjectNode> finisher() {
// return x -> x;
// }
//
// @Override
// public Set<java.util.stream.Collector.Characteristics> characteristics() {
// return EnumSet.of(Characteristics.UNORDERED);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Searchable.java
// public interface Searchable {
// public String getSearchId();
// }
| import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.InternalServerErrorException;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomain;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient;
import com.amazonaws.services.cloudsearchdomain.model.QueryParser;
import com.amazonaws.services.cloudsearchdomain.model.SearchRequest;
import com.amazonaws.services.cloudsearchdomain.model.SearchResult;
import com.amazonaws.services.cloudsearchdomain.model.UploadDocumentsRequest;
import com.amazonaws.services.cloudsearchv2.AmazonCloudSearch;
import com.amazonaws.services.cloudsearchv2.model.DescribeDomainsRequest;
import com.amazonaws.services.cloudsearchv2.model.DomainStatus;
import com.amazonaws.services.cloudsearchv2.model.ServiceEndpoint;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
import com.coding4people.mosquitoreport.api.Env;
import com.coding4people.mosquitoreport.api.collectors.EntrySetStringStringSetToObjectNodeCollector;
import com.coding4people.mosquitoreport.api.models.Searchable;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode; | .withDocuments(new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8))));
} catch (JsonProcessingException e) {
// TODO log indexer errors
e.printStackTrace();
}
}
// TODO avoid query injection
public List<ObjectNode> search(String latlonnw, String latlonse) {
String[] latlonnwa = latlonnw.split(",");
String[] latlonsea = latlonse.split(",");
Double latnw = Double.parseDouble(latlonnwa[0]);
Double lonnw = Double.parseDouble(latlonnwa[1]);
Double latse = Double.parseDouble(latlonsea[0]);
Double lonse = Double.parseDouble(latlonsea[1]);
String latlon = (latnw - ((latnw - latse) / 2)) + "," + (lonnw - ((lonnw - lonse) / 2));
SearchRequest request = new SearchRequest().withSize(30L)
.withQuery("latlon:['" + latlonnw + "','" + latlonse + "']")
.withExpr("{\"distance\":\"haversin(" + latlon + ",latlon.latitude,latlon.longitude)\"}")
.withSort("distance asc");
request.setQueryParser(QueryParser.Structured);
SearchResult result = domain.search(request);
return result.getHits().getHit().stream().map(hit -> { | // Path: src/main/java/com/coding4people/mosquitoreport/api/Env.java
// public class Env {
// public final static Env instance = new Env();
//
// private Map<String, String> properties = Maps.newHashMap();
//
// public Optional<String> get(String key) {
// return Optional.ofNullable(properties.getOrDefault(key, System.getenv(key)));
// }
//
// public Env register(String key, String value) {
// properties.put(key, value);
//
// return this;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/collectors/EntrySetStringStringSetToObjectNodeCollector.java
// public class EntrySetStringStringSetToObjectNodeCollector implements Collector<Entry<String, List<String>>, ObjectNode, ObjectNode> {
//
// private static final ObjectMapper mapper = new ObjectMapper();
//
// @Override
// public Supplier<ObjectNode> supplier() {
// return mapper::createObjectNode;
// }
//
// @Override
// public BiConsumer<ObjectNode, Entry<String, List<String>>> accumulator() {
// return (x, y) -> {
// if (!y.getValue().isEmpty())
// x.put(y.getKey(), y.getValue().get(0));
// };
// }
//
// @Override
// public BinaryOperator<ObjectNode> combiner() {
// return (x, y) -> {
// final Iterator<String> iterator = x.fieldNames();
//
// while (iterator.hasNext()) {
// String fieldName = iterator.next();
// y.put(fieldName, x.get(fieldName).asText());
// }
//
// return y;
// };
// }
//
// @Override
// public Function<ObjectNode, ObjectNode> finisher() {
// return x -> x;
// }
//
// @Override
// public Set<java.util.stream.Collector.Characteristics> characteristics() {
// return EnumSet.of(Characteristics.UNORDERED);
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/Searchable.java
// public interface Searchable {
// public String getSearchId();
// }
// Path: src/main/java/com/coding4people/mosquitoreport/api/indexers/Indexer.java
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.InternalServerErrorException;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomain;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient;
import com.amazonaws.services.cloudsearchdomain.model.QueryParser;
import com.amazonaws.services.cloudsearchdomain.model.SearchRequest;
import com.amazonaws.services.cloudsearchdomain.model.SearchResult;
import com.amazonaws.services.cloudsearchdomain.model.UploadDocumentsRequest;
import com.amazonaws.services.cloudsearchv2.AmazonCloudSearch;
import com.amazonaws.services.cloudsearchv2.model.DescribeDomainsRequest;
import com.amazonaws.services.cloudsearchv2.model.DomainStatus;
import com.amazonaws.services.cloudsearchv2.model.ServiceEndpoint;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
import com.coding4people.mosquitoreport.api.Env;
import com.coding4people.mosquitoreport.api.collectors.EntrySetStringStringSetToObjectNodeCollector;
import com.coding4people.mosquitoreport.api.models.Searchable;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
.withDocuments(new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8))));
} catch (JsonProcessingException e) {
// TODO log indexer errors
e.printStackTrace();
}
}
// TODO avoid query injection
public List<ObjectNode> search(String latlonnw, String latlonse) {
String[] latlonnwa = latlonnw.split(",");
String[] latlonsea = latlonse.split(",");
Double latnw = Double.parseDouble(latlonnwa[0]);
Double lonnw = Double.parseDouble(latlonnwa[1]);
Double latse = Double.parseDouble(latlonsea[0]);
Double lonse = Double.parseDouble(latlonsea[1]);
String latlon = (latnw - ((latnw - latse) / 2)) + "," + (lonnw - ((lonnw - lonse) / 2));
SearchRequest request = new SearchRequest().withSize(30L)
.withQuery("latlon:['" + latlonnw + "','" + latlonse + "']")
.withExpr("{\"distance\":\"haversin(" + latlon + ",latlon.latitude,latlon.longitude)\"}")
.withSort("distance asc");
request.setQueryParser(QueryParser.Structured);
SearchResult result = domain.search(request);
return result.getHits().getHit().stream().map(hit -> { | return hit.getFields().entrySet().stream().collect(new EntrySetStringStringSetToObjectNodeCollector()); |
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/model/EmailTest.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
| import org.junit.Test;
import com.coding4people.mosquitoreport.api.models.Email; | package com.coding4people.mosquitoreport.api.model;
public class EmailTest {
@Test(expected = IllegalArgumentException.class)
public void testThrowsIllegalArgumentException() { | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/Email.java
// @DynamoDBTable(tableName = "email")
// public class Email {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBAttribute
// private String userguid;
//
// @DynamoDBAttribute
// @JsonIgnore
// private String password;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public static String encryptPassword(String rawPassword) {
// return BCrypt.hashpw(rawPassword, BCrypt.gensalt(12));
// }
//
// public static boolean checkPassword(String rawPassword, String password) {
// if(null == password || !password.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawPassword, password);
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/model/EmailTest.java
import org.junit.Test;
import com.coding4people.mosquitoreport.api.models.Email;
package com.coding4people.mosquitoreport.api.model;
public class EmailTest {
@Test(expected = IllegalArgumentException.class)
public void testThrowsIllegalArgumentException() { | Email.checkPassword("", ""); |
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/model/PasswordResetTokenTest.java | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/PasswordResetToken.java
// @DynamoDBTable(tableName = "passwordresettoken")
// public class PasswordResetToken {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBRangeKey
// private String expires;
//
// @DynamoDBAttribute
// private String token;
//
// @DynamoDBAttribute
// private String userguid;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getExpires() {
// return expires;
// }
//
// public void setExpires(String expires) {
// this.expires = expires;
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public static String encryptToken(String rawToken) {
// return BCrypt.hashpw(rawToken, BCrypt.gensalt(12));
// }
//
// public static boolean checkToken(String rawToken, String token) {
// if(null == token || !token.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawToken, token);
// }
// }
| import org.junit.Test;
import com.coding4people.mosquitoreport.api.models.PasswordResetToken; | package com.coding4people.mosquitoreport.api.model;
public class PasswordResetTokenTest {
@Test(expected = IllegalArgumentException.class)
public void testThrowsIllegalArgumentException() { | // Path: src/main/java/com/coding4people/mosquitoreport/api/models/PasswordResetToken.java
// @DynamoDBTable(tableName = "passwordresettoken")
// public class PasswordResetToken {
// @DynamoDBHashKey
// private String email;
//
// @DynamoDBRangeKey
// private String expires;
//
// @DynamoDBAttribute
// private String token;
//
// @DynamoDBAttribute
// private String userguid;
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getExpires() {
// return expires;
// }
//
// public void setExpires(String expires) {
// this.expires = expires;
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public String getUserguid() {
// return userguid;
// }
//
// public void setUserguid(String userguid) {
// this.userguid = userguid;
// }
//
// public static String encryptToken(String rawToken) {
// return BCrypt.hashpw(rawToken, BCrypt.gensalt(12));
// }
//
// public static boolean checkToken(String rawToken, String token) {
// if(null == token || !token.startsWith("$2a$")) {
// throw new IllegalArgumentException("Invalid hash provided for comparison");
// }
//
// return BCrypt.checkpw(rawToken, token);
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/model/PasswordResetTokenTest.java
import org.junit.Test;
import com.coding4people.mosquitoreport.api.models.PasswordResetToken;
package com.coding4people.mosquitoreport.api.model;
public class PasswordResetTokenTest {
@Test(expected = IllegalArgumentException.class)
public void testThrowsIllegalArgumentException() { | PasswordResetToken.checkToken("", ""); |
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/controllers/ProfileControllerTest.java | // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/ProfileController.java
// public static class ProfilePostInput {
// @NotNull
// @NotEmpty
// private String firstname;
//
// private String lastname;
//
// private String location;
//
// private String facebookurl;
//
// private String twitter;
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/UserRepository.java
// @Singleton
// public class UserRepository extends Repository<User> {
// @Override
// protected Class<User> getType() {
// return User.class;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.controllers.ProfileController.ProfilePostInput;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.UserRepository;
| package com.coding4people.mosquitoreport.api.controllers;
public class ProfileControllerTest extends WithServer {
@Mock
| // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/ProfileController.java
// public static class ProfilePostInput {
// @NotNull
// @NotEmpty
// private String firstname;
//
// private String lastname;
//
// private String location;
//
// private String facebookurl;
//
// private String twitter;
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/UserRepository.java
// @Singleton
// public class UserRepository extends Repository<User> {
// @Override
// protected Class<User> getType() {
// return User.class;
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/controllers/ProfileControllerTest.java
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.controllers.ProfileController.ProfilePostInput;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.UserRepository;
package com.coding4people.mosquitoreport.api.controllers;
public class ProfileControllerTest extends WithServer {
@Mock
| UserRepository userRepository;
|
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/controllers/ProfileControllerTest.java | // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/ProfileController.java
// public static class ProfilePostInput {
// @NotNull
// @NotEmpty
// private String firstname;
//
// private String lastname;
//
// private String location;
//
// private String facebookurl;
//
// private String twitter;
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/UserRepository.java
// @Singleton
// public class UserRepository extends Repository<User> {
// @Override
// protected Class<User> getType() {
// return User.class;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.controllers.ProfileController.ProfilePostInput;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.UserRepository;
| package com.coding4people.mosquitoreport.api.controllers;
public class ProfileControllerTest extends WithServer {
@Mock
UserRepository userRepository;
| // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/ProfileController.java
// public static class ProfilePostInput {
// @NotNull
// @NotEmpty
// private String firstname;
//
// private String lastname;
//
// private String location;
//
// private String facebookurl;
//
// private String twitter;
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/UserRepository.java
// @Singleton
// public class UserRepository extends Repository<User> {
// @Override
// protected Class<User> getType() {
// return User.class;
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/controllers/ProfileControllerTest.java
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.controllers.ProfileController.ProfilePostInput;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.UserRepository;
package com.coding4people.mosquitoreport.api.controllers;
public class ProfileControllerTest extends WithServer {
@Mock
UserRepository userRepository;
| User currentUser = new User();;
|
coding4people/mosquito-report-api | src/test/java/com/coding4people/mosquitoreport/api/controllers/ProfileControllerTest.java | // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/ProfileController.java
// public static class ProfilePostInput {
// @NotNull
// @NotEmpty
// private String firstname;
//
// private String lastname;
//
// private String location;
//
// private String facebookurl;
//
// private String twitter;
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/UserRepository.java
// @Singleton
// public class UserRepository extends Repository<User> {
// @Override
// protected Class<User> getType() {
// return User.class;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.controllers.ProfileController.ProfilePostInput;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.UserRepository;
| currentUser.setProfilepictureguid("my profilepictureguid");
Response response = target().path("/profile").request().get();
assertEquals(200, response.getStatus());
assertEquals("application/json;charset=UTF-8", response.getHeaderString("Content-type"));
User user = response.readEntity(User.class);
assertEquals("my guid", user.getGuid());
assertEquals("my email", user.getEmail());
assertEquals("my firstname", user.getFirstname());
assertEquals("my lastname", user.getLastname());
assertEquals("my location", user.getLocation());
assertEquals("my facebookurl", user.getFacebookurl());
assertEquals("my twitter", user.getTwitter());
assertEquals("my profilepictureguid", user.getProfilepictureguid());
}
@Test
public void testPost() {
currentUser.setGuid("my guid");
currentUser.setEmail("my email");
currentUser.setFirstname("my firstname");
currentUser.setLastname("my lastname");
currentUser.setLocation("my location");
currentUser.setFacebookurl("my facebookurl");
currentUser.setTwitter("my twitter");
currentUser.setProfilepictureguid("my profilepictureguid");
| // Path: src/test/java/com/coding4people/mosquitoreport/api/WithServer.java
// abstract public class WithServer extends JerseyTest implements BaseTest {
// @Override
// protected ResourceConfig configure() {
// MockitoAnnotations.initMocks(this);
//
// return new Config().configureFramework().register(new MockBinder(this));
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/controllers/ProfileController.java
// public static class ProfilePostInput {
// @NotNull
// @NotEmpty
// private String firstname;
//
// private String lastname;
//
// private String location;
//
// private String facebookurl;
//
// private String twitter;
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/models/User.java
// @DynamoDBTable(tableName = "user")
// public class User {
// @DynamoDBHashKey
// private String guid;
//
// @DynamoDBAttribute
// private String email;
//
// @DynamoDBAttribute
// private String firstname;
//
// @DynamoDBAttribute
// private String lastname;
//
// @DynamoDBAttribute
// private String location;
//
// @DynamoDBAttribute
// private String facebookurl;
//
// @DynamoDBAttribute
// private String twitter;
//
// @DynamoDBAttribute
// private String profilepictureguid;
//
// public String getGuid() {
// return guid;
// }
//
// public void setGuid(String guid) {
// this.guid = guid;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getFirstname() {
// return firstname;
// }
//
// public void setFirstname(String firstname) {
// this.firstname = firstname;
// }
//
// public String getLastname() {
// return lastname;
// }
//
// public void setLastname(String lastname) {
// this.lastname = lastname;
// }
//
// public String getLocation() {
// return location;
// }
//
// public void setLocation(String location) {
// this.location = location;
// }
//
// public String getFacebookurl() {
// return facebookurl;
// }
//
// public void setFacebookurl(String facebookurl) {
// this.facebookurl = facebookurl;
// }
//
// public String getTwitter() {
// return twitter;
// }
//
// public void setTwitter(String twitter) {
// this.twitter = twitter;
// }
//
// public String getProfilepictureguid() {
// return profilepictureguid;
// }
//
// public void setProfilepictureguid(String profilepictureguid) {
// this.profilepictureguid = profilepictureguid;
// }
// }
//
// Path: src/main/java/com/coding4people/mosquitoreport/api/repositories/UserRepository.java
// @Singleton
// public class UserRepository extends Repository<User> {
// @Override
// protected Class<User> getType() {
// return User.class;
// }
// }
// Path: src/test/java/com/coding4people/mosquitoreport/api/controllers/ProfileControllerTest.java
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Test;
import org.mockito.Mock;
import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.controllers.ProfileController.ProfilePostInput;
import com.coding4people.mosquitoreport.api.models.User;
import com.coding4people.mosquitoreport.api.repositories.UserRepository;
currentUser.setProfilepictureguid("my profilepictureguid");
Response response = target().path("/profile").request().get();
assertEquals(200, response.getStatus());
assertEquals("application/json;charset=UTF-8", response.getHeaderString("Content-type"));
User user = response.readEntity(User.class);
assertEquals("my guid", user.getGuid());
assertEquals("my email", user.getEmail());
assertEquals("my firstname", user.getFirstname());
assertEquals("my lastname", user.getLastname());
assertEquals("my location", user.getLocation());
assertEquals("my facebookurl", user.getFacebookurl());
assertEquals("my twitter", user.getTwitter());
assertEquals("my profilepictureguid", user.getProfilepictureguid());
}
@Test
public void testPost() {
currentUser.setGuid("my guid");
currentUser.setEmail("my email");
currentUser.setFirstname("my firstname");
currentUser.setLastname("my lastname");
currentUser.setLocation("my location");
currentUser.setFacebookurl("my facebookurl");
currentUser.setTwitter("my twitter");
currentUser.setProfilepictureguid("my profilepictureguid");
| ProfilePostInput input = new ProfilePostInput();
|
jackpotsvr/Java-Conquer-Server | src/main/java/net/co/java/cipher/Cryptographer.java | // Path: src/main/java/net/co/java/packets/IncomingPacket.java
// public class IncomingPacket {
//
// final ByteBuffer buffer;
// private final PacketType packetType;
//
// /**
// * Construct a new {@code IncommingPacket} based on a {@code ByteBuffer}
// * @param buffer
// * @throws UnimplementedPacketTypeException
// */
// public IncomingPacket(ByteBuffer buffer) throws UnimplementedPacketTypeException {
// this.buffer = buffer.order(ByteOrder.LITTLE_ENDIAN);
// this.packetType = PacketType.valueOf(this.readUnsignedShort(2));
// }
//
// /**
// * Returns unsigned byte at specified offset (1 byte)
// * @param offset
// * @return {short} as the range of ubyte is 0 to 2^8-1
// */
// public short readUnsignedByte(int offset) {
// return ((short) (buffer.get(offset) & (short) 0xff));
// }
//
// /**
// * @param position
// * @return byte at position
// */
// public byte getByte(int position) {
// return buffer.get(position);
// }
//
// /**
// * Returns unsigned short at specified offset (2 bytes)
// * @param offset
// * @return {int} as the range of ushort is 0 to 2^16-1
// */
// public int readUnsignedShort(int offset) {
// return (buffer.getShort(offset) & 0xffff);
// }
//
// /**
// * Returns unsigned integer at specified offset (4 bytes)
// * @param offset
// * @return long as the range of uint is 0 to 2^32-1
// */
// public long readUnsignedInt(int offset) {
// return ((long) buffer.getInt(offset) & 0xffffffffL);
// }
//
// /**
// * Returns string at specified offset and of specified length
// * @param offset
// * @param length
// * @return {String}
// */
// public String readString(int offset, int length) {
// byte[] output = new byte[length];
// System.arraycopy(buffer.array(), offset, output, 0, length);
// /*
// * We had to replace the null termination for Strings because they did
// * not work well with database models: ERROR: invalid byte sequence for
// * encoding "UTF8": 0x00 FIX
// */
// return new String(output).replaceAll("[\u0000]", "");
// }
//
// /**
// * @return decrypted password
// */
// public String readPassword() {
// /*
// * We had to replace the null termination for Strings because they did
// * not work well with database models: ERROR: invalid byte sequence for
// * encoding "UTF8": 0x00 FIX
// */
// return Cryptographer.decryptPassword(this, 20).replaceAll("[\u0000]", "");
// }
//
// /**
// * @return the length for this packet, based on the data
// */
// public int getLength() {
// return buffer.limit();
// }
//
// /**
// * @return the {@code PacketType} for this {@code IncommingPacket}
// */
// public PacketType getPacketType() {
// return packetType;
// }
//
// @Override
// public String toString() {
// return packetType.toString() + " : " + bytesToHex(buffer.array()) + " (" + getLength() + ")";
// }
//
// private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
//
// private static String bytesToHex(byte[] bytes) {
// char[] hexChars = new char[bytes.length * 2];
// for ( int j = 0; j < bytes.length; j++ ) {
// int v = bytes[j] & 0xFF;
// hexChars[j * 2] = hexArray[v >>> 4];
// hexChars[j * 2 + 1] = hexArray[v & 0x0F];
// }
// return new String(hexChars);
// }
//
// }
| import java.nio.ByteBuffer;
import net.co.java.packets.IncomingPacket; | long IMul = DWordKey * DWordKey;
byte[] XorKey = {
(byte) (DWordKey & 0xFF),
(byte) ((DWordKey >> 8) & 0xFF),
(byte) ((DWordKey >> 16) & 0xFF),
(byte) ((DWordKey >> 24) & 0xFF),
(byte) (IMul & 0xFF),
(byte) ((IMul >> 8) & 0xFF),
(byte) ((IMul >> 16) & 0xFF),
(byte) ((IMul >> 24) & 0xFF)
};
for ( int i = 0; i < 256; i++ )
{
key3[i] = (byte) (XorKey[i % 4] ^ key1[i]);
key4[i] = (byte) (XorKey[i%4+4] ^ key2[i]);
}
usingAlternate = true;
outCounter = 0;
}
/**
* Decrypt a password
* @param incomingPacket that contains the password
* @param offset at which the password resists
* @return the decrypted password
*/ | // Path: src/main/java/net/co/java/packets/IncomingPacket.java
// public class IncomingPacket {
//
// final ByteBuffer buffer;
// private final PacketType packetType;
//
// /**
// * Construct a new {@code IncommingPacket} based on a {@code ByteBuffer}
// * @param buffer
// * @throws UnimplementedPacketTypeException
// */
// public IncomingPacket(ByteBuffer buffer) throws UnimplementedPacketTypeException {
// this.buffer = buffer.order(ByteOrder.LITTLE_ENDIAN);
// this.packetType = PacketType.valueOf(this.readUnsignedShort(2));
// }
//
// /**
// * Returns unsigned byte at specified offset (1 byte)
// * @param offset
// * @return {short} as the range of ubyte is 0 to 2^8-1
// */
// public short readUnsignedByte(int offset) {
// return ((short) (buffer.get(offset) & (short) 0xff));
// }
//
// /**
// * @param position
// * @return byte at position
// */
// public byte getByte(int position) {
// return buffer.get(position);
// }
//
// /**
// * Returns unsigned short at specified offset (2 bytes)
// * @param offset
// * @return {int} as the range of ushort is 0 to 2^16-1
// */
// public int readUnsignedShort(int offset) {
// return (buffer.getShort(offset) & 0xffff);
// }
//
// /**
// * Returns unsigned integer at specified offset (4 bytes)
// * @param offset
// * @return long as the range of uint is 0 to 2^32-1
// */
// public long readUnsignedInt(int offset) {
// return ((long) buffer.getInt(offset) & 0xffffffffL);
// }
//
// /**
// * Returns string at specified offset and of specified length
// * @param offset
// * @param length
// * @return {String}
// */
// public String readString(int offset, int length) {
// byte[] output = new byte[length];
// System.arraycopy(buffer.array(), offset, output, 0, length);
// /*
// * We had to replace the null termination for Strings because they did
// * not work well with database models: ERROR: invalid byte sequence for
// * encoding "UTF8": 0x00 FIX
// */
// return new String(output).replaceAll("[\u0000]", "");
// }
//
// /**
// * @return decrypted password
// */
// public String readPassword() {
// /*
// * We had to replace the null termination for Strings because they did
// * not work well with database models: ERROR: invalid byte sequence for
// * encoding "UTF8": 0x00 FIX
// */
// return Cryptographer.decryptPassword(this, 20).replaceAll("[\u0000]", "");
// }
//
// /**
// * @return the length for this packet, based on the data
// */
// public int getLength() {
// return buffer.limit();
// }
//
// /**
// * @return the {@code PacketType} for this {@code IncommingPacket}
// */
// public PacketType getPacketType() {
// return packetType;
// }
//
// @Override
// public String toString() {
// return packetType.toString() + " : " + bytesToHex(buffer.array()) + " (" + getLength() + ")";
// }
//
// private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
//
// private static String bytesToHex(byte[] bytes) {
// char[] hexChars = new char[bytes.length * 2];
// for ( int j = 0; j < bytes.length; j++ ) {
// int v = bytes[j] & 0xFF;
// hexChars[j * 2] = hexArray[v >>> 4];
// hexChars[j * 2 + 1] = hexArray[v & 0x0F];
// }
// return new String(hexChars);
// }
//
// }
// Path: src/main/java/net/co/java/cipher/Cryptographer.java
import java.nio.ByteBuffer;
import net.co.java.packets.IncomingPacket;
long IMul = DWordKey * DWordKey;
byte[] XorKey = {
(byte) (DWordKey & 0xFF),
(byte) ((DWordKey >> 8) & 0xFF),
(byte) ((DWordKey >> 16) & 0xFF),
(byte) ((DWordKey >> 24) & 0xFF),
(byte) (IMul & 0xFF),
(byte) ((IMul >> 8) & 0xFF),
(byte) ((IMul >> 16) & 0xFF),
(byte) ((IMul >> 24) & 0xFF)
};
for ( int i = 0; i < 256; i++ )
{
key3[i] = (byte) (XorKey[i % 4] ^ key1[i]);
key4[i] = (byte) (XorKey[i%4+4] ^ key2[i]);
}
usingAlternate = true;
outCounter = 0;
}
/**
* Decrypt a password
* @param incomingPacket that contains the password
* @param offset at which the password resists
* @return the decrypted password
*/ | public static String decryptPassword(IncomingPacket incomingPacket, int offset) { |
jackpotsvr/Java-Conquer-Server | src/main/java/net/co/java/packets/serialization/Incoming.java | // Path: src/main/java/net/co/java/packets/PacketHandler.java
// public interface PacketHandler extends PacketWrapper {
//
// /**
// * Delegate the Packet
// * @param client
// */
// void handle(GameServerClient client);
// }
//
// Path: src/main/java/net/co/java/packets/packethandlers/NoPacketHandler.java
// public class NoPacketHandler extends AbstractPacketHandler {
//
// public NoPacketHandler(Packet packet) {
// super(packet);
// }
//
// @Override
// public PacketWriter build() {
// return null;
// }
//
// @Override
// public void handle(GameServerClient client) {
//
// }
//
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.co.java.packets.PacketHandler;
import net.co.java.packets.packethandlers.NoPacketHandler; | package net.co.java.packets.serialization;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Incoming {
/**
* @return The handler for the packet. This is a NoPacketHandler by default,
* if the packet doesn't have a PacketHandler.
*/ | // Path: src/main/java/net/co/java/packets/PacketHandler.java
// public interface PacketHandler extends PacketWrapper {
//
// /**
// * Delegate the Packet
// * @param client
// */
// void handle(GameServerClient client);
// }
//
// Path: src/main/java/net/co/java/packets/packethandlers/NoPacketHandler.java
// public class NoPacketHandler extends AbstractPacketHandler {
//
// public NoPacketHandler(Packet packet) {
// super(packet);
// }
//
// @Override
// public PacketWriter build() {
// return null;
// }
//
// @Override
// public void handle(GameServerClient client) {
//
// }
//
// }
// Path: src/main/java/net/co/java/packets/serialization/Incoming.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.co.java.packets.PacketHandler;
import net.co.java.packets.packethandlers.NoPacketHandler;
package net.co.java.packets.serialization;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Incoming {
/**
* @return The handler for the packet. This is a NoPacketHandler by default,
* if the packet doesn't have a PacketHandler.
*/ | Class<? extends PacketHandler> handler() default NoPacketHandler.class; |
jackpotsvr/Java-Conquer-Server | src/main/java/net/co/java/packets/serialization/Incoming.java | // Path: src/main/java/net/co/java/packets/PacketHandler.java
// public interface PacketHandler extends PacketWrapper {
//
// /**
// * Delegate the Packet
// * @param client
// */
// void handle(GameServerClient client);
// }
//
// Path: src/main/java/net/co/java/packets/packethandlers/NoPacketHandler.java
// public class NoPacketHandler extends AbstractPacketHandler {
//
// public NoPacketHandler(Packet packet) {
// super(packet);
// }
//
// @Override
// public PacketWriter build() {
// return null;
// }
//
// @Override
// public void handle(GameServerClient client) {
//
// }
//
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.co.java.packets.PacketHandler;
import net.co.java.packets.packethandlers.NoPacketHandler; | package net.co.java.packets.serialization;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Incoming {
/**
* @return The handler for the packet. This is a NoPacketHandler by default,
* if the packet doesn't have a PacketHandler.
*/ | // Path: src/main/java/net/co/java/packets/PacketHandler.java
// public interface PacketHandler extends PacketWrapper {
//
// /**
// * Delegate the Packet
// * @param client
// */
// void handle(GameServerClient client);
// }
//
// Path: src/main/java/net/co/java/packets/packethandlers/NoPacketHandler.java
// public class NoPacketHandler extends AbstractPacketHandler {
//
// public NoPacketHandler(Packet packet) {
// super(packet);
// }
//
// @Override
// public PacketWriter build() {
// return null;
// }
//
// @Override
// public void handle(GameServerClient client) {
//
// }
//
// }
// Path: src/main/java/net/co/java/packets/serialization/Incoming.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.co.java.packets.PacketHandler;
import net.co.java.packets.packethandlers.NoPacketHandler;
package net.co.java.packets.serialization;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Incoming {
/**
* @return The handler for the packet. This is a NoPacketHandler by default,
* if the packet doesn't have a PacketHandler.
*/ | Class<? extends PacketHandler> handler() default NoPacketHandler.class; |
jackpotsvr/Java-Conquer-Server | src/main/java/net/co/java/packets/Packet.java | // Path: src/main/java/net/co/java/packets/serialization/PacketValueType.java
// public enum PacketValueType {
// BOOLEAN,
// UNSIGNED_BYTE,
// BYTE,
// UNSIGNED_SHORT,
// SHORT,
// UNSIGNED_INT,
// INT,
// STRING_WITH_LENGTH,
// STRING,
// ENUM_VALUE;
// }
| import net.co.java.packets.serialization.PacketValue;
import net.co.java.packets.serialization.PacketValueType; | package net.co.java.packets;
public abstract class Packet {
private IncomingPacket ip;
public PacketHeader header;
public Packet(IncomingPacket ip) {
this.ip = ip;
if(ip == null) {
header = new PacketHeader();
}
}
public PacketType getType() {
return (ip == null) ? header.type : ip.getPacketType();
};
public void setType(PacketType type) {
header.type = type;
}
public int getLength() {
return header.length;
}
public void setLength(int length) {
header.length = length;
}
public IncomingPacket getIncomingPacket() {
return ip;
}
public static final class PacketHeader {
| // Path: src/main/java/net/co/java/packets/serialization/PacketValueType.java
// public enum PacketValueType {
// BOOLEAN,
// UNSIGNED_BYTE,
// BYTE,
// UNSIGNED_SHORT,
// SHORT,
// UNSIGNED_INT,
// INT,
// STRING_WITH_LENGTH,
// STRING,
// ENUM_VALUE;
// }
// Path: src/main/java/net/co/java/packets/Packet.java
import net.co.java.packets.serialization.PacketValue;
import net.co.java.packets.serialization.PacketValueType;
package net.co.java.packets;
public abstract class Packet {
private IncomingPacket ip;
public PacketHeader header;
public Packet(IncomingPacket ip) {
this.ip = ip;
if(ip == null) {
header = new PacketHeader();
}
}
public PacketType getType() {
return (ip == null) ? header.type : ip.getPacketType();
};
public void setType(PacketType type) {
header.type = type;
}
public int getLength() {
return header.length;
}
public void setLength(int length) {
header.length = length;
}
public IncomingPacket getIncomingPacket() {
return ip;
}
public static final class PacketHeader {
| @PacketValue(type = PacketValueType.ENUM_VALUE) |
jackpotsvr/Java-Conquer-Server | src/main/java/net/co/java/packets/serialization/Bidirectional.java | // Path: src/main/java/net/co/java/packets/AbstractPacketHandler.java
// public abstract class AbstractPacketHandler implements PacketHandler {
// protected Packet packet;
//
// public AbstractPacketHandler(Packet packet) {
// this.packet = packet;
// }
//
// @Override
// public PacketWriter build() {
// return new PacketBuilder(packet).build();
// }
// }
//
// Path: src/main/java/net/co/java/packets/PacketHandler.java
// public interface PacketHandler extends PacketWrapper {
//
// /**
// * Delegate the Packet
// * @param client
// */
// void handle(GameServerClient client);
// }
//
// Path: src/main/java/net/co/java/packets/packethandlers/NoPacketHandler.java
// public class NoPacketHandler extends AbstractPacketHandler {
//
// public NoPacketHandler(Packet packet) {
// super(packet);
// }
//
// @Override
// public PacketWriter build() {
// return null;
// }
//
// @Override
// public void handle(GameServerClient client) {
//
// }
//
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.co.java.packets.AbstractPacketHandler;
import net.co.java.packets.PacketHandler;
import net.co.java.packets.packethandlers.NoPacketHandler; | package net.co.java.packets.serialization;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Bidirectional {
/**
* @return The handler for the packet. This is a NoPacketHandler by default,
* if the packet doesn't have a PacketHandler.
*/ | // Path: src/main/java/net/co/java/packets/AbstractPacketHandler.java
// public abstract class AbstractPacketHandler implements PacketHandler {
// protected Packet packet;
//
// public AbstractPacketHandler(Packet packet) {
// this.packet = packet;
// }
//
// @Override
// public PacketWriter build() {
// return new PacketBuilder(packet).build();
// }
// }
//
// Path: src/main/java/net/co/java/packets/PacketHandler.java
// public interface PacketHandler extends PacketWrapper {
//
// /**
// * Delegate the Packet
// * @param client
// */
// void handle(GameServerClient client);
// }
//
// Path: src/main/java/net/co/java/packets/packethandlers/NoPacketHandler.java
// public class NoPacketHandler extends AbstractPacketHandler {
//
// public NoPacketHandler(Packet packet) {
// super(packet);
// }
//
// @Override
// public PacketWriter build() {
// return null;
// }
//
// @Override
// public void handle(GameServerClient client) {
//
// }
//
// }
// Path: src/main/java/net/co/java/packets/serialization/Bidirectional.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.co.java.packets.AbstractPacketHandler;
import net.co.java.packets.PacketHandler;
import net.co.java.packets.packethandlers.NoPacketHandler;
package net.co.java.packets.serialization;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Bidirectional {
/**
* @return The handler for the packet. This is a NoPacketHandler by default,
* if the packet doesn't have a PacketHandler.
*/ | Class<? extends AbstractPacketHandler> handler() default NoPacketHandler.class; |
jackpotsvr/Java-Conquer-Server | src/main/java/net/co/java/packets/serialization/Bidirectional.java | // Path: src/main/java/net/co/java/packets/AbstractPacketHandler.java
// public abstract class AbstractPacketHandler implements PacketHandler {
// protected Packet packet;
//
// public AbstractPacketHandler(Packet packet) {
// this.packet = packet;
// }
//
// @Override
// public PacketWriter build() {
// return new PacketBuilder(packet).build();
// }
// }
//
// Path: src/main/java/net/co/java/packets/PacketHandler.java
// public interface PacketHandler extends PacketWrapper {
//
// /**
// * Delegate the Packet
// * @param client
// */
// void handle(GameServerClient client);
// }
//
// Path: src/main/java/net/co/java/packets/packethandlers/NoPacketHandler.java
// public class NoPacketHandler extends AbstractPacketHandler {
//
// public NoPacketHandler(Packet packet) {
// super(packet);
// }
//
// @Override
// public PacketWriter build() {
// return null;
// }
//
// @Override
// public void handle(GameServerClient client) {
//
// }
//
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.co.java.packets.AbstractPacketHandler;
import net.co.java.packets.PacketHandler;
import net.co.java.packets.packethandlers.NoPacketHandler; | package net.co.java.packets.serialization;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Bidirectional {
/**
* @return The handler for the packet. This is a NoPacketHandler by default,
* if the packet doesn't have a PacketHandler.
*/ | // Path: src/main/java/net/co/java/packets/AbstractPacketHandler.java
// public abstract class AbstractPacketHandler implements PacketHandler {
// protected Packet packet;
//
// public AbstractPacketHandler(Packet packet) {
// this.packet = packet;
// }
//
// @Override
// public PacketWriter build() {
// return new PacketBuilder(packet).build();
// }
// }
//
// Path: src/main/java/net/co/java/packets/PacketHandler.java
// public interface PacketHandler extends PacketWrapper {
//
// /**
// * Delegate the Packet
// * @param client
// */
// void handle(GameServerClient client);
// }
//
// Path: src/main/java/net/co/java/packets/packethandlers/NoPacketHandler.java
// public class NoPacketHandler extends AbstractPacketHandler {
//
// public NoPacketHandler(Packet packet) {
// super(packet);
// }
//
// @Override
// public PacketWriter build() {
// return null;
// }
//
// @Override
// public void handle(GameServerClient client) {
//
// }
//
// }
// Path: src/main/java/net/co/java/packets/serialization/Bidirectional.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.co.java.packets.AbstractPacketHandler;
import net.co.java.packets.PacketHandler;
import net.co.java.packets.packethandlers.NoPacketHandler;
package net.co.java.packets.serialization;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Bidirectional {
/**
* @return The handler for the packet. This is a NoPacketHandler by default,
* if the packet doesn't have a PacketHandler.
*/ | Class<? extends AbstractPacketHandler> handler() default NoPacketHandler.class; |
jackpotsvr/Java-Conquer-Server | src/main/java/net/co/java/packets/PacketBuilder.java | // Path: src/main/java/net/co/java/packets/serialization/PacketSerializer.java
// public class PacketSerializer {
// protected int totalStringLength = 0;
// protected int currentStringLength = 0;
// protected final Packet packet;
// protected Class<? extends Packet> clasz;
// protected PacketWriter pw = null;
//
// public PacketSerializer(Packet packet) {
// this.packet = packet;
//
// try {
// clasz = Packets.getInstance().getPacketClass(packet.getType());
// setTotalStringLength(packet);
// } catch (IllegalArgumentException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// }
//
// /**
// * @param packet
// * @throws IllegalArgumentException
// * @throws IllegalAccessException
// */
// protected void setTotalStringLength(Packet packet) throws IllegalArgumentException, IllegalAccessException {
// for(Field field : clasz.getDeclaredFields()) {
// if(field.isAnnotationPresent(PacketValue.class)) {
// field.setAccessible(true);
// PacketValue value = field.getAnnotation(PacketValue.class);
// switch(value.type()) {
// case STRING_WITH_LENGTH:
// totalStringLength += ((String) field.get(packet)).length();
// default:
// break;
// }
// }
// }
// }
//
// public PacketWriter serialize() {
// int length = 0;
//
// if(clasz.isAnnotationPresent(PacketLength.class)) {
// PacketLength packetLength = clasz.getAnnotation(PacketLength.class);
// length = packetLength.length();
// }
//
// pw = new PacketWriter(packet.getType(), length + totalStringLength);
//
// for(Field field : clasz.getDeclaredFields()) {
// if(field.isAnnotationPresent(PacketValue.class)) {
// if(field.isAnnotationPresent(Offset.class)){
// PacketValue value = field.getAnnotation(PacketValue.class);
// Offset offset = field.getAnnotation(Offset.class);
// field.setAccessible(true);
// try {
// switch(value.type()) {
// case ENUM_VALUE:
// setEnum(packet, field, value, offset);
// break;
// case STRING:
// pw.setOffset(offset.value());
// //setString(packet, field, value, offset);
// pw.putString((String) field.get(packet), 16);
// break;
// case STRING_WITH_LENGTH:
// setStringWithLength(packet, field, value, offset);
// case UNSIGNED_BYTE:
// case BYTE:
// case UNSIGNED_SHORT:
// case SHORT:
// case UNSIGNED_INT:
// case INT:
// default:
// setPrimitive(packet, field, value, offset);
// break;
// }
// } catch (IllegalArgumentException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// } catch (NoSuchFieldException e) {
// e.printStackTrace();
// } catch (SecurityException e) {
// e.printStackTrace();
// }
// }
// }
// }
//
// return pw;
// }
//
// private void setEnum(Packet packet, Field field, PacketValue value,
// Offset offset) throws IllegalArgumentException, IllegalAccessException,
// NoSuchFieldException, SecurityException {
// pw.setOffset(offset.value());
// pw.putUnsignedShort(EnumUtility.getEnumValue(field.get(packet)));
// }
//
// private void setStringWithLength(Packet packet, Field field,
// PacketValue value, Offset offset) throws IllegalArgumentException, IllegalAccessException {
// pw.setOffset(offset.value() + currentStringLength);
// pw.putUnsignedByte(((String) field.get(packet)).length());
// pw.putString(((String) field.get(packet)));
// currentStringLength += ((String) field.get(packet)).length();
// }
//
//
//
// public void setPrimitive(Packet packet, Field field, PacketValue value, Offset offset)
// throws IllegalArgumentException, IllegalAccessException {
// pw.setOffset(offset.value());
// switch(value.type()) {
// case BOOLEAN:
// pw.putBoolean(field.getBoolean(packet));
// break;
// case UNSIGNED_BYTE:
// pw.putUnsignedByte(field.getInt(packet));
// break;
// case UNSIGNED_SHORT:
// pw.putUnsignedShort(field.getInt(packet));
// break;
// case UNSIGNED_INT:
// pw.putUnsignedInteger(field.getLong(packet));
// break;
// case INT:
// pw.putSignedInteger(field.getInt(packet));
// break;
// default:
// break;
// }
// }
// }
| import net.co.java.packets.serialization.PacketSerializer; | package net.co.java.packets;
public class PacketBuilder implements PacketWrapper {
private Packet packet;
public PacketBuilder(Packet packet) {
this.packet = packet;
}
@Override
public PacketWriter build() { | // Path: src/main/java/net/co/java/packets/serialization/PacketSerializer.java
// public class PacketSerializer {
// protected int totalStringLength = 0;
// protected int currentStringLength = 0;
// protected final Packet packet;
// protected Class<? extends Packet> clasz;
// protected PacketWriter pw = null;
//
// public PacketSerializer(Packet packet) {
// this.packet = packet;
//
// try {
// clasz = Packets.getInstance().getPacketClass(packet.getType());
// setTotalStringLength(packet);
// } catch (IllegalArgumentException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// }
//
// /**
// * @param packet
// * @throws IllegalArgumentException
// * @throws IllegalAccessException
// */
// protected void setTotalStringLength(Packet packet) throws IllegalArgumentException, IllegalAccessException {
// for(Field field : clasz.getDeclaredFields()) {
// if(field.isAnnotationPresent(PacketValue.class)) {
// field.setAccessible(true);
// PacketValue value = field.getAnnotation(PacketValue.class);
// switch(value.type()) {
// case STRING_WITH_LENGTH:
// totalStringLength += ((String) field.get(packet)).length();
// default:
// break;
// }
// }
// }
// }
//
// public PacketWriter serialize() {
// int length = 0;
//
// if(clasz.isAnnotationPresent(PacketLength.class)) {
// PacketLength packetLength = clasz.getAnnotation(PacketLength.class);
// length = packetLength.length();
// }
//
// pw = new PacketWriter(packet.getType(), length + totalStringLength);
//
// for(Field field : clasz.getDeclaredFields()) {
// if(field.isAnnotationPresent(PacketValue.class)) {
// if(field.isAnnotationPresent(Offset.class)){
// PacketValue value = field.getAnnotation(PacketValue.class);
// Offset offset = field.getAnnotation(Offset.class);
// field.setAccessible(true);
// try {
// switch(value.type()) {
// case ENUM_VALUE:
// setEnum(packet, field, value, offset);
// break;
// case STRING:
// pw.setOffset(offset.value());
// //setString(packet, field, value, offset);
// pw.putString((String) field.get(packet), 16);
// break;
// case STRING_WITH_LENGTH:
// setStringWithLength(packet, field, value, offset);
// case UNSIGNED_BYTE:
// case BYTE:
// case UNSIGNED_SHORT:
// case SHORT:
// case UNSIGNED_INT:
// case INT:
// default:
// setPrimitive(packet, field, value, offset);
// break;
// }
// } catch (IllegalArgumentException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// } catch (NoSuchFieldException e) {
// e.printStackTrace();
// } catch (SecurityException e) {
// e.printStackTrace();
// }
// }
// }
// }
//
// return pw;
// }
//
// private void setEnum(Packet packet, Field field, PacketValue value,
// Offset offset) throws IllegalArgumentException, IllegalAccessException,
// NoSuchFieldException, SecurityException {
// pw.setOffset(offset.value());
// pw.putUnsignedShort(EnumUtility.getEnumValue(field.get(packet)));
// }
//
// private void setStringWithLength(Packet packet, Field field,
// PacketValue value, Offset offset) throws IllegalArgumentException, IllegalAccessException {
// pw.setOffset(offset.value() + currentStringLength);
// pw.putUnsignedByte(((String) field.get(packet)).length());
// pw.putString(((String) field.get(packet)));
// currentStringLength += ((String) field.get(packet)).length();
// }
//
//
//
// public void setPrimitive(Packet packet, Field field, PacketValue value, Offset offset)
// throws IllegalArgumentException, IllegalAccessException {
// pw.setOffset(offset.value());
// switch(value.type()) {
// case BOOLEAN:
// pw.putBoolean(field.getBoolean(packet));
// break;
// case UNSIGNED_BYTE:
// pw.putUnsignedByte(field.getInt(packet));
// break;
// case UNSIGNED_SHORT:
// pw.putUnsignedShort(field.getInt(packet));
// break;
// case UNSIGNED_INT:
// pw.putUnsignedInteger(field.getLong(packet));
// break;
// case INT:
// pw.putSignedInteger(field.getInt(packet));
// break;
// default:
// break;
// }
// }
// }
// Path: src/main/java/net/co/java/packets/PacketBuilder.java
import net.co.java.packets.serialization.PacketSerializer;
package net.co.java.packets;
public class PacketBuilder implements PacketWrapper {
private Packet packet;
public PacketBuilder(Packet packet) {
this.packet = packet;
}
@Override
public PacketWriter build() { | return new PacketSerializer(packet).serialize(); |
jackpotsvr/Java-Conquer-Server | src/main/java/net/co/java/entity/Location.java | // Path: src/main/java/net/co/java/server/Map.java
// public enum Map {
//
// /* http://www.elitepvpers.com/forum/co2-programming/177758-request-map-id-complete-list.html */
// Desert(1000),
// CentralPlain(1002),
// PromotionCenter(1004),
// PhoenixCastle(1011),
// BirdIsland(1015),
// ApeMoutain(1020);
//
//
// private final Integer id;
//
// private final List<Entity> entities = new CopyOnWriteArrayList<Entity>();
//
// /**
// * Construct a new Map with a given id
// * @param id
// */
// private Map(int id) {
// this.id = Integer.valueOf(id);
// System.out.println("Initializing map: " + this.toString() + " (" + this.id + ")");
// }
//
// /**
// * @return the id for a Map
// */
// public int getMapID() {
// return id;
// }
//
// /**
// * Add an {@code Entity} to this Map, for example due a windspell, portal or spawn.
// * Send an EntitySpawn packet to surrounding players.
// * @param entity
// */
// public void addEntity(Entity entity) {
// if(!entities.contains(entity)) {
// entities.add(entity);
// }
// }
//
// /**
// * Remove an {@code Entity} from this Map - death or teleport.
// * Send an Entity Remove packet to surrounding players.
// * @param entity
// */
// public void removeEntity(Entity entity) {
// entities.remove(entity);
// }
//
// /**
// * @return all entities in this map.
// */
// public List<Entity> getEntities() {
// return entities;
// }
//
// public static Map valueOf(int id)
// {
// for ( Map mp : Map.values() ) {
// if ( mp.id == id )
// return mp;
// }
// return null;
// }
// }
| import net.co.java.server.Map; | package net.co.java.entity;
/**
* The Location class contains the information for a location
* in a Map
*
* @author Jan-Willem Gmelig Meyling
* @author Thomas Gmelig Meyling
*/
public class Location {
public final static int VIEW_RANGE = 18;
public final int xCord, yCord; | // Path: src/main/java/net/co/java/server/Map.java
// public enum Map {
//
// /* http://www.elitepvpers.com/forum/co2-programming/177758-request-map-id-complete-list.html */
// Desert(1000),
// CentralPlain(1002),
// PromotionCenter(1004),
// PhoenixCastle(1011),
// BirdIsland(1015),
// ApeMoutain(1020);
//
//
// private final Integer id;
//
// private final List<Entity> entities = new CopyOnWriteArrayList<Entity>();
//
// /**
// * Construct a new Map with a given id
// * @param id
// */
// private Map(int id) {
// this.id = Integer.valueOf(id);
// System.out.println("Initializing map: " + this.toString() + " (" + this.id + ")");
// }
//
// /**
// * @return the id for a Map
// */
// public int getMapID() {
// return id;
// }
//
// /**
// * Add an {@code Entity} to this Map, for example due a windspell, portal or spawn.
// * Send an EntitySpawn packet to surrounding players.
// * @param entity
// */
// public void addEntity(Entity entity) {
// if(!entities.contains(entity)) {
// entities.add(entity);
// }
// }
//
// /**
// * Remove an {@code Entity} from this Map - death or teleport.
// * Send an Entity Remove packet to surrounding players.
// * @param entity
// */
// public void removeEntity(Entity entity) {
// entities.remove(entity);
// }
//
// /**
// * @return all entities in this map.
// */
// public List<Entity> getEntities() {
// return entities;
// }
//
// public static Map valueOf(int id)
// {
// for ( Map mp : Map.values() ) {
// if ( mp.id == id )
// return mp;
// }
// return null;
// }
// }
// Path: src/main/java/net/co/java/entity/Location.java
import net.co.java.server.Map;
package net.co.java.entity;
/**
* The Location class contains the information for a location
* in a Map
*
* @author Jan-Willem Gmelig Meyling
* @author Thomas Gmelig Meyling
*/
public class Location {
public final static int VIEW_RANGE = 18;
public final int xCord, yCord; | public final Map map; |
jojenki/Concordia | lang/java/src/name/jenkins/paul/john/concordia/schema/ObjectSchema.java | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
| import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; | package name.jenkins.paul.john.concordia.schema;
/**
* <p>
* The object Concordia type. This must include a definition of its fields.
* </p>
*
* <p>
* This class is immutable.
* </p>
*
* @author John Jenkins
*/
public class ObjectSchema extends Schema {
/**
* <p>
* A builder specifically for reference schemas.
* </p>
*
* @author John Jenkins
*/
public static class Builder extends Schema.Builder {
/**
* The list of fields in this object.
*/
private List<Schema> fields;
/**
* Creates a builder based off of an existing schema.
*
* @param original
* The original schema to base the fields in this builder off
* of.
*/
public Builder(final ObjectSchema original) {
super(original);
fields = new ArrayList<Schema>(original.fields);
}
/**
* Returns the currently set list of fields. The internal list is
* backed by the response value, so modifications to the returned list
* will be reflected in this builder.
*
* @return The currently set list of fields.
*/
public List<Schema> getFields() {
return fields;
}
/**
* Sets the list of fields. There is no aggregation; this will replace
* the current list of fields. It will be a deep copy of the parameter,
* so modifying the parameterized list will have no effect on the
* internal list of fields.
*
* @param fields
* The desired list of fields.
*
* @return Returns this to facilitate chaining.
*/
public ObjectSchema.Builder setReference(final List<Schema> fields) {
this.fields = new ArrayList<Schema>(fields);
return this;
}
/*
* (non-Javadoc)
* @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
*/
@Override | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/ObjectSchema.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
package name.jenkins.paul.john.concordia.schema;
/**
* <p>
* The object Concordia type. This must include a definition of its fields.
* </p>
*
* <p>
* This class is immutable.
* </p>
*
* @author John Jenkins
*/
public class ObjectSchema extends Schema {
/**
* <p>
* A builder specifically for reference schemas.
* </p>
*
* @author John Jenkins
*/
public static class Builder extends Schema.Builder {
/**
* The list of fields in this object.
*/
private List<Schema> fields;
/**
* Creates a builder based off of an existing schema.
*
* @param original
* The original schema to base the fields in this builder off
* of.
*/
public Builder(final ObjectSchema original) {
super(original);
fields = new ArrayList<Schema>(original.fields);
}
/**
* Returns the currently set list of fields. The internal list is
* backed by the response value, so modifications to the returned list
* will be reflected in this builder.
*
* @return The currently set list of fields.
*/
public List<Schema> getFields() {
return fields;
}
/**
* Sets the list of fields. There is no aggregation; this will replace
* the current list of fields. It will be a deep copy of the parameter,
* so modifying the parameterized list will have no effect on the
* internal list of fields.
*
* @param fields
* The desired list of fields.
*
* @return Returns this to facilitate chaining.
*/
public ObjectSchema.Builder setReference(final List<Schema> fields) {
this.fields = new ArrayList<Schema>(fields);
return this;
}
/*
* (non-Javadoc)
* @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
*/
@Override | public ObjectSchema build() throws ConcordiaException { |
jojenki/Concordia | lang/java/src/name/jenkins/paul/john/concordia/validator/NumberValidator.java | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/NumberSchema.java
// public class NumberSchema extends Schema {
// /**
// * <p>
// * A builder specifically for reference schemas.
// * </p>
// *
// * @author John Jenkins
// */
// public static class Builder extends Schema.Builder {
// /**
// * Creates a builder based off of an existing schema.
// *
// * @param original
// * The original schema to base the fields in this builder off
// * of.
// */
// public Builder(final NumberSchema original) {
// super(original);
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
// */
// @Override
// public NumberSchema build() throws ConcordiaException {
// return
// new NumberSchema(
// getDoc(),
// getOptional(),
// getName(),
// getOthers());
// }
// }
//
// /**
// * The field value for this type.
// */
// public static final String TYPE_ID = "number";
//
// /**
// * An ID for this class for serialization purposes.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates a new number schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// */
// public NumberSchema(
// @JsonProperty(JSON_KEY_DOC) final String doc,
// @JsonProperty(JSON_KEY_OPTIONAL) final boolean optional,
// @JsonProperty(ObjectSchema.JSON_KEY_NAME) final String name) {
//
// this(doc, optional, name, null);
// }
//
// /**
// * Creates a new number schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// *
// * @param others
// * Additional undefined fields that are being preserved.
// */
// protected NumberSchema(
// final String doc,
// final boolean optional,
// final String name,
// final Map<String, Object> others) {
//
// super(doc, optional, name, others);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see name.jenkins.paul.john.concordia.schema.Schema#getType()
// */
// @Override
// public String getType() {
// return TYPE_ID;
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getSubSchemas()
// */
// @Override
// public List<Schema> getSubSchemas() {
// return Collections.emptyList();
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getBuilder()
// */
// @Override
// public Schema.Builder getBuilder() {
// return new NumberSchema.Builder(this);
// }
// }
| import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import name.jenkins.paul.john.concordia.schema.NumberSchema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.NumericNode; | package name.jenkins.paul.john.concordia.validator;
/**
* The required validator for number schemas.
*
* @author John Jenkins
*/
public final class NumberValidator
implements | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/NumberSchema.java
// public class NumberSchema extends Schema {
// /**
// * <p>
// * A builder specifically for reference schemas.
// * </p>
// *
// * @author John Jenkins
// */
// public static class Builder extends Schema.Builder {
// /**
// * Creates a builder based off of an existing schema.
// *
// * @param original
// * The original schema to base the fields in this builder off
// * of.
// */
// public Builder(final NumberSchema original) {
// super(original);
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
// */
// @Override
// public NumberSchema build() throws ConcordiaException {
// return
// new NumberSchema(
// getDoc(),
// getOptional(),
// getName(),
// getOthers());
// }
// }
//
// /**
// * The field value for this type.
// */
// public static final String TYPE_ID = "number";
//
// /**
// * An ID for this class for serialization purposes.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates a new number schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// */
// public NumberSchema(
// @JsonProperty(JSON_KEY_DOC) final String doc,
// @JsonProperty(JSON_KEY_OPTIONAL) final boolean optional,
// @JsonProperty(ObjectSchema.JSON_KEY_NAME) final String name) {
//
// this(doc, optional, name, null);
// }
//
// /**
// * Creates a new number schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// *
// * @param others
// * Additional undefined fields that are being preserved.
// */
// protected NumberSchema(
// final String doc,
// final boolean optional,
// final String name,
// final Map<String, Object> others) {
//
// super(doc, optional, name, others);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see name.jenkins.paul.john.concordia.schema.Schema#getType()
// */
// @Override
// public String getType() {
// return TYPE_ID;
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getSubSchemas()
// */
// @Override
// public List<Schema> getSubSchemas() {
// return Collections.emptyList();
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getBuilder()
// */
// @Override
// public Schema.Builder getBuilder() {
// return new NumberSchema.Builder(this);
// }
// }
// Path: lang/java/src/name/jenkins/paul/john/concordia/validator/NumberValidator.java
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import name.jenkins.paul.john.concordia.schema.NumberSchema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.NumericNode;
package name.jenkins.paul.john.concordia.validator;
/**
* The required validator for number schemas.
*
* @author John Jenkins
*/
public final class NumberValidator
implements | SchemaValidator<NumberSchema>, |
jojenki/Concordia | lang/java/src/name/jenkins/paul/john/concordia/validator/NumberValidator.java | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/NumberSchema.java
// public class NumberSchema extends Schema {
// /**
// * <p>
// * A builder specifically for reference schemas.
// * </p>
// *
// * @author John Jenkins
// */
// public static class Builder extends Schema.Builder {
// /**
// * Creates a builder based off of an existing schema.
// *
// * @param original
// * The original schema to base the fields in this builder off
// * of.
// */
// public Builder(final NumberSchema original) {
// super(original);
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
// */
// @Override
// public NumberSchema build() throws ConcordiaException {
// return
// new NumberSchema(
// getDoc(),
// getOptional(),
// getName(),
// getOthers());
// }
// }
//
// /**
// * The field value for this type.
// */
// public static final String TYPE_ID = "number";
//
// /**
// * An ID for this class for serialization purposes.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates a new number schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// */
// public NumberSchema(
// @JsonProperty(JSON_KEY_DOC) final String doc,
// @JsonProperty(JSON_KEY_OPTIONAL) final boolean optional,
// @JsonProperty(ObjectSchema.JSON_KEY_NAME) final String name) {
//
// this(doc, optional, name, null);
// }
//
// /**
// * Creates a new number schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// *
// * @param others
// * Additional undefined fields that are being preserved.
// */
// protected NumberSchema(
// final String doc,
// final boolean optional,
// final String name,
// final Map<String, Object> others) {
//
// super(doc, optional, name, others);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see name.jenkins.paul.john.concordia.schema.Schema#getType()
// */
// @Override
// public String getType() {
// return TYPE_ID;
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getSubSchemas()
// */
// @Override
// public List<Schema> getSubSchemas() {
// return Collections.emptyList();
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getBuilder()
// */
// @Override
// public Schema.Builder getBuilder() {
// return new NumberSchema.Builder(this);
// }
// }
| import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import name.jenkins.paul.john.concordia.schema.NumberSchema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.NumericNode; | package name.jenkins.paul.john.concordia.validator;
/**
* The required validator for number schemas.
*
* @author John Jenkins
*/
public final class NumberValidator
implements
SchemaValidator<NumberSchema>,
DataValidator<NumberSchema> {
@Override
public void validate(
final NumberSchema schema,
final ValidationController controller) | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/NumberSchema.java
// public class NumberSchema extends Schema {
// /**
// * <p>
// * A builder specifically for reference schemas.
// * </p>
// *
// * @author John Jenkins
// */
// public static class Builder extends Schema.Builder {
// /**
// * Creates a builder based off of an existing schema.
// *
// * @param original
// * The original schema to base the fields in this builder off
// * of.
// */
// public Builder(final NumberSchema original) {
// super(original);
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
// */
// @Override
// public NumberSchema build() throws ConcordiaException {
// return
// new NumberSchema(
// getDoc(),
// getOptional(),
// getName(),
// getOthers());
// }
// }
//
// /**
// * The field value for this type.
// */
// public static final String TYPE_ID = "number";
//
// /**
// * An ID for this class for serialization purposes.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates a new number schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// */
// public NumberSchema(
// @JsonProperty(JSON_KEY_DOC) final String doc,
// @JsonProperty(JSON_KEY_OPTIONAL) final boolean optional,
// @JsonProperty(ObjectSchema.JSON_KEY_NAME) final String name) {
//
// this(doc, optional, name, null);
// }
//
// /**
// * Creates a new number schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// *
// * @param others
// * Additional undefined fields that are being preserved.
// */
// protected NumberSchema(
// final String doc,
// final boolean optional,
// final String name,
// final Map<String, Object> others) {
//
// super(doc, optional, name, others);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see name.jenkins.paul.john.concordia.schema.Schema#getType()
// */
// @Override
// public String getType() {
// return TYPE_ID;
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getSubSchemas()
// */
// @Override
// public List<Schema> getSubSchemas() {
// return Collections.emptyList();
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getBuilder()
// */
// @Override
// public Schema.Builder getBuilder() {
// return new NumberSchema.Builder(this);
// }
// }
// Path: lang/java/src/name/jenkins/paul/john/concordia/validator/NumberValidator.java
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import name.jenkins.paul.john.concordia.schema.NumberSchema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.NumericNode;
package name.jenkins.paul.john.concordia.validator;
/**
* The required validator for number schemas.
*
* @author John Jenkins
*/
public final class NumberValidator
implements
SchemaValidator<NumberSchema>,
DataValidator<NumberSchema> {
@Override
public void validate(
final NumberSchema schema,
final ValidationController controller) | throws ConcordiaException { |
jojenki/Concordia | lang/java/src/name/jenkins/paul/john/concordia/schema/BooleanSchema.java | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
| import java.util.Collections;
import java.util.List;
import java.util.Map;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; | package name.jenkins.paul.john.concordia.schema;
/**
* <p>
* The boolean Concordia type.
* </p>
*
* <p>
* This class is immutable.
* </p>
*
* @author John Jenkins
*/
public class BooleanSchema extends Schema {
/**
* <p>
* A builder specifically for reference schemas.
* </p>
*
* @author John Jenkins
*/
public static class Builder extends Schema.Builder {
/**
* Creates a builder based off of an existing schema.
*
* @param original
* The original schema to base the fields in this builder off
* of.
*/
public Builder(final BooleanSchema original) {
super(original);
}
/*
* (non-Javadoc)
* @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
*/
@Override | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/BooleanSchema.java
import java.util.Collections;
import java.util.List;
import java.util.Map;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
package name.jenkins.paul.john.concordia.schema;
/**
* <p>
* The boolean Concordia type.
* </p>
*
* <p>
* This class is immutable.
* </p>
*
* @author John Jenkins
*/
public class BooleanSchema extends Schema {
/**
* <p>
* A builder specifically for reference schemas.
* </p>
*
* @author John Jenkins
*/
public static class Builder extends Schema.Builder {
/**
* Creates a builder based off of an existing schema.
*
* @param original
* The original schema to base the fields in this builder off
* of.
*/
public Builder(final BooleanSchema original) {
super(original);
}
/*
* (non-Javadoc)
* @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
*/
@Override | public BooleanSchema build() throws ConcordiaException { |
jojenki/Concordia | lang/java/src/name/jenkins/paul/john/concordia/schema/NumberSchema.java | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
| import java.util.Collections;
import java.util.List;
import java.util.Map;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import com.fasterxml.jackson.annotation.JsonProperty; | package name.jenkins.paul.john.concordia.schema;
/**
* <p>
* The number Concordia type.
* </p>
*
* <p>
* This class is immutable.
* </p>
*
* @author John Jenkins
*/
public class NumberSchema extends Schema {
/**
* <p>
* A builder specifically for reference schemas.
* </p>
*
* @author John Jenkins
*/
public static class Builder extends Schema.Builder {
/**
* Creates a builder based off of an existing schema.
*
* @param original
* The original schema to base the fields in this builder off
* of.
*/
public Builder(final NumberSchema original) {
super(original);
}
/*
* (non-Javadoc)
* @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
*/
@Override | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/NumberSchema.java
import java.util.Collections;
import java.util.List;
import java.util.Map;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import com.fasterxml.jackson.annotation.JsonProperty;
package name.jenkins.paul.john.concordia.schema;
/**
* <p>
* The number Concordia type.
* </p>
*
* <p>
* This class is immutable.
* </p>
*
* @author John Jenkins
*/
public class NumberSchema extends Schema {
/**
* <p>
* A builder specifically for reference schemas.
* </p>
*
* @author John Jenkins
*/
public static class Builder extends Schema.Builder {
/**
* Creates a builder based off of an existing schema.
*
* @param original
* The original schema to base the fields in this builder off
* of.
*/
public Builder(final NumberSchema original) {
super(original);
}
/*
* (non-Javadoc)
* @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
*/
@Override | public NumberSchema build() throws ConcordiaException { |
jojenki/Concordia | lang/java/src/name/jenkins/paul/john/concordia/validator/BooleanValidator.java | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/BooleanSchema.java
// public class BooleanSchema extends Schema {
// /**
// * <p>
// * A builder specifically for reference schemas.
// * </p>
// *
// * @author John Jenkins
// */
// public static class Builder extends Schema.Builder {
// /**
// * Creates a builder based off of an existing schema.
// *
// * @param original
// * The original schema to base the fields in this builder off
// * of.
// */
// public Builder(final BooleanSchema original) {
// super(original);
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
// */
// @Override
// public BooleanSchema build() throws ConcordiaException {
// return
// new BooleanSchema(
// getDoc(),
// getOptional(),
// getName(),
// getOthers());
// }
// }
//
// /**
// * The field value for this type.
// */
// public static final String TYPE_ID = "boolean";
//
// /**
// * An ID for this class for serialization purposes.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates a new boolean schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// */
// @JsonCreator
// public BooleanSchema(
// @JsonProperty(JSON_KEY_DOC) final String doc,
// @JsonProperty(JSON_KEY_OPTIONAL) final boolean optional,
// @JsonProperty(ObjectSchema.JSON_KEY_NAME) final String name) {
//
// this(doc, optional, name, null);
// }
//
// /**
// * Creates a new boolean schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// *
// * @param others
// * Additional undefined fields that are being preserved.
// */
// protected BooleanSchema(
// final String doc,
// final boolean optional,
// final String name,
// final Map<String, Object> others) {
//
// super(doc, optional, name, others);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see name.jenkins.paul.john.concordia.schema.Schema#getType()
// */
// @Override
// public String getType() {
// return TYPE_ID;
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getSubSchemas()
// */
// @Override
// public List<Schema> getSubSchemas() {
// return Collections.emptyList();
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getBuilder()
// */
// @Override
// public Schema.Builder getBuilder() {
// return new BooleanSchema.Builder(this);
// }
// }
| import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import name.jenkins.paul.john.concordia.schema.BooleanSchema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.BooleanNode;
import com.fasterxml.jackson.databind.node.NullNode; | package name.jenkins.paul.john.concordia.validator;
/**
* <p>
* The required validator for boolean schemas.
* </p>
*
* @author John Jenkins
*/
public final class BooleanValidator
implements SchemaValidator<BooleanSchema>, DataValidator<BooleanSchema> {
/**
* Validates that some boolean schema is valid.
*/
@Override
public void validate(
final BooleanSchema schema,
final ValidationController controller) | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/BooleanSchema.java
// public class BooleanSchema extends Schema {
// /**
// * <p>
// * A builder specifically for reference schemas.
// * </p>
// *
// * @author John Jenkins
// */
// public static class Builder extends Schema.Builder {
// /**
// * Creates a builder based off of an existing schema.
// *
// * @param original
// * The original schema to base the fields in this builder off
// * of.
// */
// public Builder(final BooleanSchema original) {
// super(original);
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
// */
// @Override
// public BooleanSchema build() throws ConcordiaException {
// return
// new BooleanSchema(
// getDoc(),
// getOptional(),
// getName(),
// getOthers());
// }
// }
//
// /**
// * The field value for this type.
// */
// public static final String TYPE_ID = "boolean";
//
// /**
// * An ID for this class for serialization purposes.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates a new boolean schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// */
// @JsonCreator
// public BooleanSchema(
// @JsonProperty(JSON_KEY_DOC) final String doc,
// @JsonProperty(JSON_KEY_OPTIONAL) final boolean optional,
// @JsonProperty(ObjectSchema.JSON_KEY_NAME) final String name) {
//
// this(doc, optional, name, null);
// }
//
// /**
// * Creates a new boolean schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// *
// * @param others
// * Additional undefined fields that are being preserved.
// */
// protected BooleanSchema(
// final String doc,
// final boolean optional,
// final String name,
// final Map<String, Object> others) {
//
// super(doc, optional, name, others);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see name.jenkins.paul.john.concordia.schema.Schema#getType()
// */
// @Override
// public String getType() {
// return TYPE_ID;
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getSubSchemas()
// */
// @Override
// public List<Schema> getSubSchemas() {
// return Collections.emptyList();
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getBuilder()
// */
// @Override
// public Schema.Builder getBuilder() {
// return new BooleanSchema.Builder(this);
// }
// }
// Path: lang/java/src/name/jenkins/paul/john/concordia/validator/BooleanValidator.java
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import name.jenkins.paul.john.concordia.schema.BooleanSchema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.BooleanNode;
import com.fasterxml.jackson.databind.node.NullNode;
package name.jenkins.paul.john.concordia.validator;
/**
* <p>
* The required validator for boolean schemas.
* </p>
*
* @author John Jenkins
*/
public final class BooleanValidator
implements SchemaValidator<BooleanSchema>, DataValidator<BooleanSchema> {
/**
* Validates that some boolean schema is valid.
*/
@Override
public void validate(
final BooleanSchema schema,
final ValidationController controller) | throws ConcordiaException { |
jojenki/Concordia | lang/java/src/name/jenkins/paul/john/concordia/schema/StringSchema.java | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
| import java.util.Collections;
import java.util.List;
import java.util.Map;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; | package name.jenkins.paul.john.concordia.schema;
/**
* <p>
* The string Concordia type.
* </p>
*
* <p>
* This class is immutable.
* </p>
*
* @author John Jenkins
*/
public class StringSchema extends Schema {
/**
* <p>
* A builder specifically for reference schemas.
* </p>
*
* @author John Jenkins
*/
public static class Builder extends Schema.Builder {
/**
* Creates a builder based off of an existing schema.
*
* @param original
* The original schema to base the fields in this builder off
* of.
*/
public Builder(final StringSchema original) {
super(original);
}
/*
* (non-Javadoc)
* @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
*/
@Override | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/StringSchema.java
import java.util.Collections;
import java.util.List;
import java.util.Map;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
package name.jenkins.paul.john.concordia.schema;
/**
* <p>
* The string Concordia type.
* </p>
*
* <p>
* This class is immutable.
* </p>
*
* @author John Jenkins
*/
public class StringSchema extends Schema {
/**
* <p>
* A builder specifically for reference schemas.
* </p>
*
* @author John Jenkins
*/
public static class Builder extends Schema.Builder {
/**
* Creates a builder based off of an existing schema.
*
* @param original
* The original schema to base the fields in this builder off
* of.
*/
public Builder(final StringSchema original) {
super(original);
}
/*
* (non-Javadoc)
* @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
*/
@Override | public StringSchema build() throws ConcordiaException { |
jojenki/Concordia | lang/java/src/name/jenkins/paul/john/concordia/schema/ArraySchema.java | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
| import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; | package name.jenkins.paul.john.concordia.schema;
/**
* <p>
* The array Concordia type. This must include either a single {@link Schema}
* defining a constant-type array or a list of {@link Schema}s defining a
* constant-length array.
* </p>
*
* <p>
* This class is immutable.
* </p>
*
* @author John Jenkins
*/
@JsonInclude(Include.NON_NULL)
public class ArraySchema extends Schema {
/**
* <p>
* A builder specifically for reference schemas.
* </p>
*
* @author John Jenkins
*/
public static class Builder extends Schema.Builder {
/**
* The {@link Schema} for this array if it is a constant-type array.
*/
private Schema constType;
/**
* The {@link Schema}s for this array if it is a constant-type array.
*/
private List<Schema> constLength;
/**
* Creates a builder based off of an existing schema.
*
* @param original
* The original schema to base the fields in this builder off
* of.
*/
public Builder(final ArraySchema original) {
super(original);
constType = original.constType;
constLength = original.constLength;
}
/**
* Returns the currently set type for a constant type array.
*
* @return The currently set type for a constant type array.
*/
public Schema getConstType() {
return constType;
}
/**
* Sets the type for a constant type array. This will not be checked
* with whether or not there is a constant length value until the
* schema is built. This may be null to clear the constant type-ness.
*
* @param constType
* The type for this constant type array.
*
* @return Returns this to facilitate chaining.
*
* @see #build()
*/
public ArraySchema.Builder setConstType(final Schema constType) {
this.constType = constType;
return this;
}
/**
* Returns the currently set list of types for a constant length array.
* The internal list is backed by the response value, so modifications
* to the returned list will be reflected in this builder.
*
* @return The currently set list of types for a constant length array.
*/
public List<Schema> getConstLength() {
return constLength;
}
/**
* Sets the list of types for a constant length array. This will not be
* checked with whether or not there is a constant type value until the
* schema is built. This may be null to clear the constant length-ness.
*
* @param constLength
* The list of types for this constant length array.
*
* @return Returns this to facilitate chaining.
*
* @see #build()
*/
public ArraySchema.Builder setConstLength(
final List<Schema> constLength) {
this.constLength = constLength;
return this;
}
/*
* (non-Javadoc)
* @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
*/
@Override | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/ArraySchema.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
package name.jenkins.paul.john.concordia.schema;
/**
* <p>
* The array Concordia type. This must include either a single {@link Schema}
* defining a constant-type array or a list of {@link Schema}s defining a
* constant-length array.
* </p>
*
* <p>
* This class is immutable.
* </p>
*
* @author John Jenkins
*/
@JsonInclude(Include.NON_NULL)
public class ArraySchema extends Schema {
/**
* <p>
* A builder specifically for reference schemas.
* </p>
*
* @author John Jenkins
*/
public static class Builder extends Schema.Builder {
/**
* The {@link Schema} for this array if it is a constant-type array.
*/
private Schema constType;
/**
* The {@link Schema}s for this array if it is a constant-type array.
*/
private List<Schema> constLength;
/**
* Creates a builder based off of an existing schema.
*
* @param original
* The original schema to base the fields in this builder off
* of.
*/
public Builder(final ArraySchema original) {
super(original);
constType = original.constType;
constLength = original.constLength;
}
/**
* Returns the currently set type for a constant type array.
*
* @return The currently set type for a constant type array.
*/
public Schema getConstType() {
return constType;
}
/**
* Sets the type for a constant type array. This will not be checked
* with whether or not there is a constant length value until the
* schema is built. This may be null to clear the constant type-ness.
*
* @param constType
* The type for this constant type array.
*
* @return Returns this to facilitate chaining.
*
* @see #build()
*/
public ArraySchema.Builder setConstType(final Schema constType) {
this.constType = constType;
return this;
}
/**
* Returns the currently set list of types for a constant length array.
* The internal list is backed by the response value, so modifications
* to the returned list will be reflected in this builder.
*
* @return The currently set list of types for a constant length array.
*/
public List<Schema> getConstLength() {
return constLength;
}
/**
* Sets the list of types for a constant length array. This will not be
* checked with whether or not there is a constant type value until the
* schema is built. This may be null to clear the constant length-ness.
*
* @param constLength
* The list of types for this constant length array.
*
* @return Returns this to facilitate chaining.
*
* @see #build()
*/
public ArraySchema.Builder setConstLength(
final List<Schema> constLength) {
this.constLength = constLength;
return this;
}
/*
* (non-Javadoc)
* @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
*/
@Override | public ArraySchema build() throws ConcordiaException { |
jojenki/Concordia | lang/java/src/name/jenkins/paul/john/concordia/validator/StringValidator.java | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/StringSchema.java
// public class StringSchema extends Schema {
// /**
// * <p>
// * A builder specifically for reference schemas.
// * </p>
// *
// * @author John Jenkins
// */
// public static class Builder extends Schema.Builder {
// /**
// * Creates a builder based off of an existing schema.
// *
// * @param original
// * The original schema to base the fields in this builder off
// * of.
// */
// public Builder(final StringSchema original) {
// super(original);
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
// */
// @Override
// public StringSchema build() throws ConcordiaException {
// return
// new StringSchema(
// getDoc(),
// getOptional(),
// getName(),
// getOthers());
// }
// }
//
// /**
// * The field value for this type.
// */
// public static final String TYPE_ID = "string";
//
// /**
// * An ID for this class for serialization purposes.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates a new string schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// */
// @JsonCreator
// public StringSchema(
// @JsonProperty(JSON_KEY_DOC) final String doc,
// @JsonProperty(JSON_KEY_OPTIONAL) final boolean optional,
// @JsonProperty(ObjectSchema.JSON_KEY_NAME) final String name) {
//
// super(doc, optional, name, null);
// }
//
// /**
// * Creates a new string schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// *
// * @param others
// * Additional undefined fields that are being preserved.
// */
// protected StringSchema(
// final String doc,
// final boolean optional,
// final String name,
// final Map<String, Object> others) {
//
// super(doc, optional, name, others);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see name.jenkins.paul.john.concordia.schema.Schema#getType()
// */
// @Override
// public String getType() {
// return TYPE_ID;
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getSubSchemas()
// */
// @Override
// public List<Schema> getSubSchemas() {
// return Collections.emptyList();
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getBuilder()
// */
// @Override
// public Schema.Builder getBuilder() {
// return new StringSchema.Builder(this);
// }
// }
| import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import name.jenkins.paul.john.concordia.schema.StringSchema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.TextNode; | package name.jenkins.paul.john.concordia.validator;
/**
* The required validator for string schemas.
*
* @author John Jenkins
*/
public class StringValidator
implements | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/StringSchema.java
// public class StringSchema extends Schema {
// /**
// * <p>
// * A builder specifically for reference schemas.
// * </p>
// *
// * @author John Jenkins
// */
// public static class Builder extends Schema.Builder {
// /**
// * Creates a builder based off of an existing schema.
// *
// * @param original
// * The original schema to base the fields in this builder off
// * of.
// */
// public Builder(final StringSchema original) {
// super(original);
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
// */
// @Override
// public StringSchema build() throws ConcordiaException {
// return
// new StringSchema(
// getDoc(),
// getOptional(),
// getName(),
// getOthers());
// }
// }
//
// /**
// * The field value for this type.
// */
// public static final String TYPE_ID = "string";
//
// /**
// * An ID for this class for serialization purposes.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates a new string schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// */
// @JsonCreator
// public StringSchema(
// @JsonProperty(JSON_KEY_DOC) final String doc,
// @JsonProperty(JSON_KEY_OPTIONAL) final boolean optional,
// @JsonProperty(ObjectSchema.JSON_KEY_NAME) final String name) {
//
// super(doc, optional, name, null);
// }
//
// /**
// * Creates a new string schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// *
// * @param others
// * Additional undefined fields that are being preserved.
// */
// protected StringSchema(
// final String doc,
// final boolean optional,
// final String name,
// final Map<String, Object> others) {
//
// super(doc, optional, name, others);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see name.jenkins.paul.john.concordia.schema.Schema#getType()
// */
// @Override
// public String getType() {
// return TYPE_ID;
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getSubSchemas()
// */
// @Override
// public List<Schema> getSubSchemas() {
// return Collections.emptyList();
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getBuilder()
// */
// @Override
// public Schema.Builder getBuilder() {
// return new StringSchema.Builder(this);
// }
// }
// Path: lang/java/src/name/jenkins/paul/john/concordia/validator/StringValidator.java
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import name.jenkins.paul.john.concordia.schema.StringSchema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.TextNode;
package name.jenkins.paul.john.concordia.validator;
/**
* The required validator for string schemas.
*
* @author John Jenkins
*/
public class StringValidator
implements | SchemaValidator<StringSchema>, |
jojenki/Concordia | lang/java/src/name/jenkins/paul/john/concordia/validator/StringValidator.java | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/StringSchema.java
// public class StringSchema extends Schema {
// /**
// * <p>
// * A builder specifically for reference schemas.
// * </p>
// *
// * @author John Jenkins
// */
// public static class Builder extends Schema.Builder {
// /**
// * Creates a builder based off of an existing schema.
// *
// * @param original
// * The original schema to base the fields in this builder off
// * of.
// */
// public Builder(final StringSchema original) {
// super(original);
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
// */
// @Override
// public StringSchema build() throws ConcordiaException {
// return
// new StringSchema(
// getDoc(),
// getOptional(),
// getName(),
// getOthers());
// }
// }
//
// /**
// * The field value for this type.
// */
// public static final String TYPE_ID = "string";
//
// /**
// * An ID for this class for serialization purposes.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates a new string schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// */
// @JsonCreator
// public StringSchema(
// @JsonProperty(JSON_KEY_DOC) final String doc,
// @JsonProperty(JSON_KEY_OPTIONAL) final boolean optional,
// @JsonProperty(ObjectSchema.JSON_KEY_NAME) final String name) {
//
// super(doc, optional, name, null);
// }
//
// /**
// * Creates a new string schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// *
// * @param others
// * Additional undefined fields that are being preserved.
// */
// protected StringSchema(
// final String doc,
// final boolean optional,
// final String name,
// final Map<String, Object> others) {
//
// super(doc, optional, name, others);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see name.jenkins.paul.john.concordia.schema.Schema#getType()
// */
// @Override
// public String getType() {
// return TYPE_ID;
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getSubSchemas()
// */
// @Override
// public List<Schema> getSubSchemas() {
// return Collections.emptyList();
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getBuilder()
// */
// @Override
// public Schema.Builder getBuilder() {
// return new StringSchema.Builder(this);
// }
// }
| import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import name.jenkins.paul.john.concordia.schema.StringSchema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.TextNode; | package name.jenkins.paul.john.concordia.validator;
/**
* The required validator for string schemas.
*
* @author John Jenkins
*/
public class StringValidator
implements
SchemaValidator<StringSchema>,
DataValidator<StringSchema> {
/**
* Validates that some string schema is valid.
*/
@Override
public void validate(
final StringSchema schema, | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
//
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/StringSchema.java
// public class StringSchema extends Schema {
// /**
// * <p>
// * A builder specifically for reference schemas.
// * </p>
// *
// * @author John Jenkins
// */
// public static class Builder extends Schema.Builder {
// /**
// * Creates a builder based off of an existing schema.
// *
// * @param original
// * The original schema to base the fields in this builder off
// * of.
// */
// public Builder(final StringSchema original) {
// super(original);
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema.Builder#build()
// */
// @Override
// public StringSchema build() throws ConcordiaException {
// return
// new StringSchema(
// getDoc(),
// getOptional(),
// getName(),
// getOthers());
// }
// }
//
// /**
// * The field value for this type.
// */
// public static final String TYPE_ID = "string";
//
// /**
// * An ID for this class for serialization purposes.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates a new string schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// */
// @JsonCreator
// public StringSchema(
// @JsonProperty(JSON_KEY_DOC) final String doc,
// @JsonProperty(JSON_KEY_OPTIONAL) final boolean optional,
// @JsonProperty(ObjectSchema.JSON_KEY_NAME) final String name) {
//
// super(doc, optional, name, null);
// }
//
// /**
// * Creates a new string schema.
// *
// * @param doc
// * Optional documentation for this Schema.
// *
// * @param optional
// * Whether or not data for this Schema is optional.
// *
// * @param name
// * The name of this field, which is needed when constructing an
// * {@link ObjectSchema}.
// *
// * @param others
// * Additional undefined fields that are being preserved.
// */
// protected StringSchema(
// final String doc,
// final boolean optional,
// final String name,
// final Map<String, Object> others) {
//
// super(doc, optional, name, others);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see name.jenkins.paul.john.concordia.schema.Schema#getType()
// */
// @Override
// public String getType() {
// return TYPE_ID;
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getSubSchemas()
// */
// @Override
// public List<Schema> getSubSchemas() {
// return Collections.emptyList();
// }
//
// /*
// * (non-Javadoc)
// * @see name.jenkins.paul.john.concordia.schema.Schema#getBuilder()
// */
// @Override
// public Schema.Builder getBuilder() {
// return new StringSchema.Builder(this);
// }
// }
// Path: lang/java/src/name/jenkins/paul/john/concordia/validator/StringValidator.java
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import name.jenkins.paul.john.concordia.schema.StringSchema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.TextNode;
package name.jenkins.paul.john.concordia.validator;
/**
* The required validator for string schemas.
*
* @author John Jenkins
*/
public class StringValidator
implements
SchemaValidator<StringSchema>,
DataValidator<StringSchema> {
/**
* Validates that some string schema is valid.
*/
@Override
public void validate(
final StringSchema schema, | final ValidationController controller) throws ConcordiaException { |
jojenki/Concordia | lang/java/src/name/jenkins/paul/john/concordia/schema/Schema.java | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
| import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; | *
* @return Returns this to facilitate chaining.
*/
public Schema.Builder setName(final String name) {
this.name = name;
return this;
}
/**
* Returns the additional, undefined values.
*
* @return The additional, undefined values.
*/
protected Map<String, Object> getOthers() {
return others;
}
/**
* Uses the current state of this builder to produce a Schema object.
* This may be called any number of times without affecting the state
* of the builder.
*
* @return A Schema object whose type is based on how this builder was
* created.
*
* @throws ConcordiaException
* The state of this builder is invalid for building a Survey
* object.
*/ | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
// Path: lang/java/src/name/jenkins/paul/john/concordia/schema/Schema.java
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
*
* @return Returns this to facilitate chaining.
*/
public Schema.Builder setName(final String name) {
this.name = name;
return this;
}
/**
* Returns the additional, undefined values.
*
* @return The additional, undefined values.
*/
protected Map<String, Object> getOthers() {
return others;
}
/**
* Uses the current state of this builder to produce a Schema object.
* This may be called any number of times without affecting the state
* of the builder.
*
* @return A Schema object whose type is based on how this builder was
* created.
*
* @throws ConcordiaException
* The state of this builder is invalid for building a Survey
* object.
*/ | public abstract Schema build() throws ConcordiaException; |
jojenki/Concordia | lang/java/test/name/jenkins/paul/john/concordia/StaticServer.java | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
| import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import org.junit.Ignore;
import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer; | package name.jenkins.paul.john.concordia;
/**
* <p>
* Starts a HTTP server on the specified ports and gives the user control over
* the response.
* </p>
*
* @author John Jenkins
*/
@Ignore
public class StaticServer {
/**
* <p>
* This is a very lightweight handler for responding to requests.
* </p>
*
* @author John Jenkins
*/
@Ignore
private static class RequestHandler implements HttpHandler {
public int responseCode = 200;
public String response = "";
/*
* (non-Javadoc)
* @see com.sun.net.httpserver.HttpHandler#handle(com.sun.net.httpserver.HttpExchange)
*/
@Override
public void handle(final HttpExchange exchange) throws IOException {
Headers responseHeaders = exchange.getResponseHeaders();
responseHeaders.add("Content-Type", "application/json");
exchange.sendResponseHeaders(responseCode, response.length());
OutputStream responseBody = exchange.getResponseBody();
responseBody.write(response.getBytes());
responseBody.close();
}
}
/**
* The port which this private server will connect to.
*/
public static final int DEFAULT_PORT = 60000;
/**
* The server instance.
*/
private final HttpServer server;
/**
* The handler for requests.
*/
private final RequestHandler handler;
/**
* Creates a new HTTP server at the given port.
*
* @param port The port to attach.
*
* @throws ConcordiaException There was an error starting the server.
*/ | // Path: lang/java/src/name/jenkins/paul/john/concordia/exception/ConcordiaException.java
// public class ConcordiaException extends Exception {
// /**
// * The version of this exception class.
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Creates an exception with a reason why this exception was thrown.
// *
// * @param reason
// * The user-friendly reason this exception was thrown.
// */
// public ConcordiaException(final String reason) {
// super(reason);
// }
//
// /**
// * Creates an exception with an underlying cause.
// *
// * @param cause
// * The cause for the exception.
// */
// public ConcordiaException(final Throwable cause) {
// super(cause);
// }
//
// /**
// * Creates an exception with a reason and an underlying cause.
// *
// * @param reason
// * The reason this exception was thrown.
// *
// * @param cause
// * The underlying cause of this exception.
// */
// public ConcordiaException(final String reason, final Throwable cause) {
// super(reason, cause);
// }
// }
// Path: lang/java/test/name/jenkins/paul/john/concordia/StaticServer.java
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import name.jenkins.paul.john.concordia.exception.ConcordiaException;
import org.junit.Ignore;
import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
package name.jenkins.paul.john.concordia;
/**
* <p>
* Starts a HTTP server on the specified ports and gives the user control over
* the response.
* </p>
*
* @author John Jenkins
*/
@Ignore
public class StaticServer {
/**
* <p>
* This is a very lightweight handler for responding to requests.
* </p>
*
* @author John Jenkins
*/
@Ignore
private static class RequestHandler implements HttpHandler {
public int responseCode = 200;
public String response = "";
/*
* (non-Javadoc)
* @see com.sun.net.httpserver.HttpHandler#handle(com.sun.net.httpserver.HttpExchange)
*/
@Override
public void handle(final HttpExchange exchange) throws IOException {
Headers responseHeaders = exchange.getResponseHeaders();
responseHeaders.add("Content-Type", "application/json");
exchange.sendResponseHeaders(responseCode, response.length());
OutputStream responseBody = exchange.getResponseBody();
responseBody.write(response.getBytes());
responseBody.close();
}
}
/**
* The port which this private server will connect to.
*/
public static final int DEFAULT_PORT = 60000;
/**
* The server instance.
*/
private final HttpServer server;
/**
* The handler for requests.
*/
private final RequestHandler handler;
/**
* Creates a new HTTP server at the given port.
*
* @param port The port to attach.
*
* @throws ConcordiaException There was an error starting the server.
*/ | public StaticServer(final int port) throws ConcordiaException { |
DavidShepherdson/jira-suite-utilities | src/main/java/com/googlecode/jsu/transitionssummary/issuetabpanel/TransitionSummaryAction.java | // Path: src/main/java/com/googlecode/jsu/transitionssummary/TransitionSummary.java
// public class TransitionSummary {
// private String id;
// private Status fromStatus;
// private Status toStatus;
// private Long duration;
// private String lastUpdater;
// private Timestamp lastUpdate;
// private List<Transition> transitions = new ArrayList<Transition>();
//
// /**
// * @param id an external ID generate.
// * @param fromStatus
// * @param toStatus
// */
// public TransitionSummary(String id, Status fromStatus, Status toStatus){
// setId(id);
// setFromStatus(fromStatus);
// setToStatus(toStatus);
// setDuration(new Long("0"));
// }
//
// /**
// * @param tran a simple Transition.
// *
// * Allows to add a transition and recalculate the summary values.
// */
// public void addTransition(Transition tran){
// transitions.add(tran);
//
// setLastUpdater(tran.getChangedBy());
// setLastupdate(tran.getChangedAt());
//
// addTime(tran.getDurationInMillis());
// }
//
// /**
// * @return a nice String format of the duration.
// */
// public String getDurationAsString(){
// String retVal = "";
// Long duration = this.getDurationInMillis();
//
// if(duration!=new Long("0")){
// Long days = new Long(duration.longValue() / 86400000);
// Long restDay = new Long(duration.longValue() % 86400000);
//
// Long hours = new Long(restDay.longValue() / 3600000);
// Long resthours = new Long(restDay.longValue() % 3600000);
//
// Long minutes = new Long(resthours.longValue() / 60000);
// Long restMinutes = new Long(resthours.longValue() % 60000);
//
// Long seconds = new Long(restMinutes.longValue() / 1000);
//
// // If it has been days, it does not have sense to show the seconds.
// retVal = days.equals(new Long("0"))?"":String.valueOf(days) + "d ";
// retVal = retVal + (hours.equals(new Long("0"))?"":String.valueOf(hours) + "h ");
// retVal = retVal + (minutes.equals(new Long("0"))?"":String.valueOf(minutes) + "m ");
// if((days.equals(new Long("0"))) && (hours.equals(new Long("0")))){
// retVal = retVal + (seconds.equals(new Long("0"))?"":String.valueOf(seconds) + "s");
// }
//
// }else{
// retVal = "0s";
// }
//
// return retVal;
// }
//
// public int getTimesToTransition(){
// return transitions.size();
// }
//
// private void addTime(Long timeInMillis){
// setDuration(new Long(getDurationInMillis().longValue() + timeInMillis.longValue()));
// }
//
// public String getId() {
// return id;
// }
//
// public Status getFromStatus() {
// return fromStatus;
// }
//
// public Status getToStatus() {
// return toStatus;
// }
//
// /**
// * @return a nice formatted date as String.
// */
// public String getLastUpdateAsString(){
// return CommonPluginUtils.getNiceDate(lastUpdate);
// }
//
// /**
// * @return the lastUpdate
// */
// public Timestamp getLastUpdate() {
// return lastUpdate;
// }
//
// public String getLastUpdater() {
// return lastUpdater;
// }
//
// private void setId(String id) {
// this.id = id;
// }
//
// public Long getDurationInMillis() {
// return duration;
// }
//
// private void setFromStatus(Status fromStatus) {
// this.fromStatus = fromStatus;
// }
//
// private void setToStatus(Status toStatus) {
// this.toStatus = toStatus;
// }
//
// private void setLastupdate(Timestamp lastupdate) {
// this.lastUpdate = lastupdate;
// }
//
// private void setLastUpdater(String lastUpdater) {
// this.lastUpdater = lastUpdater;
// }
//
// private void setDuration(Long duration) {
// this.duration = duration;
// }
//
// }
| import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.ofbiz.core.util.UtilMisc;
import com.atlassian.core.user.UserUtils;
import com.atlassian.jira.plugin.issuetabpanel.AbstractIssueAction;
import com.atlassian.jira.plugin.issuetabpanel.IssueTabPanelModuleDescriptor;
import com.atlassian.jira.web.action.JiraWebActionSupport;
import com.googlecode.jsu.transitionssummary.TransitionSummary;
import com.opensymphony.user.EntityNotFoundException;
| package com.googlecode.jsu.transitionssummary.issuetabpanel;
/**
* @author Gustavo Martin
*
* This is a valid Action, that it allows to visualize the Transition Summaries.
*/
public class TransitionSummaryAction extends AbstractIssueAction {
protected final IssueTabPanelModuleDescriptor descriptor;
| // Path: src/main/java/com/googlecode/jsu/transitionssummary/TransitionSummary.java
// public class TransitionSummary {
// private String id;
// private Status fromStatus;
// private Status toStatus;
// private Long duration;
// private String lastUpdater;
// private Timestamp lastUpdate;
// private List<Transition> transitions = new ArrayList<Transition>();
//
// /**
// * @param id an external ID generate.
// * @param fromStatus
// * @param toStatus
// */
// public TransitionSummary(String id, Status fromStatus, Status toStatus){
// setId(id);
// setFromStatus(fromStatus);
// setToStatus(toStatus);
// setDuration(new Long("0"));
// }
//
// /**
// * @param tran a simple Transition.
// *
// * Allows to add a transition and recalculate the summary values.
// */
// public void addTransition(Transition tran){
// transitions.add(tran);
//
// setLastUpdater(tran.getChangedBy());
// setLastupdate(tran.getChangedAt());
//
// addTime(tran.getDurationInMillis());
// }
//
// /**
// * @return a nice String format of the duration.
// */
// public String getDurationAsString(){
// String retVal = "";
// Long duration = this.getDurationInMillis();
//
// if(duration!=new Long("0")){
// Long days = new Long(duration.longValue() / 86400000);
// Long restDay = new Long(duration.longValue() % 86400000);
//
// Long hours = new Long(restDay.longValue() / 3600000);
// Long resthours = new Long(restDay.longValue() % 3600000);
//
// Long minutes = new Long(resthours.longValue() / 60000);
// Long restMinutes = new Long(resthours.longValue() % 60000);
//
// Long seconds = new Long(restMinutes.longValue() / 1000);
//
// // If it has been days, it does not have sense to show the seconds.
// retVal = days.equals(new Long("0"))?"":String.valueOf(days) + "d ";
// retVal = retVal + (hours.equals(new Long("0"))?"":String.valueOf(hours) + "h ");
// retVal = retVal + (minutes.equals(new Long("0"))?"":String.valueOf(minutes) + "m ");
// if((days.equals(new Long("0"))) && (hours.equals(new Long("0")))){
// retVal = retVal + (seconds.equals(new Long("0"))?"":String.valueOf(seconds) + "s");
// }
//
// }else{
// retVal = "0s";
// }
//
// return retVal;
// }
//
// public int getTimesToTransition(){
// return transitions.size();
// }
//
// private void addTime(Long timeInMillis){
// setDuration(new Long(getDurationInMillis().longValue() + timeInMillis.longValue()));
// }
//
// public String getId() {
// return id;
// }
//
// public Status getFromStatus() {
// return fromStatus;
// }
//
// public Status getToStatus() {
// return toStatus;
// }
//
// /**
// * @return a nice formatted date as String.
// */
// public String getLastUpdateAsString(){
// return CommonPluginUtils.getNiceDate(lastUpdate);
// }
//
// /**
// * @return the lastUpdate
// */
// public Timestamp getLastUpdate() {
// return lastUpdate;
// }
//
// public String getLastUpdater() {
// return lastUpdater;
// }
//
// private void setId(String id) {
// this.id = id;
// }
//
// public Long getDurationInMillis() {
// return duration;
// }
//
// private void setFromStatus(Status fromStatus) {
// this.fromStatus = fromStatus;
// }
//
// private void setToStatus(Status toStatus) {
// this.toStatus = toStatus;
// }
//
// private void setLastupdate(Timestamp lastupdate) {
// this.lastUpdate = lastupdate;
// }
//
// private void setLastUpdater(String lastUpdater) {
// this.lastUpdater = lastUpdater;
// }
//
// private void setDuration(Long duration) {
// this.duration = duration;
// }
//
// }
// Path: src/main/java/com/googlecode/jsu/transitionssummary/issuetabpanel/TransitionSummaryAction.java
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.ofbiz.core.util.UtilMisc;
import com.atlassian.core.user.UserUtils;
import com.atlassian.jira.plugin.issuetabpanel.AbstractIssueAction;
import com.atlassian.jira.plugin.issuetabpanel.IssueTabPanelModuleDescriptor;
import com.atlassian.jira.web.action.JiraWebActionSupport;
import com.googlecode.jsu.transitionssummary.TransitionSummary;
import com.opensymphony.user.EntityNotFoundException;
package com.googlecode.jsu.transitionssummary.issuetabpanel;
/**
* @author Gustavo Martin
*
* This is a valid Action, that it allows to visualize the Transition Summaries.
*/
public class TransitionSummaryAction extends AbstractIssueAction {
protected final IssueTabPanelModuleDescriptor descriptor;
| protected List<TransitionSummary> tranSummaries;
|
DavidShepherdson/jira-suite-utilities | src/main/java/com/googlecode/jsu/customfields/TextSearcher.java | // Path: src/main/java/com/googlecode/jsu/util/ComponentUtils.java
// public static <T> T getComponent(Class<T> clazz) {
// notNull("class", clazz);
//
// T component = getComponentInstanceOfType(clazz);
//
// if (component == null) {
// // Didn't find in pico container
// component = getOSGiComponentInstanceOfType(clazz);
// }
//
// notNull(clazz.getSimpleName(), component);
//
// return component;
// }
| import static com.googlecode.jsu.util.ComponentUtils.getComponent;
import com.atlassian.jira.issue.customfields.searchers.transformer.CustomFieldInputHelper;
import com.atlassian.jira.jql.operand.JqlOperandResolver;
import com.atlassian.jira.web.FieldVisibilityManager; | package com.googlecode.jsu.customfields;
/**
* Wrapper on Jira TextSearcher for using inside plugins v2.
*
* @author <A href="mailto:abashev at gmail dot com">Alexey Abashev</A>
* @version $Id$
*/
public class TextSearcher extends com.atlassian.jira.issue.customfields.searchers.TextSearcher {
/**
* Default constructor without injection.
*/
public TextSearcher() {
super( | // Path: src/main/java/com/googlecode/jsu/util/ComponentUtils.java
// public static <T> T getComponent(Class<T> clazz) {
// notNull("class", clazz);
//
// T component = getComponentInstanceOfType(clazz);
//
// if (component == null) {
// // Didn't find in pico container
// component = getOSGiComponentInstanceOfType(clazz);
// }
//
// notNull(clazz.getSimpleName(), component);
//
// return component;
// }
// Path: src/main/java/com/googlecode/jsu/customfields/TextSearcher.java
import static com.googlecode.jsu.util.ComponentUtils.getComponent;
import com.atlassian.jira.issue.customfields.searchers.transformer.CustomFieldInputHelper;
import com.atlassian.jira.jql.operand.JqlOperandResolver;
import com.atlassian.jira.web.FieldVisibilityManager;
package com.googlecode.jsu.customfields;
/**
* Wrapper on Jira TextSearcher for using inside plugins v2.
*
* @author <A href="mailto:abashev at gmail dot com">Alexey Abashev</A>
* @version $Id$
*/
public class TextSearcher extends com.atlassian.jira.issue.customfields.searchers.TextSearcher {
/**
* Default constructor without injection.
*/
public TextSearcher() {
super( | getComponent(FieldVisibilityManager.class), |
DavidShepherdson/jira-suite-utilities | src/main/java/com/googlecode/jsu/customfields/LocationTextCFType.java | // Path: src/main/java/com/googlecode/jsu/util/ComponentUtils.java
// public static <T> T getComponent(Class<T> clazz) {
// notNull("class", clazz);
//
// T component = getComponentInstanceOfType(clazz);
//
// if (component == null) {
// // Didn't find in pico container
// component = getOSGiComponentInstanceOfType(clazz);
// }
//
// notNull(clazz.getSimpleName(), component);
//
// return component;
// }
| import static com.googlecode.jsu.util.ComponentUtils.getComponent;
import com.atlassian.jira.issue.customfields.converters.StringConverter;
import com.atlassian.jira.issue.customfields.impl.RenderableTextCFType;
import com.atlassian.jira.issue.customfields.manager.GenericConfigManager;
import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister; | package com.googlecode.jsu.customfields;
/**
* Wrapper on Jira RenderableTextCFType for using inside plugins v2.
*
* @author <A href="mailto:abashev at gmail dot com">Alexey Abashev</A>
* @version $Id$
*/
public class LocationTextCFType extends RenderableTextCFType {
/**
* Default constructor without injection.
*/
public LocationTextCFType() {
super( | // Path: src/main/java/com/googlecode/jsu/util/ComponentUtils.java
// public static <T> T getComponent(Class<T> clazz) {
// notNull("class", clazz);
//
// T component = getComponentInstanceOfType(clazz);
//
// if (component == null) {
// // Didn't find in pico container
// component = getOSGiComponentInstanceOfType(clazz);
// }
//
// notNull(clazz.getSimpleName(), component);
//
// return component;
// }
// Path: src/main/java/com/googlecode/jsu/customfields/LocationTextCFType.java
import static com.googlecode.jsu.util.ComponentUtils.getComponent;
import com.atlassian.jira.issue.customfields.converters.StringConverter;
import com.atlassian.jira.issue.customfields.impl.RenderableTextCFType;
import com.atlassian.jira.issue.customfields.manager.GenericConfigManager;
import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister;
package com.googlecode.jsu.customfields;
/**
* Wrapper on Jira RenderableTextCFType for using inside plugins v2.
*
* @author <A href="mailto:abashev at gmail dot com">Alexey Abashev</A>
* @version $Id$
*/
public class LocationTextCFType extends RenderableTextCFType {
/**
* Default constructor without injection.
*/
public LocationTextCFType() {
super( | getComponent(CustomFieldValuePersister.class), |
DavidShepherdson/jira-suite-utilities | src/main/java/com/googlecode/jsu/util/CommonPluginUtils.java | // Path: src/main/java/com/googlecode/jsu/helpers/NameComparatorEx.java
// public class NameComparatorEx implements Comparator<Field> {
// private final I18nBean i18nBean;
//
// public NameComparatorEx(I18nBean i18nBean) {
// this.i18nBean = i18nBean;
// }
//
// public int compare(Field o1, Field o2) {
// if (o1 == null)
// throw new IllegalArgumentException("The first parameter is null");
// if (o2 == null)
// throw new IllegalArgumentException("The second parameter is null");
//
// String name1 = i18nBean.getText(o1.getName());
// String name2 = i18nBean.getText(o2.getName());
//
// return name1.compareTo(name2);
// }
// }
| import static com.atlassian.jira.issue.IssueFieldConstants.*;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.apache.log4j.Logger;
import org.ofbiz.core.entity.model.ModelEntity;
import org.ofbiz.core.entity.model.ModelField;
import com.atlassian.core.ofbiz.CoreFactory;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.ManagerFactory;
import com.atlassian.jira.config.properties.ApplicationProperties;
import com.atlassian.jira.config.properties.ApplicationPropertiesImpl;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueFieldConstants;
import com.atlassian.jira.issue.customfields.CustomFieldType;
import com.atlassian.jira.issue.customfields.impl.DateCFType;
import com.atlassian.jira.issue.customfields.impl.DateTimeCFType;
import com.atlassian.jira.issue.customfields.impl.ImportIdLinkCFType;
import com.atlassian.jira.issue.customfields.impl.ReadOnlyCFType;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.Field;
import com.atlassian.jira.issue.fields.FieldException;
import com.atlassian.jira.issue.fields.FieldManager;
import com.atlassian.jira.issue.fields.NavigableField;
import com.atlassian.jira.issue.fields.config.FieldConfig;
import com.atlassian.jira.issue.fields.layout.field.FieldLayout;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutStorageException;
import com.atlassian.jira.issue.fields.screen.FieldScreen;
import com.atlassian.jira.issue.fields.screen.FieldScreenLayoutItem;
import com.atlassian.jira.issue.fields.screen.FieldScreenTab;
import com.atlassian.jira.util.I18nHelper;
import com.atlassian.jira.web.FieldVisibilityManager;
import com.atlassian.jira.web.bean.I18nBean;
import com.googlecode.jsu.helpers.NameComparatorEx;
| * Clear the time part from a given Calendar.
*
*/
public static void clearCalendarTimePart(Calendar cal) {
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
}
/**
* @param tsDate
* @return a String.
*
* It formats to a date nice.
*/
public static String getNiceDate(Timestamp tsDate){
Date timePerformed = new Date(tsDate.getTime());
I18nHelper i18n = new I18nBean();
return ManagerFactory.getOutlookDateManager().getOutlookDate(i18n.getLocale()).formatDMYHMS(timePerformed);
}
/**
* Get comparator for sorting fields.
* @return
*/
private static Comparator<Field> getComparator() {
ApplicationProperties ap = new ApplicationPropertiesImpl();
I18nBean i18n = new I18nBean(ap.getDefaultLocale().getDisplayName());
| // Path: src/main/java/com/googlecode/jsu/helpers/NameComparatorEx.java
// public class NameComparatorEx implements Comparator<Field> {
// private final I18nBean i18nBean;
//
// public NameComparatorEx(I18nBean i18nBean) {
// this.i18nBean = i18nBean;
// }
//
// public int compare(Field o1, Field o2) {
// if (o1 == null)
// throw new IllegalArgumentException("The first parameter is null");
// if (o2 == null)
// throw new IllegalArgumentException("The second parameter is null");
//
// String name1 = i18nBean.getText(o1.getName());
// String name2 = i18nBean.getText(o2.getName());
//
// return name1.compareTo(name2);
// }
// }
// Path: src/main/java/com/googlecode/jsu/util/CommonPluginUtils.java
import static com.atlassian.jira.issue.IssueFieldConstants.*;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.apache.log4j.Logger;
import org.ofbiz.core.entity.model.ModelEntity;
import org.ofbiz.core.entity.model.ModelField;
import com.atlassian.core.ofbiz.CoreFactory;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.ManagerFactory;
import com.atlassian.jira.config.properties.ApplicationProperties;
import com.atlassian.jira.config.properties.ApplicationPropertiesImpl;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueFieldConstants;
import com.atlassian.jira.issue.customfields.CustomFieldType;
import com.atlassian.jira.issue.customfields.impl.DateCFType;
import com.atlassian.jira.issue.customfields.impl.DateTimeCFType;
import com.atlassian.jira.issue.customfields.impl.ImportIdLinkCFType;
import com.atlassian.jira.issue.customfields.impl.ReadOnlyCFType;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.Field;
import com.atlassian.jira.issue.fields.FieldException;
import com.atlassian.jira.issue.fields.FieldManager;
import com.atlassian.jira.issue.fields.NavigableField;
import com.atlassian.jira.issue.fields.config.FieldConfig;
import com.atlassian.jira.issue.fields.layout.field.FieldLayout;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutStorageException;
import com.atlassian.jira.issue.fields.screen.FieldScreen;
import com.atlassian.jira.issue.fields.screen.FieldScreenLayoutItem;
import com.atlassian.jira.issue.fields.screen.FieldScreenTab;
import com.atlassian.jira.util.I18nHelper;
import com.atlassian.jira.web.FieldVisibilityManager;
import com.atlassian.jira.web.bean.I18nBean;
import com.googlecode.jsu.helpers.NameComparatorEx;
* Clear the time part from a given Calendar.
*
*/
public static void clearCalendarTimePart(Calendar cal) {
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
}
/**
* @param tsDate
* @return a String.
*
* It formats to a date nice.
*/
public static String getNiceDate(Timestamp tsDate){
Date timePerformed = new Date(tsDate.getTime());
I18nHelper i18n = new I18nBean();
return ManagerFactory.getOutlookDateManager().getOutlookDate(i18n.getLocale()).formatDMYHMS(timePerformed);
}
/**
* Get comparator for sorting fields.
* @return
*/
private static Comparator<Field> getComparator() {
ApplicationProperties ap = new ApplicationPropertiesImpl();
I18nBean i18n = new I18nBean(ap.getDefaultLocale().getDisplayName());
| return new NameComparatorEx(i18n);
|
DavidShepherdson/jira-suite-utilities | src/main/java/com/googlecode/jsu/customfields/LocationSelectCFType.java | // Path: src/main/java/com/googlecode/jsu/util/ComponentUtils.java
// public static <T> T getComponent(Class<T> clazz) {
// notNull("class", clazz);
//
// T component = getComponentInstanceOfType(clazz);
//
// if (component == null) {
// // Didn't find in pico container
// component = getOSGiComponentInstanceOfType(clazz);
// }
//
// notNull(clazz.getSimpleName(), component);
//
// return component;
// }
| import static com.googlecode.jsu.util.ComponentUtils.getComponent;
import com.atlassian.jira.issue.customfields.converters.SelectConverter;
import com.atlassian.jira.issue.customfields.converters.StringConverter;
import com.atlassian.jira.issue.customfields.impl.SelectCFType;
import com.atlassian.jira.issue.customfields.manager.GenericConfigManager;
import com.atlassian.jira.issue.customfields.manager.OptionsManager;
import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister; | package com.googlecode.jsu.customfields;
/**
* Wrapper on Jira SelectCFType for using inside plugins v2.
*
* @author <A href="mailto:abashev at gmail dot com">Alexey Abashev</A>
* @version $Id$
*/
public class LocationSelectCFType extends SelectCFType {
/**
* Default constructor without injection.
*/
public LocationSelectCFType() {
super( | // Path: src/main/java/com/googlecode/jsu/util/ComponentUtils.java
// public static <T> T getComponent(Class<T> clazz) {
// notNull("class", clazz);
//
// T component = getComponentInstanceOfType(clazz);
//
// if (component == null) {
// // Didn't find in pico container
// component = getOSGiComponentInstanceOfType(clazz);
// }
//
// notNull(clazz.getSimpleName(), component);
//
// return component;
// }
// Path: src/main/java/com/googlecode/jsu/customfields/LocationSelectCFType.java
import static com.googlecode.jsu.util.ComponentUtils.getComponent;
import com.atlassian.jira.issue.customfields.converters.SelectConverter;
import com.atlassian.jira.issue.customfields.converters.StringConverter;
import com.atlassian.jira.issue.customfields.impl.SelectCFType;
import com.atlassian.jira.issue.customfields.manager.GenericConfigManager;
import com.atlassian.jira.issue.customfields.manager.OptionsManager;
import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister;
package com.googlecode.jsu.customfields;
/**
* Wrapper on Jira SelectCFType for using inside plugins v2.
*
* @author <A href="mailto:abashev at gmail dot com">Alexey Abashev</A>
* @version $Id$
*/
public class LocationSelectCFType extends SelectCFType {
/**
* Default constructor without injection.
*/
public LocationSelectCFType() {
super( | getComponent(CustomFieldValuePersister.class), |
DavidShepherdson/jira-suite-utilities | src/main/java/com/googlecode/jsu/helpers/ConditionCheckerFactory.java | // Path: src/main/java/com/googlecode/jsu/helpers/checkers/CheckerCompositeFactory.java
// public class CheckerCompositeFactory {
// private static final Logger log = Logger.getLogger(CheckerCompositeFactory.class);
//
// /**
// * Create composite for checking values.
// *
// * @param converterClass
// * @param snipetClass
// * @return
// */
// public CheckerComposite getComposite(String converterClass, String snipetClass) {
// ComparingSnipet snipet = getInstance(snipetClass);
//
// if (snipet == null) {
// return null;
// }
//
// ValueConverter converter = getInstance(converterClass);
//
// if (converter == null) {
// return null;
// }
//
// return (new CheckerComposite(converter, snipet));
// }
//
// @SuppressWarnings("unchecked")
// private <T> T getInstance(String className) {
// T instance = null;
//
// try {
// instance = (T) Class.forName(className).newInstance();
// } catch (InstantiationException e) {
// log.error("Unable to initialize class [" + className + "]", e);
// } catch (IllegalAccessException e) {
// log.error("Unable to initialize class [" + className + "]", e);
// } catch (ClassNotFoundException e) {
// log.error("Unable to initialize class [" + className + "]", e);
// }
//
// return instance;
// }
// }
| import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import com.googlecode.jsu.helpers.checkers.CheckerCompositeFactory; | package com.googlecode.jsu.helpers;
/**
* Return object for checking conditions.
*
* @author <A href="mailto:abashev at gmail dot com">Alexey Abashev</A>
* @version $Id: GenericValidator.java 173 2008-10-14 13:04:43Z abashev $
*/
public class ConditionCheckerFactory {
public static final ConditionType GREATER = new ConditionType(1, ">", "greater than", "G");
public static final ConditionType GREATER_EQUAL = new ConditionType(2, ">=", "greater than or equal to", "GE");
public static final ConditionType EQUAL = new ConditionType(3, "=", "equal to", "E");
public static final ConditionType LESS_EQUAL = new ConditionType(4, "<=", "less than or equal to", "LE");
public static final ConditionType LESS = new ConditionType(5, "<", "less than", "L");
public static final ConditionType NOT_EQUAL = new ConditionType(6, "!=", "not equal to", "NE");
public static final ComparisonType STRING = new ComparisonType(1, "String", "String");
public static final ComparisonType NUMBER = new ComparisonType(2, "Number", "Number");
public static final ComparisonType DATE = new ComparisonType(3, "Date with time", "Date");
public static final ComparisonType DATE_WITHOUT_TIME = new ComparisonType(4, "Date without time", "DateWithoutTime");
/** Template for checker class. */
private static final String PACKAGE = ConditionCheckerFactory.class.getPackage().getName();
private static final String CONDITION_CLASS_TEMPLATE = PACKAGE + ".checkers.Snipet";
private static final String COMPARISON_CLASS_TEMPLATE = PACKAGE + ".checkers.Converter";
/** Cache for searching through conditions */
@SuppressWarnings("serial")
private static final Map<Integer, ConditionType> CONDITIONS_CACHE =
new LinkedHashMap<Integer, ConditionType>(6) {{
put(GREATER.getId(), GREATER);
put(GREATER_EQUAL.getId(), GREATER_EQUAL);
put(EQUAL.getId(), EQUAL);
put(LESS_EQUAL.getId(), LESS_EQUAL);
put(LESS.getId(), LESS);
put(NOT_EQUAL.getId(), NOT_EQUAL);
}};
/** Cache for searching through types */
@SuppressWarnings("serial")
private static final Map<Integer, ComparisonType> COMPARISONS_CACHE =
new LinkedHashMap<Integer, ComparisonType>(4) {{
put(STRING.getId(), STRING);
put(NUMBER.getId(), NUMBER);
put(DATE.getId(), DATE);
put(DATE_WITHOUT_TIME.getId(), DATE_WITHOUT_TIME);
}};
private final Logger log = Logger.getLogger(ConditionCheckerFactory.class); | // Path: src/main/java/com/googlecode/jsu/helpers/checkers/CheckerCompositeFactory.java
// public class CheckerCompositeFactory {
// private static final Logger log = Logger.getLogger(CheckerCompositeFactory.class);
//
// /**
// * Create composite for checking values.
// *
// * @param converterClass
// * @param snipetClass
// * @return
// */
// public CheckerComposite getComposite(String converterClass, String snipetClass) {
// ComparingSnipet snipet = getInstance(snipetClass);
//
// if (snipet == null) {
// return null;
// }
//
// ValueConverter converter = getInstance(converterClass);
//
// if (converter == null) {
// return null;
// }
//
// return (new CheckerComposite(converter, snipet));
// }
//
// @SuppressWarnings("unchecked")
// private <T> T getInstance(String className) {
// T instance = null;
//
// try {
// instance = (T) Class.forName(className).newInstance();
// } catch (InstantiationException e) {
// log.error("Unable to initialize class [" + className + "]", e);
// } catch (IllegalAccessException e) {
// log.error("Unable to initialize class [" + className + "]", e);
// } catch (ClassNotFoundException e) {
// log.error("Unable to initialize class [" + className + "]", e);
// }
//
// return instance;
// }
// }
// Path: src/main/java/com/googlecode/jsu/helpers/ConditionCheckerFactory.java
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import com.googlecode.jsu.helpers.checkers.CheckerCompositeFactory;
package com.googlecode.jsu.helpers;
/**
* Return object for checking conditions.
*
* @author <A href="mailto:abashev at gmail dot com">Alexey Abashev</A>
* @version $Id: GenericValidator.java 173 2008-10-14 13:04:43Z abashev $
*/
public class ConditionCheckerFactory {
public static final ConditionType GREATER = new ConditionType(1, ">", "greater than", "G");
public static final ConditionType GREATER_EQUAL = new ConditionType(2, ">=", "greater than or equal to", "GE");
public static final ConditionType EQUAL = new ConditionType(3, "=", "equal to", "E");
public static final ConditionType LESS_EQUAL = new ConditionType(4, "<=", "less than or equal to", "LE");
public static final ConditionType LESS = new ConditionType(5, "<", "less than", "L");
public static final ConditionType NOT_EQUAL = new ConditionType(6, "!=", "not equal to", "NE");
public static final ComparisonType STRING = new ComparisonType(1, "String", "String");
public static final ComparisonType NUMBER = new ComparisonType(2, "Number", "Number");
public static final ComparisonType DATE = new ComparisonType(3, "Date with time", "Date");
public static final ComparisonType DATE_WITHOUT_TIME = new ComparisonType(4, "Date without time", "DateWithoutTime");
/** Template for checker class. */
private static final String PACKAGE = ConditionCheckerFactory.class.getPackage().getName();
private static final String CONDITION_CLASS_TEMPLATE = PACKAGE + ".checkers.Snipet";
private static final String COMPARISON_CLASS_TEMPLATE = PACKAGE + ".checkers.Converter";
/** Cache for searching through conditions */
@SuppressWarnings("serial")
private static final Map<Integer, ConditionType> CONDITIONS_CACHE =
new LinkedHashMap<Integer, ConditionType>(6) {{
put(GREATER.getId(), GREATER);
put(GREATER_EQUAL.getId(), GREATER_EQUAL);
put(EQUAL.getId(), EQUAL);
put(LESS_EQUAL.getId(), LESS_EQUAL);
put(LESS.getId(), LESS);
put(NOT_EQUAL.getId(), NOT_EQUAL);
}};
/** Cache for searching through types */
@SuppressWarnings("serial")
private static final Map<Integer, ComparisonType> COMPARISONS_CACHE =
new LinkedHashMap<Integer, ComparisonType>(4) {{
put(STRING.getId(), STRING);
put(NUMBER.getId(), NUMBER);
put(DATE.getId(), DATE);
put(DATE_WITHOUT_TIME.getId(), DATE_WITHOUT_TIME);
}};
private final Logger log = Logger.getLogger(ConditionCheckerFactory.class); | private final CheckerCompositeFactory checkerCompositeFactory = new CheckerCompositeFactory(); |
larusba/neo4j-jdbc | neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/MybatisTestUtil.java | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/mapper/ActorMapper.java
// public interface ActorMapper {
// public Actor selectActorByBorn(int born);
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
| import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.jdbc.example.mybatis.mapper.ActorMapper;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
import javax.sql.DataSource;
import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label; | /*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class MybatisTestUtil {
public enum TestLabels implements Label {
Person
}
protected static void populateGraphDB(GraphDatabaseService graphDatabaseService) {
try (Transaction tx = graphDatabaseService.beginTx()) {
Node node = graphDatabaseService.createNode(TestLabels.Person);
node.setProperty("name", "Dave Chappelle");
node.setProperty("born", 1973);
tx.success();
}
}
protected void buildMybatisConfiguration(String protocol, String host, int port) {
DataSource dataSource = new UnpooledDataSource("org.neo4j.jdbc.Driver", "jdbc:neo4j:" + protocol + "://" + host + ":" + port + "?nossl", null);
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("development", transactionFactory, dataSource);
Configuration configuration = new Configuration(environment); | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/mapper/ActorMapper.java
// public interface ActorMapper {
// public Actor selectActorByBorn(int born);
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
// Path: neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/MybatisTestUtil.java
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.jdbc.example.mybatis.mapper.ActorMapper;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
import javax.sql.DataSource;
import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label;
/*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class MybatisTestUtil {
public enum TestLabels implements Label {
Person
}
protected static void populateGraphDB(GraphDatabaseService graphDatabaseService) {
try (Transaction tx = graphDatabaseService.beginTx()) {
Node node = graphDatabaseService.createNode(TestLabels.Person);
node.setProperty("name", "Dave Chappelle");
node.setProperty("born", 1973);
tx.success();
}
}
protected void buildMybatisConfiguration(String protocol, String host, int port) {
DataSource dataSource = new UnpooledDataSource("org.neo4j.jdbc.Driver", "jdbc:neo4j:" + protocol + "://" + host + ":" + port + "?nossl", null);
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("development", transactionFactory, dataSource);
Configuration configuration = new Configuration(environment); | configuration.getMapperRegistry().addMapper(ActorMapper.class); |
larusba/neo4j-jdbc | neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/MybatisTestUtil.java | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/mapper/ActorMapper.java
// public interface ActorMapper {
// public Actor selectActorByBorn(int born);
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
| import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.jdbc.example.mybatis.mapper.ActorMapper;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
import javax.sql.DataSource;
import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label; | /*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class MybatisTestUtil {
public enum TestLabels implements Label {
Person
}
protected static void populateGraphDB(GraphDatabaseService graphDatabaseService) {
try (Transaction tx = graphDatabaseService.beginTx()) {
Node node = graphDatabaseService.createNode(TestLabels.Person);
node.setProperty("name", "Dave Chappelle");
node.setProperty("born", 1973);
tx.success();
}
}
protected void buildMybatisConfiguration(String protocol, String host, int port) {
DataSource dataSource = new UnpooledDataSource("org.neo4j.jdbc.Driver", "jdbc:neo4j:" + protocol + "://" + host + ":" + port + "?nossl", null);
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("development", transactionFactory, dataSource);
Configuration configuration = new Configuration(environment);
configuration.getMapperRegistry().addMapper(ActorMapper.class);
configuration.addLoadedResource("org/neo4j/jdbc/example/mybatis/mapper/ActorMapper.xml");
| // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/mapper/ActorMapper.java
// public interface ActorMapper {
// public Actor selectActorByBorn(int born);
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
// Path: neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/MybatisTestUtil.java
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.jdbc.example.mybatis.mapper.ActorMapper;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
import javax.sql.DataSource;
import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label;
/*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class MybatisTestUtil {
public enum TestLabels implements Label {
Person
}
protected static void populateGraphDB(GraphDatabaseService graphDatabaseService) {
try (Transaction tx = graphDatabaseService.beginTx()) {
Node node = graphDatabaseService.createNode(TestLabels.Person);
node.setProperty("name", "Dave Chappelle");
node.setProperty("born", 1973);
tx.success();
}
}
protected void buildMybatisConfiguration(String protocol, String host, int port) {
DataSource dataSource = new UnpooledDataSource("org.neo4j.jdbc.Driver", "jdbc:neo4j:" + protocol + "://" + host + ":" + port + "?nossl", null);
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("development", transactionFactory, dataSource);
Configuration configuration = new Configuration(environment);
configuration.getMapperRegistry().addMapper(ActorMapper.class);
configuration.addLoadedResource("org/neo4j/jdbc/example/mybatis/mapper/ActorMapper.xml");
| ConnectionFactory.getSqlSessionFactory(configuration); |
larusba/neo4j-jdbc | neo4j-jdbc-bolt/src/test/java/org/neo4j/jdbc/bolt/BoltNeo4jConnectionIT.java | // Path: neo4j-jdbc-bolt/src/test/java/org/neo4j/jdbc/bolt/data/StatementData.java
// public class StatementData {
// public static String STATEMENT_MATCH_ALL = "MATCH (n) RETURN n;";
// public static String STATEMENT_MATCH_ALL_STRING = "MATCH (n:User) RETURN n.name;";
// public static String STATEMENT_MATCH_NODES = "MATCH (n:User) RETURN n;";
// public static String STATEMENT_MATCH_NODES_MORE = "MATCH (n:User)-[]->(s:Session) RETURN n, s;";
// public static String STATEMENT_MATCH_MISC = "MATCH (n:User) RETURN n, n.name;";
// public static String STATEMENT_MATCH_RELATIONS = "MATCH ()-[r:CONNECTED_IN]-() RETURN r;";
// public static String STATEMENT_MATCH_NODES_RELATIONS = "MATCH (n:User)-[r:CONNECTED_IN]->(s:Session) RETURN n, r, s";
// public static String STATEMENT_CREATE = "CREATE (n:User {name:\"test\"});";
// public static String STATEMENT_CREATE_REV = "MATCH (n:User {name:\"test\"}) DELETE n;";
// public static String STATEMENT_CREATE_TWO_PROPERTIES = "CREATE (n:User {name:\"test\", surname:\"testAgain\"});";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_REV = "MATCH (n:USer {name:\"test\", surname:\"testAgain\"}) DETACH DELETE n;";
// public static String STATEMENT_MATCH_ALL_STRING_PARAMETRIC = "MATCH (n) WHERE n.name = ? RETURN n.surname;";
// public static String STATEMENT_MATCH_ALL_STRING_PARAMETRIC_NAMED = "MATCH (n) WHERE n.name = {1} RETURN n.surname;";
// public static String STATEMENT_CREATE_OTHER_TYPE_AND_RELATIONS = "MATCH (n:User) CREATE (n)-[:CONNECTED_IN {date:1459248821051}]->(:Session {status:true});";
// public static String STATEMENT_CREATE_OTHER_TYPE_AND_RELATIONS_REV = "MATCH (s:Session) DETACH DELETE s;";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_PARAMETRIC = "CREATE (n:User {name:?, surname:?});";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_PARAMETRIC_REV = "MATCH (n:User {name:?, surname:?}) DETACH DELETE n;";
// public static String STATEMENT_CLEAR_DB = "MATCH (n) DETACH DELETE n;";
// public static String STATEMENT_COUNT_NODES = "MATCH (n) RETURN count(n) AS total;";
// }
| import org.junit.rules.ExpectedException;
import org.neo4j.jdbc.bolt.data.StatementData;
import static org.junit.Assert.*;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.junit.*; | @Test public void setAutoCommitShouldCommitFromFalseToTrue() throws SQLException {
// Connect (autoCommit = false)
Connection writer = DriverManager.getConnection(NEO4J_JDBC_BOLT_URL);
writer.setAutoCommit(false);
Connection reader = DriverManager.getConnection(NEO4J_JDBC_BOLT_URL);
// Creating a node with a transaction
try (Statement stmt = writer.createStatement()) {
stmt.executeQuery("CREATE (:SetAutoCommitSwitch{result:\"ok\"})");
Statement stmtRead = reader.createStatement();
ResultSet rs = stmtRead.executeQuery("MATCH (n:SetAutoCommitSwitch) RETURN n.result");
assertFalse(rs.next());
writer.setAutoCommit(true);
rs = stmtRead.executeQuery("MATCH (n:SetAutoCommitSwitch) RETURN n.result");
assertTrue(rs.next());
assertEquals("ok", rs.getString("n.result"));
assertFalse(rs.next());
}
writer.close();
reader.close();
}
@Test public void setAutoCommitShouldWorkAfterMultipleChanges() throws SQLException {
Connection writer = DriverManager.getConnection(NEO4J_JDBC_BOLT_URL);
Connection reader = DriverManager.getConnection(NEO4J_JDBC_BOLT_URL);
Statement writerStmt = writer.createStatement(); | // Path: neo4j-jdbc-bolt/src/test/java/org/neo4j/jdbc/bolt/data/StatementData.java
// public class StatementData {
// public static String STATEMENT_MATCH_ALL = "MATCH (n) RETURN n;";
// public static String STATEMENT_MATCH_ALL_STRING = "MATCH (n:User) RETURN n.name;";
// public static String STATEMENT_MATCH_NODES = "MATCH (n:User) RETURN n;";
// public static String STATEMENT_MATCH_NODES_MORE = "MATCH (n:User)-[]->(s:Session) RETURN n, s;";
// public static String STATEMENT_MATCH_MISC = "MATCH (n:User) RETURN n, n.name;";
// public static String STATEMENT_MATCH_RELATIONS = "MATCH ()-[r:CONNECTED_IN]-() RETURN r;";
// public static String STATEMENT_MATCH_NODES_RELATIONS = "MATCH (n:User)-[r:CONNECTED_IN]->(s:Session) RETURN n, r, s";
// public static String STATEMENT_CREATE = "CREATE (n:User {name:\"test\"});";
// public static String STATEMENT_CREATE_REV = "MATCH (n:User {name:\"test\"}) DELETE n;";
// public static String STATEMENT_CREATE_TWO_PROPERTIES = "CREATE (n:User {name:\"test\", surname:\"testAgain\"});";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_REV = "MATCH (n:USer {name:\"test\", surname:\"testAgain\"}) DETACH DELETE n;";
// public static String STATEMENT_MATCH_ALL_STRING_PARAMETRIC = "MATCH (n) WHERE n.name = ? RETURN n.surname;";
// public static String STATEMENT_MATCH_ALL_STRING_PARAMETRIC_NAMED = "MATCH (n) WHERE n.name = {1} RETURN n.surname;";
// public static String STATEMENT_CREATE_OTHER_TYPE_AND_RELATIONS = "MATCH (n:User) CREATE (n)-[:CONNECTED_IN {date:1459248821051}]->(:Session {status:true});";
// public static String STATEMENT_CREATE_OTHER_TYPE_AND_RELATIONS_REV = "MATCH (s:Session) DETACH DELETE s;";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_PARAMETRIC = "CREATE (n:User {name:?, surname:?});";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_PARAMETRIC_REV = "MATCH (n:User {name:?, surname:?}) DETACH DELETE n;";
// public static String STATEMENT_CLEAR_DB = "MATCH (n) DETACH DELETE n;";
// public static String STATEMENT_COUNT_NODES = "MATCH (n) RETURN count(n) AS total;";
// }
// Path: neo4j-jdbc-bolt/src/test/java/org/neo4j/jdbc/bolt/BoltNeo4jConnectionIT.java
import org.junit.rules.ExpectedException;
import org.neo4j.jdbc.bolt.data.StatementData;
import static org.junit.Assert.*;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.junit.*;
@Test public void setAutoCommitShouldCommitFromFalseToTrue() throws SQLException {
// Connect (autoCommit = false)
Connection writer = DriverManager.getConnection(NEO4J_JDBC_BOLT_URL);
writer.setAutoCommit(false);
Connection reader = DriverManager.getConnection(NEO4J_JDBC_BOLT_URL);
// Creating a node with a transaction
try (Statement stmt = writer.createStatement()) {
stmt.executeQuery("CREATE (:SetAutoCommitSwitch{result:\"ok\"})");
Statement stmtRead = reader.createStatement();
ResultSet rs = stmtRead.executeQuery("MATCH (n:SetAutoCommitSwitch) RETURN n.result");
assertFalse(rs.next());
writer.setAutoCommit(true);
rs = stmtRead.executeQuery("MATCH (n:SetAutoCommitSwitch) RETURN n.result");
assertTrue(rs.next());
assertEquals("ok", rs.getString("n.result"));
assertFalse(rs.next());
}
writer.close();
reader.close();
}
@Test public void setAutoCommitShouldWorkAfterMultipleChanges() throws SQLException {
Connection writer = DriverManager.getConnection(NEO4J_JDBC_BOLT_URL);
Connection reader = DriverManager.getConnection(NEO4J_JDBC_BOLT_URL);
Statement writerStmt = writer.createStatement(); | writerStmt.executeQuery(StatementData.STATEMENT_CREATE); |
larusba/neo4j-jdbc | neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jDataSource.java | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
| import org.neo4j.jdbc.utils.ExceptionBuilder;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Objects;
import java.util.logging.Logger; | /*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 03/02/16
*/
package org.neo4j.jdbc;
/**
* @author AgileLARUS
* @since 3.2.0
*/
public abstract class Neo4jDataSource implements javax.sql.DataSource {
public static final String NEO4J_JDBC_PREFIX = "jdbc:neo4j:";
protected String serverName = "localhost";
protected String user;
protected String password;
protected int portNumber = 0;
protected boolean isSsl = false;
/*
* Ensure the driver is loaded as JDBC Driver might be invisible to Java's ServiceLoader.
* Usually, {@code Class.forName(...)} is not required as {@link DriverManager} detects JDBC drivers
* via {@code META-INF/services/java.sql.Driver} entries. However there might be cases when the driver
* is located at the application level classloader, thus it might be required to perform manual
* registration of the driver.
*/
static {
try {
Class.forName("org.neo4j.jdbc.Neo4jDriver");
} catch (ClassNotFoundException e) {
throw new IllegalStateException(
"Neo4jDataSource is unable to load org.neo4j.jdbc.Neo4jDriver. Please check if you have proper Neo4j JDBC Driver jar on the classpath", e);
}
}
@Override public PrintWriter getLogWriter() throws SQLException { | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jDataSource.java
import org.neo4j.jdbc.utils.ExceptionBuilder;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Objects;
import java.util.logging.Logger;
/*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 03/02/16
*/
package org.neo4j.jdbc;
/**
* @author AgileLARUS
* @since 3.2.0
*/
public abstract class Neo4jDataSource implements javax.sql.DataSource {
public static final String NEO4J_JDBC_PREFIX = "jdbc:neo4j:";
protected String serverName = "localhost";
protected String user;
protected String password;
protected int portNumber = 0;
protected boolean isSsl = false;
/*
* Ensure the driver is loaded as JDBC Driver might be invisible to Java's ServiceLoader.
* Usually, {@code Class.forName(...)} is not required as {@link DriverManager} detects JDBC drivers
* via {@code META-INF/services/java.sql.Driver} entries. However there might be cases when the driver
* is located at the application level classloader, thus it might be required to perform manual
* registration of the driver.
*/
static {
try {
Class.forName("org.neo4j.jdbc.Neo4jDriver");
} catch (ClassNotFoundException e) {
throw new IllegalStateException(
"Neo4jDataSource is unable to load org.neo4j.jdbc.Neo4jDriver. Please check if you have proper Neo4j JDBC Driver jar on the classpath", e);
}
}
@Override public PrintWriter getLogWriter() throws SQLException { | throw ExceptionBuilder.buildUnsupportedOperationException(); |
larusba/neo4j-jdbc | neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/mapper/ActorMapper.java
// public interface ActorMapper {
// public Actor selectActorByBorn(int born);
// }
| import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.mapper.ActorMapper;
import org.apache.ibatis.session.SqlSession;
| /*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis.util;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManager {
private ActorManager() {}
| // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/mapper/ActorMapper.java
// public interface ActorMapper {
// public Actor selectActorByBorn(int born);
// }
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.mapper.ActorMapper;
import org.apache.ibatis.session.SqlSession;
/*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis.util;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManager {
private ActorManager() {}
| public static Actor selectActorByBorn(int born) {
|
larusba/neo4j-jdbc | neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/mapper/ActorMapper.java
// public interface ActorMapper {
// public Actor selectActorByBorn(int born);
// }
| import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.mapper.ActorMapper;
import org.apache.ibatis.session.SqlSession;
| /*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis.util;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManager {
private ActorManager() {}
public static Actor selectActorByBorn(int born) {
SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
.openSession();
try {
| // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/mapper/ActorMapper.java
// public interface ActorMapper {
// public Actor selectActorByBorn(int born);
// }
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.mapper.ActorMapper;
import org.apache.ibatis.session.SqlSession;
/*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis.util;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManager {
private ActorManager() {}
public static Actor selectActorByBorn(int born) {
SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
.openSession();
try {
| ActorMapper categoryMapper = sqlSession
|
larusba/neo4j-jdbc | neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jResultSetMetaData.java | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
| import org.neo4j.jdbc.utils.ExceptionBuilder;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List; | return String.class.getName();
}
/**
* PLANNED FOR REL 3.1
*/
@Override public String getTableName(int column) throws SQLException {
return ""; //not applicable
}
/**
* PLANNED FOR REL 3.1
*/
@Override public String getSchemaName(int column) throws SQLException {
return ""; //not applicable
}
@Override public boolean isCaseSensitive(int column) throws SQLException {
return true;
}
@Override public boolean isReadOnly(int column) throws SQLException {
return false;
}
/*---------------------------------*/
/* Not implemented yet */
/*---------------------------------*/
@Override public boolean isWritable(int column) throws SQLException { | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jResultSetMetaData.java
import org.neo4j.jdbc.utils.ExceptionBuilder;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
return String.class.getName();
}
/**
* PLANNED FOR REL 3.1
*/
@Override public String getTableName(int column) throws SQLException {
return ""; //not applicable
}
/**
* PLANNED FOR REL 3.1
*/
@Override public String getSchemaName(int column) throws SQLException {
return ""; //not applicable
}
@Override public boolean isCaseSensitive(int column) throws SQLException {
return true;
}
@Override public boolean isReadOnly(int column) throws SQLException {
return false;
}
/*---------------------------------*/
/* Not implemented yet */
/*---------------------------------*/
@Override public boolean isWritable(int column) throws SQLException { | throw ExceptionBuilder.buildUnsupportedOperationException(); |
larusba/neo4j-jdbc | neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jPreparedStatement.java | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
//
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/PreparedStatementBuilder.java
// public class PreparedStatementBuilder {
//
// private PreparedStatementBuilder() {}
//
// /**
// * This method return a String that is the original raw string with all valid placeholders replaced with neo4j curly brackets notation for parameters.
// * <br>
// * i.e. MATCH n RETURN n WHERE n.name = ? is transformed in MATCH n RETURN n WHERE n.name = {1}
// *
// * @param raw The string to be translated.
// * @return The string with the placeholders replaced.
// */
// public static String replacePlaceholders(String raw) {
// int index = 1;
// String digested = raw;
//
// String regex = "\\?(?=[^\"]*(?:\"[^\"]*\"[^\"]*)*$)";
// Matcher matcher = Pattern.compile(regex).matcher(digested);
//
// while (matcher.find()) {
// digested = digested.replaceFirst(regex, "{" + index + "}");
// index++;
// }
//
// return digested;
// }
//
// /**
// * Given a string (statement) it counts all valid placeholders
// *
// * @param raw The string of the statement
// * @return The number of all valid placeholders
// */
// public static int namedParameterCount(String raw) {
// int max = 0;
// String regex = "\\{\\s*`?\\s*(\\d+)\\s*`?\\s*\\}(?=[^\"]*(\"[^\"]*\"[^\"]*)*$)";
// Matcher matcher = Pattern.compile(regex).matcher(raw);
// while (matcher.find()) {
// max = Math.max(Integer.parseInt(matcher.group(1)),max);
// }
// return max;
// }
//
// }
| import static java.sql.Types.*;
import org.neo4j.jdbc.utils.ExceptionBuilder;
import org.neo4j.jdbc.utils.PreparedStatementBuilder;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.sql.Date;
import java.sql.ResultSet;
import java.util.*; | /*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 03/02/16
*/
package org.neo4j.jdbc;
/**
* Don't forget to close some attribute (like currentResultSet and currentUpdateCount) or your implementation.
*
* @author AgileLARUS
* @since 3.0.0
*/
public abstract class Neo4jPreparedStatement extends Neo4jStatement implements PreparedStatement {
protected String statement;
protected HashMap<String, Object> parameters;
protected List<Map<String, Object>> batchParameters;
private int parametersNumber;
private static final List<Integer> UNSUPPORTED_TYPES = Collections .unmodifiableList(
Arrays.asList(
ARRAY,
BLOB,
CLOB,
DATALINK,
JAVA_OBJECT,
NCHAR,
NCLOB,
NVARCHAR,
LONGNVARCHAR,
REF,
ROWID,
SQLXML,
STRUCT
)
);
/**
* Default constructor with connection and statement.
*
* @param connection The JDBC connection
* @param rawStatement The prepared statement
*/
protected Neo4jPreparedStatement(Neo4jConnection connection, String rawStatement) {
super(connection); | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
//
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/PreparedStatementBuilder.java
// public class PreparedStatementBuilder {
//
// private PreparedStatementBuilder() {}
//
// /**
// * This method return a String that is the original raw string with all valid placeholders replaced with neo4j curly brackets notation for parameters.
// * <br>
// * i.e. MATCH n RETURN n WHERE n.name = ? is transformed in MATCH n RETURN n WHERE n.name = {1}
// *
// * @param raw The string to be translated.
// * @return The string with the placeholders replaced.
// */
// public static String replacePlaceholders(String raw) {
// int index = 1;
// String digested = raw;
//
// String regex = "\\?(?=[^\"]*(?:\"[^\"]*\"[^\"]*)*$)";
// Matcher matcher = Pattern.compile(regex).matcher(digested);
//
// while (matcher.find()) {
// digested = digested.replaceFirst(regex, "{" + index + "}");
// index++;
// }
//
// return digested;
// }
//
// /**
// * Given a string (statement) it counts all valid placeholders
// *
// * @param raw The string of the statement
// * @return The number of all valid placeholders
// */
// public static int namedParameterCount(String raw) {
// int max = 0;
// String regex = "\\{\\s*`?\\s*(\\d+)\\s*`?\\s*\\}(?=[^\"]*(\"[^\"]*\"[^\"]*)*$)";
// Matcher matcher = Pattern.compile(regex).matcher(raw);
// while (matcher.find()) {
// max = Math.max(Integer.parseInt(matcher.group(1)),max);
// }
// return max;
// }
//
// }
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jPreparedStatement.java
import static java.sql.Types.*;
import org.neo4j.jdbc.utils.ExceptionBuilder;
import org.neo4j.jdbc.utils.PreparedStatementBuilder;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.sql.Date;
import java.sql.ResultSet;
import java.util.*;
/*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 03/02/16
*/
package org.neo4j.jdbc;
/**
* Don't forget to close some attribute (like currentResultSet and currentUpdateCount) or your implementation.
*
* @author AgileLARUS
* @since 3.0.0
*/
public abstract class Neo4jPreparedStatement extends Neo4jStatement implements PreparedStatement {
protected String statement;
protected HashMap<String, Object> parameters;
protected List<Map<String, Object>> batchParameters;
private int parametersNumber;
private static final List<Integer> UNSUPPORTED_TYPES = Collections .unmodifiableList(
Arrays.asList(
ARRAY,
BLOB,
CLOB,
DATALINK,
JAVA_OBJECT,
NCHAR,
NCLOB,
NVARCHAR,
LONGNVARCHAR,
REF,
ROWID,
SQLXML,
STRUCT
)
);
/**
* Default constructor with connection and statement.
*
* @param connection The JDBC connection
* @param rawStatement The prepared statement
*/
protected Neo4jPreparedStatement(Neo4jConnection connection, String rawStatement) {
super(connection); | this.statement = PreparedStatementBuilder.replacePlaceholders(rawStatement); |
larusba/neo4j-jdbc | neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jPreparedStatement.java | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
//
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/PreparedStatementBuilder.java
// public class PreparedStatementBuilder {
//
// private PreparedStatementBuilder() {}
//
// /**
// * This method return a String that is the original raw string with all valid placeholders replaced with neo4j curly brackets notation for parameters.
// * <br>
// * i.e. MATCH n RETURN n WHERE n.name = ? is transformed in MATCH n RETURN n WHERE n.name = {1}
// *
// * @param raw The string to be translated.
// * @return The string with the placeholders replaced.
// */
// public static String replacePlaceholders(String raw) {
// int index = 1;
// String digested = raw;
//
// String regex = "\\?(?=[^\"]*(?:\"[^\"]*\"[^\"]*)*$)";
// Matcher matcher = Pattern.compile(regex).matcher(digested);
//
// while (matcher.find()) {
// digested = digested.replaceFirst(regex, "{" + index + "}");
// index++;
// }
//
// return digested;
// }
//
// /**
// * Given a string (statement) it counts all valid placeholders
// *
// * @param raw The string of the statement
// * @return The number of all valid placeholders
// */
// public static int namedParameterCount(String raw) {
// int max = 0;
// String regex = "\\{\\s*`?\\s*(\\d+)\\s*`?\\s*\\}(?=[^\"]*(\"[^\"]*\"[^\"]*)*$)";
// Matcher matcher = Pattern.compile(regex).matcher(raw);
// while (matcher.find()) {
// max = Math.max(Integer.parseInt(matcher.group(1)),max);
// }
// return max;
// }
//
// }
| import static java.sql.Types.*;
import org.neo4j.jdbc.utils.ExceptionBuilder;
import org.neo4j.jdbc.utils.PreparedStatementBuilder;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.sql.Date;
import java.sql.ResultSet;
import java.util.*; |
@Override public boolean execute(String sql, int[] columnIndexes) throws SQLException {
throw new SQLException("Method execute(String, int[]) cannot be called on PreparedStatement");
}
@Override public boolean execute(String sql, String[] columnNames) throws SQLException {
throw new SQLException("Method execute(String, String[]) cannot be called on PreparedStatement");
}
@Override public ResultSet executeQuery(String sql) throws SQLException {
throw new SQLException("Method executeQuery(String) cannot be called on PreparedStatement");
}
@Override public int executeUpdate(String sql) throws SQLException {
throw new SQLException("Method executeUpdate(String) cannot be called on PreparedStatement");
}
@Override public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
throw new SQLException("Method executeUpdate(String, int) cannot be called on PreparedStatement");
}
@Override public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
throw new SQLException("Method executeUpdate(String, int[]) cannot be called on PreparedStatement");
}
@Override public int executeUpdate(String sql, String[] columnNames) throws SQLException {
throw new SQLException("Method executeUpdate(String, String[]) cannot be called on PreparedStatement");
}
@Override public void setByte(int parameterIndex, byte x) throws SQLException { | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
//
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/PreparedStatementBuilder.java
// public class PreparedStatementBuilder {
//
// private PreparedStatementBuilder() {}
//
// /**
// * This method return a String that is the original raw string with all valid placeholders replaced with neo4j curly brackets notation for parameters.
// * <br>
// * i.e. MATCH n RETURN n WHERE n.name = ? is transformed in MATCH n RETURN n WHERE n.name = {1}
// *
// * @param raw The string to be translated.
// * @return The string with the placeholders replaced.
// */
// public static String replacePlaceholders(String raw) {
// int index = 1;
// String digested = raw;
//
// String regex = "\\?(?=[^\"]*(?:\"[^\"]*\"[^\"]*)*$)";
// Matcher matcher = Pattern.compile(regex).matcher(digested);
//
// while (matcher.find()) {
// digested = digested.replaceFirst(regex, "{" + index + "}");
// index++;
// }
//
// return digested;
// }
//
// /**
// * Given a string (statement) it counts all valid placeholders
// *
// * @param raw The string of the statement
// * @return The number of all valid placeholders
// */
// public static int namedParameterCount(String raw) {
// int max = 0;
// String regex = "\\{\\s*`?\\s*(\\d+)\\s*`?\\s*\\}(?=[^\"]*(\"[^\"]*\"[^\"]*)*$)";
// Matcher matcher = Pattern.compile(regex).matcher(raw);
// while (matcher.find()) {
// max = Math.max(Integer.parseInt(matcher.group(1)),max);
// }
// return max;
// }
//
// }
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jPreparedStatement.java
import static java.sql.Types.*;
import org.neo4j.jdbc.utils.ExceptionBuilder;
import org.neo4j.jdbc.utils.PreparedStatementBuilder;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.sql.Date;
import java.sql.ResultSet;
import java.util.*;
@Override public boolean execute(String sql, int[] columnIndexes) throws SQLException {
throw new SQLException("Method execute(String, int[]) cannot be called on PreparedStatement");
}
@Override public boolean execute(String sql, String[] columnNames) throws SQLException {
throw new SQLException("Method execute(String, String[]) cannot be called on PreparedStatement");
}
@Override public ResultSet executeQuery(String sql) throws SQLException {
throw new SQLException("Method executeQuery(String) cannot be called on PreparedStatement");
}
@Override public int executeUpdate(String sql) throws SQLException {
throw new SQLException("Method executeUpdate(String) cannot be called on PreparedStatement");
}
@Override public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
throw new SQLException("Method executeUpdate(String, int) cannot be called on PreparedStatement");
}
@Override public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
throw new SQLException("Method executeUpdate(String, int[]) cannot be called on PreparedStatement");
}
@Override public int executeUpdate(String sql, String[] columnNames) throws SQLException {
throw new SQLException("Method executeUpdate(String, String[]) cannot be called on PreparedStatement");
}
@Override public void setByte(int parameterIndex, byte x) throws SQLException { | throw ExceptionBuilder.buildUnsupportedOperationException(); |
larusba/neo4j-jdbc | neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jStatement.java | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
| import org.neo4j.jdbc.utils.ExceptionBuilder;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.List; | return Neo4jResultSet.DEFAULT_CONCURRENCY;
}
@Override public int getResultSetType() throws SQLException {
this.checkClosed();
if (currentResultSet != null) {
return currentResultSet.getType();
}
if (this.resultSetParams.length > 0) {
return this.resultSetParams[0];
}
return Neo4jResultSet.DEFAULT_TYPE;
}
@Override public int getResultSetHoldability() throws SQLException {
this.checkClosed();
if (currentResultSet != null) {
return currentResultSet.getHoldability();
}
if (this.resultSetParams.length > 2) {
return this.resultSetParams[2];
}
return Neo4jResultSet.DEFAULT_HOLDABILITY;
}
/*---------------------------------*/
/* Not implemented yet */
/*---------------------------------*/
@Override public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jStatement.java
import org.neo4j.jdbc.utils.ExceptionBuilder;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.List;
return Neo4jResultSet.DEFAULT_CONCURRENCY;
}
@Override public int getResultSetType() throws SQLException {
this.checkClosed();
if (currentResultSet != null) {
return currentResultSet.getType();
}
if (this.resultSetParams.length > 0) {
return this.resultSetParams[0];
}
return Neo4jResultSet.DEFAULT_TYPE;
}
@Override public int getResultSetHoldability() throws SQLException {
this.checkClosed();
if (currentResultSet != null) {
return currentResultSet.getHoldability();
}
if (this.resultSetParams.length > 2) {
return this.resultSetParams[2];
}
return Neo4jResultSet.DEFAULT_HOLDABILITY;
}
/*---------------------------------*/
/* Not implemented yet */
/*---------------------------------*/
@Override public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { | throw ExceptionBuilder.buildUnsupportedOperationException(); |
larusba/neo4j-jdbc | neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerBoltTestWithLocalServer.java | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
| import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
| /*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerBoltTestWithLocalServer extends MybatisTestUtil {
/*
* Need to start a neo4j instance and load the "Movie" example graph
*/
@Test
@Ignore
public void testSelectActorBornIn1973() {
| // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
// Path: neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerBoltTestWithLocalServer.java
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
/*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerBoltTestWithLocalServer extends MybatisTestUtil {
/*
* Need to start a neo4j instance and load the "Movie" example graph
*/
@Test
@Ignore
public void testSelectActorBornIn1973() {
| ConnectionFactory.getSqlSessionFactory("bolt-database-config.xml");
|
larusba/neo4j-jdbc | neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerBoltTestWithLocalServer.java | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
| import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
| /*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerBoltTestWithLocalServer extends MybatisTestUtil {
/*
* Need to start a neo4j instance and load the "Movie" example graph
*/
@Test
@Ignore
public void testSelectActorBornIn1973() {
ConnectionFactory.getSqlSessionFactory("bolt-database-config.xml");
| // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
// Path: neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerBoltTestWithLocalServer.java
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
/*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerBoltTestWithLocalServer extends MybatisTestUtil {
/*
* Need to start a neo4j instance and load the "Movie" example graph
*/
@Test
@Ignore
public void testSelectActorBornIn1973() {
ConnectionFactory.getSqlSessionFactory("bolt-database-config.xml");
| Actor actor = ActorManager.selectActorByBorn(1973);
|
larusba/neo4j-jdbc | neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerBoltTestWithLocalServer.java | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
| import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
| /*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerBoltTestWithLocalServer extends MybatisTestUtil {
/*
* Need to start a neo4j instance and load the "Movie" example graph
*/
@Test
@Ignore
public void testSelectActorBornIn1973() {
ConnectionFactory.getSqlSessionFactory("bolt-database-config.xml");
| // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
// Path: neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerBoltTestWithLocalServer.java
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
/*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerBoltTestWithLocalServer extends MybatisTestUtil {
/*
* Need to start a neo4j instance and load the "Movie" example graph
*/
@Test
@Ignore
public void testSelectActorBornIn1973() {
ConnectionFactory.getSqlSessionFactory("bolt-database-config.xml");
| Actor actor = ActorManager.selectActorByBorn(1973);
|
larusba/neo4j-jdbc | neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerIT.java | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
| import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.neo4j.harness.junit.Neo4jRule;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
| /*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerIT extends MybatisTestUtil {
@ClassRule
public static Neo4jRule neo4j = new Neo4jRule();
@BeforeClass
public static void setUp() {
populateGraphDB(neo4j.getGraphDatabaseService());
}
@Test
public void testMybatisViaHttp() {
buildMybatisConfiguration("http", neo4j.httpURI().getHost(), neo4j.httpURI().getPort());
| // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
// Path: neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerIT.java
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.neo4j.harness.junit.Neo4jRule;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
/*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerIT extends MybatisTestUtil {
@ClassRule
public static Neo4jRule neo4j = new Neo4jRule();
@BeforeClass
public static void setUp() {
populateGraphDB(neo4j.getGraphDatabaseService());
}
@Test
public void testMybatisViaHttp() {
buildMybatisConfiguration("http", neo4j.httpURI().getHost(), neo4j.httpURI().getPort());
| Actor actor = ActorManager.selectActorByBorn(1973);
|
larusba/neo4j-jdbc | neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerIT.java | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
| import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.neo4j.harness.junit.Neo4jRule;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
| /*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerIT extends MybatisTestUtil {
@ClassRule
public static Neo4jRule neo4j = new Neo4jRule();
@BeforeClass
public static void setUp() {
populateGraphDB(neo4j.getGraphDatabaseService());
}
@Test
public void testMybatisViaHttp() {
buildMybatisConfiguration("http", neo4j.httpURI().getHost(), neo4j.httpURI().getPort());
| // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
// Path: neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerIT.java
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.neo4j.harness.junit.Neo4jRule;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
/*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerIT extends MybatisTestUtil {
@ClassRule
public static Neo4jRule neo4j = new Neo4jRule();
@BeforeClass
public static void setUp() {
populateGraphDB(neo4j.getGraphDatabaseService());
}
@Test
public void testMybatisViaHttp() {
buildMybatisConfiguration("http", neo4j.httpURI().getHost(), neo4j.httpURI().getPort());
| Actor actor = ActorManager.selectActorByBorn(1973);
|
larusba/neo4j-jdbc | neo4j-jdbc/src/test/java/org/neo4j/jdbc/impl/ListNeo4jArrayTest.java | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jArray.java
// public abstract class Neo4jArray implements java.sql.Array {
//
// protected static final List<Integer> TYPES_SUPPORTED = Arrays.asList(Types.VARCHAR, Types.INTEGER, Types.BOOLEAN, Types.DOUBLE, Types.JAVA_OBJECT);
// protected static final List<Integer> TYPES_UNSUPPORTED = Arrays
// .asList(Types.ARRAY, Types.BIGINT, Types.BINARY, Types.BIT, Types.BLOB, Types.CHAR, Types.CLOB, Types.DATALINK, Types.DATE, Types.DECIMAL,
// Types.DISTINCT, Types.FLOAT, Types.LONGNVARCHAR, Types.LONGVARBINARY, Types.NCHAR, Types.NCLOB, Types.NUMERIC, Types.NVARCHAR, Types.OTHER,
// Types.REAL, Types.REF, /*Types.REF_CURSOR,*/ Types.ROWID, Types.SMALLINT, Types.SQLXML, Types.STRUCT, Types.TIME, /*Types.TIME_WITH_TIMEZONE,*/
// Types.TIMESTAMP, /*Types.TIMESTAMP_WITH_TIMEZONE,*/ Types.TINYINT, Types.VARBINARY);
//
// private static final String NOT_SUPPORTED = "Feature not supported";
//
// @Override public String getBaseTypeName() throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public int getBaseType() throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public Object getArray() throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public Object getArray(Map<String, Class<?>> map) throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public Object getArray(long index, int count) throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public Object getArray(long index, int count, Map<String, Class<?>> map) throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public java.sql.ResultSet getResultSet() throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public ResultSet getResultSet(long index, int count) throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public ResultSet getResultSet(long index, int count, Map<String, Class<?>> map) throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public void free() throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// public static int getObjectType(Object obj){
// int type;
//
// if(obj instanceof String){
// type = Types.VARCHAR;
// } else if(obj instanceof Long){
// type = Types.INTEGER;
// } else if(obj instanceof Boolean) {
// type = Types.BOOLEAN;
// } else if(obj instanceof Double){
// type = Types.DOUBLE;
// } else {
// type = Types.JAVA_OBJECT;
// }
//
// return type;
// }
// }
| import static junit.framework.TestCase.*;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.neo4j.jdbc.Neo4jArray;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; | Types.CHAR,
Types.CLOB,
Types.DATALINK,
Types.DATE,
Types.DECIMAL,
Types.DISTINCT,
Types.FLOAT,
Types.LONGNVARCHAR,
Types.LONGVARBINARY,
Types.NCHAR,
Types.NCLOB,
Types.NUMERIC,
Types.NVARCHAR,
Types.OTHER,
Types.REAL,
Types.REF,
Types.ROWID,
Types.SMALLINT,
Types.SQLXML,
Types.STRUCT,
Types.TIME,
Types.TIMESTAMP,
Types.TINYINT,
Types.VARBINARY);
/*------------------------------*/
/* getBaseTypeName */
/*------------------------------*/
@Test public void getBaseTypeNameShouldReturnCorrectType() throws SQLException {
List<Object> list = new ArrayList<>(); | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jArray.java
// public abstract class Neo4jArray implements java.sql.Array {
//
// protected static final List<Integer> TYPES_SUPPORTED = Arrays.asList(Types.VARCHAR, Types.INTEGER, Types.BOOLEAN, Types.DOUBLE, Types.JAVA_OBJECT);
// protected static final List<Integer> TYPES_UNSUPPORTED = Arrays
// .asList(Types.ARRAY, Types.BIGINT, Types.BINARY, Types.BIT, Types.BLOB, Types.CHAR, Types.CLOB, Types.DATALINK, Types.DATE, Types.DECIMAL,
// Types.DISTINCT, Types.FLOAT, Types.LONGNVARCHAR, Types.LONGVARBINARY, Types.NCHAR, Types.NCLOB, Types.NUMERIC, Types.NVARCHAR, Types.OTHER,
// Types.REAL, Types.REF, /*Types.REF_CURSOR,*/ Types.ROWID, Types.SMALLINT, Types.SQLXML, Types.STRUCT, Types.TIME, /*Types.TIME_WITH_TIMEZONE,*/
// Types.TIMESTAMP, /*Types.TIMESTAMP_WITH_TIMEZONE,*/ Types.TINYINT, Types.VARBINARY);
//
// private static final String NOT_SUPPORTED = "Feature not supported";
//
// @Override public String getBaseTypeName() throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public int getBaseType() throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public Object getArray() throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public Object getArray(Map<String, Class<?>> map) throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public Object getArray(long index, int count) throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public Object getArray(long index, int count, Map<String, Class<?>> map) throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public java.sql.ResultSet getResultSet() throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public ResultSet getResultSet(long index, int count) throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public ResultSet getResultSet(long index, int count, Map<String, Class<?>> map) throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// @Override public void free() throws SQLException {
// throw new SQLFeatureNotSupportedException(NOT_SUPPORTED);
// }
//
// public static int getObjectType(Object obj){
// int type;
//
// if(obj instanceof String){
// type = Types.VARCHAR;
// } else if(obj instanceof Long){
// type = Types.INTEGER;
// } else if(obj instanceof Boolean) {
// type = Types.BOOLEAN;
// } else if(obj instanceof Double){
// type = Types.DOUBLE;
// } else {
// type = Types.JAVA_OBJECT;
// }
//
// return type;
// }
// }
// Path: neo4j-jdbc/src/test/java/org/neo4j/jdbc/impl/ListNeo4jArrayTest.java
import static junit.framework.TestCase.*;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.neo4j.jdbc.Neo4jArray;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Types.CHAR,
Types.CLOB,
Types.DATALINK,
Types.DATE,
Types.DECIMAL,
Types.DISTINCT,
Types.FLOAT,
Types.LONGNVARCHAR,
Types.LONGVARBINARY,
Types.NCHAR,
Types.NCLOB,
Types.NUMERIC,
Types.NVARCHAR,
Types.OTHER,
Types.REAL,
Types.REF,
Types.ROWID,
Types.SMALLINT,
Types.SQLXML,
Types.STRUCT,
Types.TIME,
Types.TIMESTAMP,
Types.TINYINT,
Types.VARBINARY);
/*------------------------------*/
/* getBaseTypeName */
/*------------------------------*/
@Test public void getBaseTypeNameShouldReturnCorrectType() throws SQLException {
List<Object> list = new ArrayList<>(); | Neo4jArray array = new ListArray(list, Types.VARCHAR); |
larusba/neo4j-jdbc | neo4j-jdbc-http/src/test/java/org/neo4j/jdbc/http/HttpNeo4jResultSetMetaDataTest.java | // Path: neo4j-jdbc-http/src/main/java/org/neo4j/jdbc/http/driver/Neo4jResult.java
// @SuppressWarnings({"rawtypes", "unchecked"})
// public class Neo4jResult {
//
// /**
// * List of columns.
// */
// private List<String> columns;
//
// /**
// * List of data row.
// */
// private List<Map> rows;
//
// /**
// * List fof stats
// */
// private Map<String, Object> stats;
//
// /**
// * Constructor.
// *
// * @param map JSON Map
// */
// public Neo4jResult(Map map) {
// this.columns = (List<String>) map.get("columns");
// this.rows = (List<Map>) map.get("data");
//
// if (map.containsKey("stats")) {
// this.stats = (Map<String, Object>) map.get("stats");
// }
// }
//
// /**
// * @return the column names in the result
// */
// public List<String> getColumns() {
// return columns;
// }
//
// /**
// * @return the rows in the result set
// */
// public List<Map> getRows() {
// return rows;
// }
//
// /**
// * @return the statistics for the statement
// */
// public Map<String, Object> getStats() {
// return stats;
// }
//
// /**
// * Compute updated elements number.
// *
// * @return the number of updated elements
// */
// public int getUpdateCount() {
// int updated = 0;
// if (this.stats != null && (boolean) this.stats.get("contains_updates")) {
// updated += ((Long) stats.get("nodes_created")).intValue();
// updated += ((Long) stats.get("nodes_deleted")).intValue();
// updated += ((Long) stats.get("relationships_created")).intValue();
// updated += ((Long) stats.get("relationship_deleted")).intValue();
// }
// return updated;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.powermock.api.mockito.PowerMockito.mock;
import static org.powermock.api.mockito.PowerMockito.when;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.jdbc.http.driver.Neo4jResult;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | /**
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 29/11/17
*/
package org.neo4j.jdbc.http;
/**
* @author AgileLARUS
*
* @since 3.0.0
*/
public class HttpNeo4jResultSetMetaDataTest {
HttpNeo4jResultSetMetaData httpResultSetMetadata;
@Before
public void setUp() {
List<Map> rows = new ArrayList<>();
Map<String, List> map = new HashMap<>();
List<Object> row = new ArrayList<>();
row.add(null);
row.add("string");
row.add(1);
row.add(1L);
row.add(true);
row.add(1.2);
row.add(1.2F);
row.add(new HashMap<>());
row.add(new ArrayList());
map.put("row", row);
rows.add(map);
| // Path: neo4j-jdbc-http/src/main/java/org/neo4j/jdbc/http/driver/Neo4jResult.java
// @SuppressWarnings({"rawtypes", "unchecked"})
// public class Neo4jResult {
//
// /**
// * List of columns.
// */
// private List<String> columns;
//
// /**
// * List of data row.
// */
// private List<Map> rows;
//
// /**
// * List fof stats
// */
// private Map<String, Object> stats;
//
// /**
// * Constructor.
// *
// * @param map JSON Map
// */
// public Neo4jResult(Map map) {
// this.columns = (List<String>) map.get("columns");
// this.rows = (List<Map>) map.get("data");
//
// if (map.containsKey("stats")) {
// this.stats = (Map<String, Object>) map.get("stats");
// }
// }
//
// /**
// * @return the column names in the result
// */
// public List<String> getColumns() {
// return columns;
// }
//
// /**
// * @return the rows in the result set
// */
// public List<Map> getRows() {
// return rows;
// }
//
// /**
// * @return the statistics for the statement
// */
// public Map<String, Object> getStats() {
// return stats;
// }
//
// /**
// * Compute updated elements number.
// *
// * @return the number of updated elements
// */
// public int getUpdateCount() {
// int updated = 0;
// if (this.stats != null && (boolean) this.stats.get("contains_updates")) {
// updated += ((Long) stats.get("nodes_created")).intValue();
// updated += ((Long) stats.get("nodes_deleted")).intValue();
// updated += ((Long) stats.get("relationships_created")).intValue();
// updated += ((Long) stats.get("relationship_deleted")).intValue();
// }
// return updated;
// }
// }
// Path: neo4j-jdbc-http/src/test/java/org/neo4j/jdbc/http/HttpNeo4jResultSetMetaDataTest.java
import static org.junit.Assert.assertEquals;
import static org.powermock.api.mockito.PowerMockito.mock;
import static org.powermock.api.mockito.PowerMockito.when;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.jdbc.http.driver.Neo4jResult;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 29/11/17
*/
package org.neo4j.jdbc.http;
/**
* @author AgileLARUS
*
* @since 3.0.0
*/
public class HttpNeo4jResultSetMetaDataTest {
HttpNeo4jResultSetMetaData httpResultSetMetadata;
@Before
public void setUp() {
List<Map> rows = new ArrayList<>();
Map<String, List> map = new HashMap<>();
List<Object> row = new ArrayList<>();
row.add(null);
row.add("string");
row.add(1);
row.add(1L);
row.add(true);
row.add(1.2);
row.add(1.2F);
row.add(new HashMap<>());
row.add(new ArrayList());
map.put("row", row);
rows.add(map);
| Neo4jResult result = mock(Neo4jResult.class); |
larusba/neo4j-jdbc | neo4j-jdbc/src/test/java/org/neo4j/jdbc/utils/Neo4jPreparedStatementBuilderTest.java | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/PreparedStatementBuilder.java
// public static String replacePlaceholders(String raw) {
// int index = 1;
// String digested = raw;
//
// String regex = "\\?(?=[^\"]*(?:\"[^\"]*\"[^\"]*)*$)";
// Matcher matcher = Pattern.compile(regex).matcher(digested);
//
// while (matcher.find()) {
// digested = digested.replaceFirst(regex, "{" + index + "}");
// index++;
// }
//
// return digested;
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Test;
import static org.neo4j.jdbc.utils.PreparedStatementBuilder.replacePlaceholders; | /*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 25/03/16
*/
package org.neo4j.jdbc.utils;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public class Neo4jPreparedStatementBuilderTest {
@Test public void replacePlaceholderShouldReturnSameStatementIfNoPlaceholders() {
String raw = "MATCH statement RETURN same WHERE thereAreNoPlaceholders"; | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/PreparedStatementBuilder.java
// public static String replacePlaceholders(String raw) {
// int index = 1;
// String digested = raw;
//
// String regex = "\\?(?=[^\"]*(?:\"[^\"]*\"[^\"]*)*$)";
// Matcher matcher = Pattern.compile(regex).matcher(digested);
//
// while (matcher.find()) {
// digested = digested.replaceFirst(regex, "{" + index + "}");
// index++;
// }
//
// return digested;
// }
// Path: neo4j-jdbc/src/test/java/org/neo4j/jdbc/utils/Neo4jPreparedStatementBuilderTest.java
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import static org.neo4j.jdbc.utils.PreparedStatementBuilder.replacePlaceholders;
/*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 25/03/16
*/
package org.neo4j.jdbc.utils;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public class Neo4jPreparedStatementBuilderTest {
@Test public void replacePlaceholderShouldReturnSameStatementIfNoPlaceholders() {
String raw = "MATCH statement RETURN same WHERE thereAreNoPlaceholders"; | assertEquals(raw, replacePlaceholders(raw)); |
larusba/neo4j-jdbc | neo4j-jdbc-http/src/test/java/org/neo4j/jdbc/http/test/Neo4jHttpUnitTestUtil.java | // Path: neo4j-jdbc-http/src/main/java/org/neo4j/jdbc/http/driver/Neo4jStatement.java
// public class Neo4jStatement {
//
// /**
// * Cypher query.
// */
// public final String statement;
//
// /**
// * Params of the cypher query.
// */
// public final Map<String, Object> parameters;
//
// /**
// * Do we need to include stats with the query ?
// */
// public final Boolean includeStats;
//
// /**
// * Default constructor.
// *
// * @param statement Cypher query
// * @param parameters List of named params for the cypher query
// * @param includeStats Do we need to include stats
// * @throws SQLException sqlexception
// */
// public Neo4jStatement(String statement, Map<String, Object> parameters, Boolean includeStats) throws SQLException {
// if (statement != null && !"".equals(statement)) {
// this.statement = statement;
// } else {
// throw new SQLException("Creating a NULL query");
// }
// if (parameters != null) {
// this.parameters = parameters;
// } else {
// this.parameters = new HashMap<>();
// }
// if (includeStats != null) {
// this.includeStats = includeStats;
// } else {
// this.includeStats = Boolean.FALSE;
// }
// }
//
// /**
// * Escape method for cypher queries.
// *
// * @param query Cypher query
// * @return ...
// */
// public static String escapeQuery(String query) {
// return query.replace('\"', '\'').replace('\n', ' ');
// }
//
// /**
// * Convert the list of query to a JSON compatible with Neo4j endpoint.
// *
// * @param queries List of cypher queries.
// * @param mapper mapper
// * @return The JSON string that correspond to the body of the API call
// * @throws SQLException sqlexception
// */
// public static String toJson(List<Neo4jStatement> queries, ObjectMapper mapper) throws SQLException {
// StringBuilder sb = new StringBuilder();
// try {
// sb.append("{\"statements\":");
// sb.append(mapper.writeValueAsString(queries));
// sb.append("}");
//
// } catch (JsonProcessingException e) {
// throw new SQLException("Can't convert Cypher statement(s) into JSON", e);
// }
// return sb.toString();
// }
//
// /**
// * Getter for Statements.
// * We escape the string for the API.
// *
// * @return the statement
// */
// public String getStatement() {
// return escapeQuery(statement);
// }
//
// }
| import java.util.*;
import au.com.bytecode.opencsv.CSVReader;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.neo4j.jdbc.http.driver.Neo4jStatement;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.rules.ExpectedException;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.sql.SQLException; | /*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 15/4/2016
*/
package org.neo4j.jdbc.http.test;
public class Neo4jHttpUnitTestUtil {
@Rule public ExpectedException expectedEx = ExpectedException.none();
private final static int CSV_STATEMENT = 0;
private final static int CSV_PARAMETERS = 1;
private final static int CSV_INCLUDESTATS = 2;
/**
* Retrieve some random queries from a csv file.
* We return a map with the CSV source into the kye <code>source</code> and its object Neo4jStatement into key <code>object</code>.
*
* @param filename The filename that contains queries
* @param nbElement The number element to return
* @return
* @throws Exception
*/
protected Map<String, List> getRandomNeo4jStatementFromCSV(String filename, int nbElement) throws Exception { | // Path: neo4j-jdbc-http/src/main/java/org/neo4j/jdbc/http/driver/Neo4jStatement.java
// public class Neo4jStatement {
//
// /**
// * Cypher query.
// */
// public final String statement;
//
// /**
// * Params of the cypher query.
// */
// public final Map<String, Object> parameters;
//
// /**
// * Do we need to include stats with the query ?
// */
// public final Boolean includeStats;
//
// /**
// * Default constructor.
// *
// * @param statement Cypher query
// * @param parameters List of named params for the cypher query
// * @param includeStats Do we need to include stats
// * @throws SQLException sqlexception
// */
// public Neo4jStatement(String statement, Map<String, Object> parameters, Boolean includeStats) throws SQLException {
// if (statement != null && !"".equals(statement)) {
// this.statement = statement;
// } else {
// throw new SQLException("Creating a NULL query");
// }
// if (parameters != null) {
// this.parameters = parameters;
// } else {
// this.parameters = new HashMap<>();
// }
// if (includeStats != null) {
// this.includeStats = includeStats;
// } else {
// this.includeStats = Boolean.FALSE;
// }
// }
//
// /**
// * Escape method for cypher queries.
// *
// * @param query Cypher query
// * @return ...
// */
// public static String escapeQuery(String query) {
// return query.replace('\"', '\'').replace('\n', ' ');
// }
//
// /**
// * Convert the list of query to a JSON compatible with Neo4j endpoint.
// *
// * @param queries List of cypher queries.
// * @param mapper mapper
// * @return The JSON string that correspond to the body of the API call
// * @throws SQLException sqlexception
// */
// public static String toJson(List<Neo4jStatement> queries, ObjectMapper mapper) throws SQLException {
// StringBuilder sb = new StringBuilder();
// try {
// sb.append("{\"statements\":");
// sb.append(mapper.writeValueAsString(queries));
// sb.append("}");
//
// } catch (JsonProcessingException e) {
// throw new SQLException("Can't convert Cypher statement(s) into JSON", e);
// }
// return sb.toString();
// }
//
// /**
// * Getter for Statements.
// * We escape the string for the API.
// *
// * @return the statement
// */
// public String getStatement() {
// return escapeQuery(statement);
// }
//
// }
// Path: neo4j-jdbc-http/src/test/java/org/neo4j/jdbc/http/test/Neo4jHttpUnitTestUtil.java
import java.util.*;
import au.com.bytecode.opencsv.CSVReader;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.neo4j.jdbc.http.driver.Neo4jStatement;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.rules.ExpectedException;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.sql.SQLException;
/*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 15/4/2016
*/
package org.neo4j.jdbc.http.test;
public class Neo4jHttpUnitTestUtil {
@Rule public ExpectedException expectedEx = ExpectedException.none();
private final static int CSV_STATEMENT = 0;
private final static int CSV_PARAMETERS = 1;
private final static int CSV_INCLUDESTATS = 2;
/**
* Retrieve some random queries from a csv file.
* We return a map with the CSV source into the kye <code>source</code> and its object Neo4jStatement into key <code>object</code>.
*
* @param filename The filename that contains queries
* @param nbElement The number element to return
* @return
* @throws Exception
*/
protected Map<String, List> getRandomNeo4jStatementFromCSV(String filename, int nbElement) throws Exception { | List<Neo4jStatement> queriesObj = new ArrayList<>(); |
larusba/neo4j-jdbc | neo4j-jdbc-bolt/src/test/java/org/neo4j/jdbc/bolt/BoltNeo4jResultSetMetaDataIT.java | // Path: neo4j-jdbc-bolt/src/test/java/org/neo4j/jdbc/bolt/data/StatementData.java
// public class StatementData {
// public static String STATEMENT_MATCH_ALL = "MATCH (n) RETURN n;";
// public static String STATEMENT_MATCH_ALL_STRING = "MATCH (n:User) RETURN n.name;";
// public static String STATEMENT_MATCH_NODES = "MATCH (n:User) RETURN n;";
// public static String STATEMENT_MATCH_NODES_MORE = "MATCH (n:User)-[]->(s:Session) RETURN n, s;";
// public static String STATEMENT_MATCH_MISC = "MATCH (n:User) RETURN n, n.name;";
// public static String STATEMENT_MATCH_RELATIONS = "MATCH ()-[r:CONNECTED_IN]-() RETURN r;";
// public static String STATEMENT_MATCH_NODES_RELATIONS = "MATCH (n:User)-[r:CONNECTED_IN]->(s:Session) RETURN n, r, s";
// public static String STATEMENT_CREATE = "CREATE (n:User {name:\"test\"});";
// public static String STATEMENT_CREATE_REV = "MATCH (n:User {name:\"test\"}) DELETE n;";
// public static String STATEMENT_CREATE_TWO_PROPERTIES = "CREATE (n:User {name:\"test\", surname:\"testAgain\"});";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_REV = "MATCH (n:USer {name:\"test\", surname:\"testAgain\"}) DETACH DELETE n;";
// public static String STATEMENT_MATCH_ALL_STRING_PARAMETRIC = "MATCH (n) WHERE n.name = ? RETURN n.surname;";
// public static String STATEMENT_MATCH_ALL_STRING_PARAMETRIC_NAMED = "MATCH (n) WHERE n.name = {1} RETURN n.surname;";
// public static String STATEMENT_CREATE_OTHER_TYPE_AND_RELATIONS = "MATCH (n:User) CREATE (n)-[:CONNECTED_IN {date:1459248821051}]->(:Session {status:true});";
// public static String STATEMENT_CREATE_OTHER_TYPE_AND_RELATIONS_REV = "MATCH (s:Session) DETACH DELETE s;";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_PARAMETRIC = "CREATE (n:User {name:?, surname:?});";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_PARAMETRIC_REV = "MATCH (n:User {name:?, surname:?}) DETACH DELETE n;";
// public static String STATEMENT_CLEAR_DB = "MATCH (n) DETACH DELETE n;";
// public static String STATEMENT_COUNT_NODES = "MATCH (n) RETURN count(n) AS total;";
// }
| import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.neo4j.driver.internal.types.InternalTypeSystem;
import org.neo4j.jdbc.bolt.data.StatementData;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.sql.Array;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types; | /*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/03/16
*/
package org.neo4j.jdbc.bolt;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public class BoltNeo4jResultSetMetaDataIT {
private final static String FLATTEN_URI = "flatten=1";
@ClassRule public static Neo4jBoltRule neo4j = new Neo4jBoltRule();
@Before public void setUp() { | // Path: neo4j-jdbc-bolt/src/test/java/org/neo4j/jdbc/bolt/data/StatementData.java
// public class StatementData {
// public static String STATEMENT_MATCH_ALL = "MATCH (n) RETURN n;";
// public static String STATEMENT_MATCH_ALL_STRING = "MATCH (n:User) RETURN n.name;";
// public static String STATEMENT_MATCH_NODES = "MATCH (n:User) RETURN n;";
// public static String STATEMENT_MATCH_NODES_MORE = "MATCH (n:User)-[]->(s:Session) RETURN n, s;";
// public static String STATEMENT_MATCH_MISC = "MATCH (n:User) RETURN n, n.name;";
// public static String STATEMENT_MATCH_RELATIONS = "MATCH ()-[r:CONNECTED_IN]-() RETURN r;";
// public static String STATEMENT_MATCH_NODES_RELATIONS = "MATCH (n:User)-[r:CONNECTED_IN]->(s:Session) RETURN n, r, s";
// public static String STATEMENT_CREATE = "CREATE (n:User {name:\"test\"});";
// public static String STATEMENT_CREATE_REV = "MATCH (n:User {name:\"test\"}) DELETE n;";
// public static String STATEMENT_CREATE_TWO_PROPERTIES = "CREATE (n:User {name:\"test\", surname:\"testAgain\"});";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_REV = "MATCH (n:USer {name:\"test\", surname:\"testAgain\"}) DETACH DELETE n;";
// public static String STATEMENT_MATCH_ALL_STRING_PARAMETRIC = "MATCH (n) WHERE n.name = ? RETURN n.surname;";
// public static String STATEMENT_MATCH_ALL_STRING_PARAMETRIC_NAMED = "MATCH (n) WHERE n.name = {1} RETURN n.surname;";
// public static String STATEMENT_CREATE_OTHER_TYPE_AND_RELATIONS = "MATCH (n:User) CREATE (n)-[:CONNECTED_IN {date:1459248821051}]->(:Session {status:true});";
// public static String STATEMENT_CREATE_OTHER_TYPE_AND_RELATIONS_REV = "MATCH (s:Session) DETACH DELETE s;";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_PARAMETRIC = "CREATE (n:User {name:?, surname:?});";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_PARAMETRIC_REV = "MATCH (n:User {name:?, surname:?}) DETACH DELETE n;";
// public static String STATEMENT_CLEAR_DB = "MATCH (n) DETACH DELETE n;";
// public static String STATEMENT_COUNT_NODES = "MATCH (n) RETURN count(n) AS total;";
// }
// Path: neo4j-jdbc-bolt/src/test/java/org/neo4j/jdbc/bolt/BoltNeo4jResultSetMetaDataIT.java
import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.neo4j.driver.internal.types.InternalTypeSystem;
import org.neo4j.jdbc.bolt.data.StatementData;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.sql.Array;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
/*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/03/16
*/
package org.neo4j.jdbc.bolt;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public class BoltNeo4jResultSetMetaDataIT {
private final static String FLATTEN_URI = "flatten=1";
@ClassRule public static Neo4jBoltRule neo4j = new Neo4jBoltRule();
@Before public void setUp() { | neo4j.getGraphDatabase().execute(StatementData.STATEMENT_CREATE_TWO_PROPERTIES); |
larusba/neo4j-jdbc | neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jParameterMetaData.java | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
| import org.neo4j.jdbc.utils.ExceptionBuilder;
import java.sql.SQLException; | /*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 03/02/16
*/
package org.neo4j.jdbc;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public abstract class Neo4jParameterMetaData implements java.sql.ParameterMetaData {
@Override public int getParameterCount() throws SQLException { | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jParameterMetaData.java
import org.neo4j.jdbc.utils.ExceptionBuilder;
import java.sql.SQLException;
/*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 03/02/16
*/
package org.neo4j.jdbc;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public abstract class Neo4jParameterMetaData implements java.sql.ParameterMetaData {
@Override public int getParameterCount() throws SQLException { | throw ExceptionBuilder.buildUnsupportedOperationException(); |
larusba/neo4j-jdbc | neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jCallableStatement.java | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
| import org.neo4j.jdbc.utils.ExceptionBuilder;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.util.Calendar;
import java.util.Map; | /*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 03/02/16
*/
package org.neo4j.jdbc;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public abstract class Neo4jCallableStatement extends Neo4jPreparedStatement implements java.sql.CallableStatement {
/**
* Default constructor with connection and statement.
*
* @param connection The JDBC connection
* @param rawStatement The prepared statement
*/
protected Neo4jCallableStatement(Neo4jConnection connection, String rawStatement) {
super(connection, rawStatement);
}
/*---------------------------------------*/
/* Some useful check method */
/*---------------------------------------*/
/**
* Check if this connection is closed or not.
* If it's closed, then we throw a SQLException, otherwise we do nothing.
* @throws SQLException sqlexception
*/
protected void checkClosed() throws SQLException {
if (this.isClosed()) {
throw new SQLException("CallableStatement already closed");
}
}
/*------------------------------------*/
/* Default implementation */
/*------------------------------------*/
@Override public SQLWarning getWarnings() throws SQLException {
checkClosed();
return null;
}
@Override public void clearWarnings() throws SQLException {
checkClosed();
}
/*---------------------------------*/
/* Not implemented yet */
/*---------------------------------*/
@Override public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException { | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jCallableStatement.java
import org.neo4j.jdbc.utils.ExceptionBuilder;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.util.Calendar;
import java.util.Map;
/*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 03/02/16
*/
package org.neo4j.jdbc;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public abstract class Neo4jCallableStatement extends Neo4jPreparedStatement implements java.sql.CallableStatement {
/**
* Default constructor with connection and statement.
*
* @param connection The JDBC connection
* @param rawStatement The prepared statement
*/
protected Neo4jCallableStatement(Neo4jConnection connection, String rawStatement) {
super(connection, rawStatement);
}
/*---------------------------------------*/
/* Some useful check method */
/*---------------------------------------*/
/**
* Check if this connection is closed or not.
* If it's closed, then we throw a SQLException, otherwise we do nothing.
* @throws SQLException sqlexception
*/
protected void checkClosed() throws SQLException {
if (this.isClosed()) {
throw new SQLException("CallableStatement already closed");
}
}
/*------------------------------------*/
/* Default implementation */
/*------------------------------------*/
@Override public SQLWarning getWarnings() throws SQLException {
checkClosed();
return null;
}
@Override public void clearWarnings() throws SQLException {
checkClosed();
}
/*---------------------------------*/
/* Not implemented yet */
/*---------------------------------*/
@Override public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException { | throw ExceptionBuilder.buildUnsupportedOperationException(); |
larusba/neo4j-jdbc | neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jDriver.java | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
//
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/Neo4jJdbcRuntimeException.java
// public class Neo4jJdbcRuntimeException extends RuntimeException {
// public Neo4jJdbcRuntimeException (Throwable t) {
// super(t);
// }
// }
| import org.neo4j.jdbc.utils.ExceptionBuilder;
import org.neo4j.jdbc.utils.Neo4jJdbcRuntimeException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger; | /*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 03/02/16
*/
package org.neo4j.jdbc;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public abstract class Neo4jDriver implements java.sql.Driver {
/**
* JDBC prefix for the connection url.
*/
protected static final String JDBC_PREFIX = "jdbc:neo4j:";
/**
* Driver prefix for the connection url.
*/
private String driverPrefix;
/**
* Constructor for extended class.
*
* @param prefix Prefix of the driver for the connection url.
*/
protected Neo4jDriver(String prefix) {
this.driverPrefix = prefix;
}
@Override public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
return new DriverPropertyInfo[0];
}
@Override public int getMajorVersion() {
return 3;
}
@Override public int getMinorVersion() {
return 2;
}
@Override public boolean jdbcCompliant() {
return false;
}
@Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
//
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/Neo4jJdbcRuntimeException.java
// public class Neo4jJdbcRuntimeException extends RuntimeException {
// public Neo4jJdbcRuntimeException (Throwable t) {
// super(t);
// }
// }
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jDriver.java
import org.neo4j.jdbc.utils.ExceptionBuilder;
import org.neo4j.jdbc.utils.Neo4jJdbcRuntimeException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;
/*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 03/02/16
*/
package org.neo4j.jdbc;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public abstract class Neo4jDriver implements java.sql.Driver {
/**
* JDBC prefix for the connection url.
*/
protected static final String JDBC_PREFIX = "jdbc:neo4j:";
/**
* Driver prefix for the connection url.
*/
private String driverPrefix;
/**
* Constructor for extended class.
*
* @param prefix Prefix of the driver for the connection url.
*/
protected Neo4jDriver(String prefix) {
this.driverPrefix = prefix;
}
@Override public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
return new DriverPropertyInfo[0];
}
@Override public int getMajorVersion() {
return 3;
}
@Override public int getMinorVersion() {
return 2;
}
@Override public boolean jdbcCompliant() {
return false;
}
@Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { | throw ExceptionBuilder.buildUnsupportedOperationException(); |
larusba/neo4j-jdbc | neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jDriver.java | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
//
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/Neo4jJdbcRuntimeException.java
// public class Neo4jJdbcRuntimeException extends RuntimeException {
// public Neo4jJdbcRuntimeException (Throwable t) {
// super(t);
// }
// }
| import org.neo4j.jdbc.utils.ExceptionBuilder;
import org.neo4j.jdbc.utils.Neo4jJdbcRuntimeException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger; | Properties properties = new Properties();
if(params != null) {
for (Map.Entry<Object, Object> entry : params.entrySet()) {
properties.put(entry.getKey().toString().toLowerCase(),entry.getValue());
}
}
if (url.contains("?")) {
String urlProps = url.substring(url.indexOf('?') + 1);
urlProps = decodeUrlComponent(urlProps);
String[] props = urlProps.split("[,&]");
for (String prop : props) {
int idx = prop.indexOf('=');
if (idx != -1) {
String key = prop.substring(0, idx);
String value = prop.substring(idx + 1);
properties.put(key.toLowerCase(), value);
} else {
properties.put(prop.toLowerCase(), "true");
}
}
properties.put("user", getUser(properties));
}
return properties;
}
private String decodeUrlComponent(String urlProps) {
try {
return URLDecoder.decode(urlProps, "UTF-8");
} catch (UnsupportedEncodingException e) { | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
//
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/Neo4jJdbcRuntimeException.java
// public class Neo4jJdbcRuntimeException extends RuntimeException {
// public Neo4jJdbcRuntimeException (Throwable t) {
// super(t);
// }
// }
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jDriver.java
import org.neo4j.jdbc.utils.ExceptionBuilder;
import org.neo4j.jdbc.utils.Neo4jJdbcRuntimeException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;
Properties properties = new Properties();
if(params != null) {
for (Map.Entry<Object, Object> entry : params.entrySet()) {
properties.put(entry.getKey().toString().toLowerCase(),entry.getValue());
}
}
if (url.contains("?")) {
String urlProps = url.substring(url.indexOf('?') + 1);
urlProps = decodeUrlComponent(urlProps);
String[] props = urlProps.split("[,&]");
for (String prop : props) {
int idx = prop.indexOf('=');
if (idx != -1) {
String key = prop.substring(0, idx);
String value = prop.substring(idx + 1);
properties.put(key.toLowerCase(), value);
} else {
properties.put(prop.toLowerCase(), "true");
}
}
properties.put("user", getUser(properties));
}
return properties;
}
private String decodeUrlComponent(String urlProps) {
try {
return URLDecoder.decode(urlProps, "UTF-8");
} catch (UnsupportedEncodingException e) { | throw new Neo4jJdbcRuntimeException(e); |
larusba/neo4j-jdbc | neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jResultSet.java | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
| import org.neo4j.jdbc.utils.ExceptionBuilder;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.util.Calendar;
import java.util.Map; | /*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 03/02/16
*/
package org.neo4j.jdbc;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public abstract class Neo4jResultSet implements ResultSet, Loggable {
public static final int DEFAULT_TYPE = TYPE_FORWARD_ONLY;
public static final int DEFAULT_CONCURRENCY = CONCUR_READ_ONLY;
public static final int DEFAULT_HOLDABILITY = CLOSE_CURSORS_AT_COMMIT;
protected static final int DEFAULT_FETCH_SIZE = 1;
protected static final String COLUMN_NOT_PRESENT = "Column not present in ResultSet";
/**
* Close state of this ResultSet.
*/
protected boolean isClosed = false;
protected int currentRowNumber = 0;
protected boolean debug;
protected int debugLevel;
protected int type;
protected int concurrency;
protected int holdability;
protected Statement statement;
/**
* Is the last read column was null.
*/
protected boolean wasNull = false;
public Neo4jResultSet(Statement statement, int... params) {
this.statement = statement;
this.type = params.length > 0 ? params[0] : TYPE_FORWARD_ONLY;
this.concurrency = params.length > 1 ? params[1] : CONCUR_READ_ONLY;
this.holdability = params.length > 2 ? params[2] : CLOSE_CURSORS_AT_COMMIT;
}
/*----------------------------------------*/
/* Some useful, check method */
/*----------------------------------------*/
/**
* Check if the connection is closed or not.
* If it is, we throw an exception.
*
* @throws SQLException if the {@link Neo4jResultSet} is closed
*/
protected void checkClosed() throws SQLException {
if (this.isClosed()) {
throw new SQLException("ResultSet already closed");
}
}
/**
* Check if the ResultSet is closed.
*
* @return <code>true</code> if <code>ResultSet</code> is closed.
* @throws SQLException in case of problems when checking if closed.
*/
@Override public boolean isClosed() throws SQLException {
return this.isClosed;
}
/*------------------------------------*/
/* Default implementation */
/*------------------------------------*/
@Override public <T> T unwrap(Class<T> iface) throws SQLException {
return Wrapper.unwrap(iface, this);
}
@Override public boolean isWrapperFor(Class<?> iface) throws SQLException {
return Wrapper.isWrapperFor(iface, this.getClass());
}
@Override public SQLWarning getWarnings() throws SQLException {
checkClosed();
return null;
}
@Override public void clearWarnings() throws SQLException {
checkClosed();
}
@Override public boolean next() throws SQLException {
boolean result = innerNext();
if (result) {
currentRowNumber++;
}
return result;
}
@Override public void setFetchSize(int rows) throws SQLException {
this.checkClosed();
if (rows < 0) {
throw new SQLException("Fetch size must be >= 0");
}
}
@Override public int getFetchSize() throws SQLException {
this.checkClosed();
return DEFAULT_FETCH_SIZE;
}
protected abstract boolean innerNext() throws SQLException;
/*---------------------------------*/
/* Not implemented yet */
/*---------------------------------*/
@Override public byte getByte(int columnIndex) throws SQLException { | // Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/utils/ExceptionBuilder.java
// public class ExceptionBuilder {
//
// private ExceptionBuilder() {}
//
// /**
// * An <code>UnsupportedOperationException</code> exception builder that retrueve it's caller to make
// * a not yet implemented exception with method and class name.
// *
// * @return an UnsupportedOperationException
// */
// public static UnsupportedOperationException buildUnsupportedOperationException() {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// if (stackTraceElements.length > 2) {
// StackTraceElement caller = stackTraceElements[2];
//
// StringBuilder sb = new StringBuilder().append("Method ").append(caller.getMethodName()).append(" in class ").append(caller.getClassName())
// .append(" is not yet implemented.");
//
// return new UnsupportedOperationException(sb.toString());
// } else {
// return new UnsupportedOperationException("Not yet implemented.");
// }
// }
// }
// Path: neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jResultSet.java
import org.neo4j.jdbc.utils.ExceptionBuilder;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.util.Calendar;
import java.util.Map;
/*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 03/02/16
*/
package org.neo4j.jdbc;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public abstract class Neo4jResultSet implements ResultSet, Loggable {
public static final int DEFAULT_TYPE = TYPE_FORWARD_ONLY;
public static final int DEFAULT_CONCURRENCY = CONCUR_READ_ONLY;
public static final int DEFAULT_HOLDABILITY = CLOSE_CURSORS_AT_COMMIT;
protected static final int DEFAULT_FETCH_SIZE = 1;
protected static final String COLUMN_NOT_PRESENT = "Column not present in ResultSet";
/**
* Close state of this ResultSet.
*/
protected boolean isClosed = false;
protected int currentRowNumber = 0;
protected boolean debug;
protected int debugLevel;
protected int type;
protected int concurrency;
protected int holdability;
protected Statement statement;
/**
* Is the last read column was null.
*/
protected boolean wasNull = false;
public Neo4jResultSet(Statement statement, int... params) {
this.statement = statement;
this.type = params.length > 0 ? params[0] : TYPE_FORWARD_ONLY;
this.concurrency = params.length > 1 ? params[1] : CONCUR_READ_ONLY;
this.holdability = params.length > 2 ? params[2] : CLOSE_CURSORS_AT_COMMIT;
}
/*----------------------------------------*/
/* Some useful, check method */
/*----------------------------------------*/
/**
* Check if the connection is closed or not.
* If it is, we throw an exception.
*
* @throws SQLException if the {@link Neo4jResultSet} is closed
*/
protected void checkClosed() throws SQLException {
if (this.isClosed()) {
throw new SQLException("ResultSet already closed");
}
}
/**
* Check if the ResultSet is closed.
*
* @return <code>true</code> if <code>ResultSet</code> is closed.
* @throws SQLException in case of problems when checking if closed.
*/
@Override public boolean isClosed() throws SQLException {
return this.isClosed;
}
/*------------------------------------*/
/* Default implementation */
/*------------------------------------*/
@Override public <T> T unwrap(Class<T> iface) throws SQLException {
return Wrapper.unwrap(iface, this);
}
@Override public boolean isWrapperFor(Class<?> iface) throws SQLException {
return Wrapper.isWrapperFor(iface, this.getClass());
}
@Override public SQLWarning getWarnings() throws SQLException {
checkClosed();
return null;
}
@Override public void clearWarnings() throws SQLException {
checkClosed();
}
@Override public boolean next() throws SQLException {
boolean result = innerNext();
if (result) {
currentRowNumber++;
}
return result;
}
@Override public void setFetchSize(int rows) throws SQLException {
this.checkClosed();
if (rows < 0) {
throw new SQLException("Fetch size must be >= 0");
}
}
@Override public int getFetchSize() throws SQLException {
this.checkClosed();
return DEFAULT_FETCH_SIZE;
}
protected abstract boolean innerNext() throws SQLException;
/*---------------------------------*/
/* Not implemented yet */
/*---------------------------------*/
@Override public byte getByte(int columnIndex) throws SQLException { | throw ExceptionBuilder.buildUnsupportedOperationException(); |
larusba/neo4j-jdbc | neo4j-jdbc-bolt/src/test/java/org/neo4j/jdbc/bolt/BoltNeo4jPreparedStatementIT.java | // Path: neo4j-jdbc-bolt/src/test/java/org/neo4j/jdbc/bolt/data/StatementData.java
// public class StatementData {
// public static String STATEMENT_MATCH_ALL = "MATCH (n) RETURN n;";
// public static String STATEMENT_MATCH_ALL_STRING = "MATCH (n:User) RETURN n.name;";
// public static String STATEMENT_MATCH_NODES = "MATCH (n:User) RETURN n;";
// public static String STATEMENT_MATCH_NODES_MORE = "MATCH (n:User)-[]->(s:Session) RETURN n, s;";
// public static String STATEMENT_MATCH_MISC = "MATCH (n:User) RETURN n, n.name;";
// public static String STATEMENT_MATCH_RELATIONS = "MATCH ()-[r:CONNECTED_IN]-() RETURN r;";
// public static String STATEMENT_MATCH_NODES_RELATIONS = "MATCH (n:User)-[r:CONNECTED_IN]->(s:Session) RETURN n, r, s";
// public static String STATEMENT_CREATE = "CREATE (n:User {name:\"test\"});";
// public static String STATEMENT_CREATE_REV = "MATCH (n:User {name:\"test\"}) DELETE n;";
// public static String STATEMENT_CREATE_TWO_PROPERTIES = "CREATE (n:User {name:\"test\", surname:\"testAgain\"});";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_REV = "MATCH (n:USer {name:\"test\", surname:\"testAgain\"}) DETACH DELETE n;";
// public static String STATEMENT_MATCH_ALL_STRING_PARAMETRIC = "MATCH (n) WHERE n.name = ? RETURN n.surname;";
// public static String STATEMENT_MATCH_ALL_STRING_PARAMETRIC_NAMED = "MATCH (n) WHERE n.name = {1} RETURN n.surname;";
// public static String STATEMENT_CREATE_OTHER_TYPE_AND_RELATIONS = "MATCH (n:User) CREATE (n)-[:CONNECTED_IN {date:1459248821051}]->(:Session {status:true});";
// public static String STATEMENT_CREATE_OTHER_TYPE_AND_RELATIONS_REV = "MATCH (s:Session) DETACH DELETE s;";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_PARAMETRIC = "CREATE (n:User {name:?, surname:?});";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_PARAMETRIC_REV = "MATCH (n:User {name:?, surname:?}) DETACH DELETE n;";
// public static String STATEMENT_CLEAR_DB = "MATCH (n) DETACH DELETE n;";
// public static String STATEMENT_COUNT_NODES = "MATCH (n) RETURN count(n) AS total;";
// }
| import java.sql.SQLException;
import org.junit.ClassRule;
import org.junit.Test;
import org.neo4j.graphdb.Result;
import org.neo4j.jdbc.bolt.data.StatementData;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.BatchUpdateException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; | /*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 25/03/16
*/
package org.neo4j.jdbc.bolt;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public class BoltNeo4jPreparedStatementIT {
@ClassRule public static Neo4jBoltRule neo4j = new Neo4jBoltRule();
/*------------------------------*/
/* executeQuery */
/*------------------------------*/
@Test public void executeQueryShouldExecuteAndReturnCorrectData() throws SQLException { | // Path: neo4j-jdbc-bolt/src/test/java/org/neo4j/jdbc/bolt/data/StatementData.java
// public class StatementData {
// public static String STATEMENT_MATCH_ALL = "MATCH (n) RETURN n;";
// public static String STATEMENT_MATCH_ALL_STRING = "MATCH (n:User) RETURN n.name;";
// public static String STATEMENT_MATCH_NODES = "MATCH (n:User) RETURN n;";
// public static String STATEMENT_MATCH_NODES_MORE = "MATCH (n:User)-[]->(s:Session) RETURN n, s;";
// public static String STATEMENT_MATCH_MISC = "MATCH (n:User) RETURN n, n.name;";
// public static String STATEMENT_MATCH_RELATIONS = "MATCH ()-[r:CONNECTED_IN]-() RETURN r;";
// public static String STATEMENT_MATCH_NODES_RELATIONS = "MATCH (n:User)-[r:CONNECTED_IN]->(s:Session) RETURN n, r, s";
// public static String STATEMENT_CREATE = "CREATE (n:User {name:\"test\"});";
// public static String STATEMENT_CREATE_REV = "MATCH (n:User {name:\"test\"}) DELETE n;";
// public static String STATEMENT_CREATE_TWO_PROPERTIES = "CREATE (n:User {name:\"test\", surname:\"testAgain\"});";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_REV = "MATCH (n:USer {name:\"test\", surname:\"testAgain\"}) DETACH DELETE n;";
// public static String STATEMENT_MATCH_ALL_STRING_PARAMETRIC = "MATCH (n) WHERE n.name = ? RETURN n.surname;";
// public static String STATEMENT_MATCH_ALL_STRING_PARAMETRIC_NAMED = "MATCH (n) WHERE n.name = {1} RETURN n.surname;";
// public static String STATEMENT_CREATE_OTHER_TYPE_AND_RELATIONS = "MATCH (n:User) CREATE (n)-[:CONNECTED_IN {date:1459248821051}]->(:Session {status:true});";
// public static String STATEMENT_CREATE_OTHER_TYPE_AND_RELATIONS_REV = "MATCH (s:Session) DETACH DELETE s;";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_PARAMETRIC = "CREATE (n:User {name:?, surname:?});";
// public static String STATEMENT_CREATE_TWO_PROPERTIES_PARAMETRIC_REV = "MATCH (n:User {name:?, surname:?}) DETACH DELETE n;";
// public static String STATEMENT_CLEAR_DB = "MATCH (n) DETACH DELETE n;";
// public static String STATEMENT_COUNT_NODES = "MATCH (n) RETURN count(n) AS total;";
// }
// Path: neo4j-jdbc-bolt/src/test/java/org/neo4j/jdbc/bolt/BoltNeo4jPreparedStatementIT.java
import java.sql.SQLException;
import org.junit.ClassRule;
import org.junit.Test;
import org.neo4j.graphdb.Result;
import org.neo4j.jdbc.bolt.data.StatementData;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.BatchUpdateException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 25/03/16
*/
package org.neo4j.jdbc.bolt;
/**
* @author AgileLARUS
* @since 3.0.0
*/
public class BoltNeo4jPreparedStatementIT {
@ClassRule public static Neo4jBoltRule neo4j = new Neo4jBoltRule();
/*------------------------------*/
/* executeQuery */
/*------------------------------*/
@Test public void executeQueryShouldExecuteAndReturnCorrectData() throws SQLException { | neo4j.getGraphDatabase().execute(StatementData.STATEMENT_CREATE_TWO_PROPERTIES); |
larusba/neo4j-jdbc | neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerHttpTestWithLocalServer.java | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
| import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
| /*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerHttpTestWithLocalServer extends MybatisTestUtil {
/*
* Need to start a neo4j instance and load the "Movie" example graph
*/
@Test
@Ignore
public void testSelectActorBornIn1973() {
| // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
// Path: neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerHttpTestWithLocalServer.java
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
/*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerHttpTestWithLocalServer extends MybatisTestUtil {
/*
* Need to start a neo4j instance and load the "Movie" example graph
*/
@Test
@Ignore
public void testSelectActorBornIn1973() {
| ConnectionFactory.getSqlSessionFactory("http-database-config.xml");
|
larusba/neo4j-jdbc | neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerHttpTestWithLocalServer.java | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
| import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
| /*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerHttpTestWithLocalServer extends MybatisTestUtil {
/*
* Need to start a neo4j instance and load the "Movie" example graph
*/
@Test
@Ignore
public void testSelectActorBornIn1973() {
ConnectionFactory.getSqlSessionFactory("http-database-config.xml");
| // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
// Path: neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerHttpTestWithLocalServer.java
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
/*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerHttpTestWithLocalServer extends MybatisTestUtil {
/*
* Need to start a neo4j instance and load the "Movie" example graph
*/
@Test
@Ignore
public void testSelectActorBornIn1973() {
ConnectionFactory.getSqlSessionFactory("http-database-config.xml");
| Actor actor = ActorManager.selectActorByBorn(1973);
|
larusba/neo4j-jdbc | neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerHttpTestWithLocalServer.java | // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
| import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
| /*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerHttpTestWithLocalServer extends MybatisTestUtil {
/*
* Need to start a neo4j instance and load the "Movie" example graph
*/
@Test
@Ignore
public void testSelectActorBornIn1973() {
ConnectionFactory.getSqlSessionFactory("http-database-config.xml");
| // Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/bean/Actor.java
// public class Actor {
//
// private int nodeId;
// private int born;
// private String name;
//
// public int getNodeId() {
// return nodeId;
// }
//
// public void setNodeId(int nodeId) {
// this.nodeId = nodeId;
// }
//
// public int getBorn() {
// return born;
// }
//
// public void setBorn(int born) {
// this.born = born;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ActorManager.java
// public class ActorManager {
//
// private ActorManager() {}
//
// public static Actor selectActorByBorn(int born) {
// SqlSession sqlSession = ConnectionFactory.getSqlSessionFactory()
// .openSession();
// try {
// ActorMapper categoryMapper = sqlSession
// .getMapper(ActorMapper.class);
// return categoryMapper.selectActorByBorn(born);
// } finally {
// sqlSession.close();
// }
// }
// }
//
// Path: neo4j-jdbc-examples/mybatis/src/main/java/org/neo4j/jdbc/example/mybatis/util/ConnectionFactory.java
// public class ConnectionFactory {
//
// private static final String DATABASE_CONFIG_XML = "database-config.xml";
//
// private static SqlSessionFactory factory;
//
// private ConnectionFactory() {}
//
// public static SqlSessionFactory getSqlSessionFactory() {
// return getSqlSessionFactory(DATABASE_CONFIG_XML);
// }
//
// public static SqlSessionFactory getSqlSessionFactory(String config) {
// if (factory == null) {
// try (Reader reader = Resources.getResourceAsReader(config)){
// factory = new SqlSessionFactoryBuilder().build(reader);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// return factory;
// }
//
// public static SqlSessionFactory getSqlSessionFactory(Configuration configuration) {
// if (factory == null) {
// factory = new SqlSessionFactoryBuilder().build(configuration);
// }
// return factory;
// }
// }
// Path: neo4j-jdbc-examples/mybatis/src/test/java/org/neo4j/jdbc/example/mybatis/ActorManagerHttpTestWithLocalServer.java
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.jdbc.example.mybatis.bean.Actor;
import org.neo4j.jdbc.example.mybatis.util.ActorManager;
import org.neo4j.jdbc.example.mybatis.util.ConnectionFactory;
/*
*
* Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it]
* <p>
* This file is part of the "LARUS Integration Framework for Neo4j".
* <p>
* The "LARUS Integration Framework for Neo4j" is 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
* <p>
* Created on 24/4/2016
*
*/
package org.neo4j.jdbc.example.mybatis;
/**
* @author AgileLARUS
* @since 3.0.2
*/
public class ActorManagerHttpTestWithLocalServer extends MybatisTestUtil {
/*
* Need to start a neo4j instance and load the "Movie" example graph
*/
@Test
@Ignore
public void testSelectActorBornIn1973() {
ConnectionFactory.getSqlSessionFactory("http-database-config.xml");
| Actor actor = ActorManager.selectActorByBorn(1973);
|
lumag/JBookReader | src/org/jbookreader/formatengine/IRenderingObject.java | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
| import org.jbookreader.book.bom.INode; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine;
/**
* This interface represents a rendering object.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public interface IRenderingObject {
/**
* Returns the total height of the object.
* @return the total height of the object.
*/
double getHeight();
/**
* Returns the width of the object.
* @return the width of the object.
*/
double getWidth();
/**
* Renders the object to assigned
* {@link org.jbookreader.formatengine.IBookPainter}.
*
*/
void render();
/**
* Returns the node which this rendering object represents.
* @return the node which this rendering object represents.
*/ | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
// Path: src/org/jbookreader/formatengine/IRenderingObject.java
import org.jbookreader.book.bom.INode;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine;
/**
* This interface represents a rendering object.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public interface IRenderingObject {
/**
* Returns the total height of the object.
* @return the total height of the object.
*/
double getHeight();
/**
* Returns the width of the object.
* @return the width of the object.
*/
double getWidth();
/**
* Renders the object to assigned
* {@link org.jbookreader.formatengine.IBookPainter}.
*
*/
void render();
/**
* Returns the node which this rendering object represents.
* @return the node which this rendering object represents.
*/ | INode getNode(); |
lumag/JBookReader | src/org/jbookreader/ui/swing/painter/SwingBookPainter.java | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IFont.java
// public interface IFont {
// /**
// * Returns the family name of the font.
// * @return the family name of the font.
// */
// String getFontFamily();
//
// /**
// * Returns the size of the font.
// * @return the size of the font.
// */
//
// double getFontSize();
// /**
// * Returns the width of space in this font.
// * @return the width of space in this font.
// */
// double getSpaceWidth();
// /**
// * Calculates dimensions to be used for rendering the specified string part
// * with given font.
// * @param s the string to calculate dimensions for
// * @param start The index of the first character in the string
// * @param end The index of the character following the last character in the subsequence
// * @return the dimensions of the string when rendered.
// */
// RenderingDimensions calculateStringDimensions(String s, int start, int end);
// /**
// * Renders the string with given font
// * @param s the string to render
// * @param start The index of the first character in the string
// * @param end The index of the character following the last character in the subsequence
// */
// void renderString(String s, int start, int end);
//
// }
//
// Path: src/org/jbookreader/formatengine/IInlineRenderingObject.java
// public interface IInlineRenderingObject extends IRenderingObject {
// /**
// * Returns the depth (the distance between the baseline
// * and the bottom) of the object.
// * @return the depth of the object.
// */
// double getDepth();
//
// void renderInline();
//
// int getAdjustability();
//
// void adjustWidth(double width) throws UnsupportedOperationException;
// }
| import java.awt.Color;
import java.awt.Graphics2D;
import java.io.InputStream;
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IFont;
import org.jbookreader.formatengine.IInlineRenderingObject; | }
public double getHeight() {
return this.myHeight;
}
public double getWidth() {
return this.myWidth;
}
public void addHorizontalStrut(double size) {
this.myCurrentX += size;
}
public void addVerticalStrut(double size) {
this.myCurrentY += size;
}
public IFont getFont(String name, int size) {
return new SwingFont(this, name, size);
}
public double getXCoordinate() {
return this.myCurrentX;
}
public double getYCoordinate() {
return this.myCurrentY;
}
| // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IFont.java
// public interface IFont {
// /**
// * Returns the family name of the font.
// * @return the family name of the font.
// */
// String getFontFamily();
//
// /**
// * Returns the size of the font.
// * @return the size of the font.
// */
//
// double getFontSize();
// /**
// * Returns the width of space in this font.
// * @return the width of space in this font.
// */
// double getSpaceWidth();
// /**
// * Calculates dimensions to be used for rendering the specified string part
// * with given font.
// * @param s the string to calculate dimensions for
// * @param start The index of the first character in the string
// * @param end The index of the character following the last character in the subsequence
// * @return the dimensions of the string when rendered.
// */
// RenderingDimensions calculateStringDimensions(String s, int start, int end);
// /**
// * Renders the string with given font
// * @param s the string to render
// * @param start The index of the first character in the string
// * @param end The index of the character following the last character in the subsequence
// */
// void renderString(String s, int start, int end);
//
// }
//
// Path: src/org/jbookreader/formatengine/IInlineRenderingObject.java
// public interface IInlineRenderingObject extends IRenderingObject {
// /**
// * Returns the depth (the distance between the baseline
// * and the bottom) of the object.
// * @return the depth of the object.
// */
// double getDepth();
//
// void renderInline();
//
// int getAdjustability();
//
// void adjustWidth(double width) throws UnsupportedOperationException;
// }
// Path: src/org/jbookreader/ui/swing/painter/SwingBookPainter.java
import java.awt.Color;
import java.awt.Graphics2D;
import java.io.InputStream;
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IFont;
import org.jbookreader.formatengine.IInlineRenderingObject;
}
public double getHeight() {
return this.myHeight;
}
public double getWidth() {
return this.myWidth;
}
public void addHorizontalStrut(double size) {
this.myCurrentX += size;
}
public void addVerticalStrut(double size) {
this.myCurrentY += size;
}
public IFont getFont(String name, int size) {
return new SwingFont(this, name, size);
}
public double getXCoordinate() {
return this.myCurrentX;
}
public double getYCoordinate() {
return this.myCurrentY;
}
| public IInlineRenderingObject getImage(INode node, String contentType, InputStream stream) { |
lumag/JBookReader | src/org/jbookreader/ui/swing/painter/SwingBookPainter.java | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IFont.java
// public interface IFont {
// /**
// * Returns the family name of the font.
// * @return the family name of the font.
// */
// String getFontFamily();
//
// /**
// * Returns the size of the font.
// * @return the size of the font.
// */
//
// double getFontSize();
// /**
// * Returns the width of space in this font.
// * @return the width of space in this font.
// */
// double getSpaceWidth();
// /**
// * Calculates dimensions to be used for rendering the specified string part
// * with given font.
// * @param s the string to calculate dimensions for
// * @param start The index of the first character in the string
// * @param end The index of the character following the last character in the subsequence
// * @return the dimensions of the string when rendered.
// */
// RenderingDimensions calculateStringDimensions(String s, int start, int end);
// /**
// * Renders the string with given font
// * @param s the string to render
// * @param start The index of the first character in the string
// * @param end The index of the character following the last character in the subsequence
// */
// void renderString(String s, int start, int end);
//
// }
//
// Path: src/org/jbookreader/formatengine/IInlineRenderingObject.java
// public interface IInlineRenderingObject extends IRenderingObject {
// /**
// * Returns the depth (the distance between the baseline
// * and the bottom) of the object.
// * @return the depth of the object.
// */
// double getDepth();
//
// void renderInline();
//
// int getAdjustability();
//
// void adjustWidth(double width) throws UnsupportedOperationException;
// }
| import java.awt.Color;
import java.awt.Graphics2D;
import java.io.InputStream;
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IFont;
import org.jbookreader.formatengine.IInlineRenderingObject; | }
public double getHeight() {
return this.myHeight;
}
public double getWidth() {
return this.myWidth;
}
public void addHorizontalStrut(double size) {
this.myCurrentX += size;
}
public void addVerticalStrut(double size) {
this.myCurrentY += size;
}
public IFont getFont(String name, int size) {
return new SwingFont(this, name, size);
}
public double getXCoordinate() {
return this.myCurrentX;
}
public double getYCoordinate() {
return this.myCurrentY;
}
| // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IFont.java
// public interface IFont {
// /**
// * Returns the family name of the font.
// * @return the family name of the font.
// */
// String getFontFamily();
//
// /**
// * Returns the size of the font.
// * @return the size of the font.
// */
//
// double getFontSize();
// /**
// * Returns the width of space in this font.
// * @return the width of space in this font.
// */
// double getSpaceWidth();
// /**
// * Calculates dimensions to be used for rendering the specified string part
// * with given font.
// * @param s the string to calculate dimensions for
// * @param start The index of the first character in the string
// * @param end The index of the character following the last character in the subsequence
// * @return the dimensions of the string when rendered.
// */
// RenderingDimensions calculateStringDimensions(String s, int start, int end);
// /**
// * Renders the string with given font
// * @param s the string to render
// * @param start The index of the first character in the string
// * @param end The index of the character following the last character in the subsequence
// */
// void renderString(String s, int start, int end);
//
// }
//
// Path: src/org/jbookreader/formatengine/IInlineRenderingObject.java
// public interface IInlineRenderingObject extends IRenderingObject {
// /**
// * Returns the depth (the distance between the baseline
// * and the bottom) of the object.
// * @return the depth of the object.
// */
// double getDepth();
//
// void renderInline();
//
// int getAdjustability();
//
// void adjustWidth(double width) throws UnsupportedOperationException;
// }
// Path: src/org/jbookreader/ui/swing/painter/SwingBookPainter.java
import java.awt.Color;
import java.awt.Graphics2D;
import java.io.InputStream;
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IFont;
import org.jbookreader.formatengine.IInlineRenderingObject;
}
public double getHeight() {
return this.myHeight;
}
public double getWidth() {
return this.myWidth;
}
public void addHorizontalStrut(double size) {
this.myCurrentX += size;
}
public void addVerticalStrut(double size) {
this.myCurrentY += size;
}
public IFont getFont(String name, int size) {
return new SwingFont(this, name, size);
}
public double getXCoordinate() {
return this.myCurrentX;
}
public double getYCoordinate() {
return this.myCurrentY;
}
| public IInlineRenderingObject getImage(INode node, String contentType, InputStream stream) { |
lumag/JBookReader | src/org/jbookreader/formatengine/objects/AbstractInlineRenderingObject.java | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IInlineRenderingObject.java
// public interface IInlineRenderingObject extends IRenderingObject {
// /**
// * Returns the depth (the distance between the baseline
// * and the bottom) of the object.
// * @return the depth of the object.
// */
// double getDepth();
//
// void renderInline();
//
// int getAdjustability();
//
// void adjustWidth(double width) throws UnsupportedOperationException;
// }
| import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IInlineRenderingObject; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine.objects;
public abstract class AbstractInlineRenderingObject extends
AbstractRenderingObject implements IInlineRenderingObject {
private double myDepth;
| // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IInlineRenderingObject.java
// public interface IInlineRenderingObject extends IRenderingObject {
// /**
// * Returns the depth (the distance between the baseline
// * and the bottom) of the object.
// * @return the depth of the object.
// */
// double getDepth();
//
// void renderInline();
//
// int getAdjustability();
//
// void adjustWidth(double width) throws UnsupportedOperationException;
// }
// Path: src/org/jbookreader/formatengine/objects/AbstractInlineRenderingObject.java
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IInlineRenderingObject;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine.objects;
public abstract class AbstractInlineRenderingObject extends
AbstractRenderingObject implements IInlineRenderingObject {
private double myDepth;
| public AbstractInlineRenderingObject(IBookPainter painter, INode node) { |
lumag/JBookReader | src/org/jbookreader/formatengine/objects/AbstractInlineRenderingObject.java | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IInlineRenderingObject.java
// public interface IInlineRenderingObject extends IRenderingObject {
// /**
// * Returns the depth (the distance between the baseline
// * and the bottom) of the object.
// * @return the depth of the object.
// */
// double getDepth();
//
// void renderInline();
//
// int getAdjustability();
//
// void adjustWidth(double width) throws UnsupportedOperationException;
// }
| import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IInlineRenderingObject; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine.objects;
public abstract class AbstractInlineRenderingObject extends
AbstractRenderingObject implements IInlineRenderingObject {
private double myDepth;
| // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IInlineRenderingObject.java
// public interface IInlineRenderingObject extends IRenderingObject {
// /**
// * Returns the depth (the distance between the baseline
// * and the bottom) of the object.
// * @return the depth of the object.
// */
// double getDepth();
//
// void renderInline();
//
// int getAdjustability();
//
// void adjustWidth(double width) throws UnsupportedOperationException;
// }
// Path: src/org/jbookreader/formatengine/objects/AbstractInlineRenderingObject.java
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IInlineRenderingObject;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine.objects;
public abstract class AbstractInlineRenderingObject extends
AbstractRenderingObject implements IInlineRenderingObject {
private double myDepth;
| public AbstractInlineRenderingObject(IBookPainter painter, INode node) { |
lumag/JBookReader | src/org/jbookreader/book/stylesheet/fb2/FB2StyleStack.java | // Path: src/org/jbookreader/book/stylesheet/EDisplayType.java
// public enum EDisplayType {
// /**
// * A new box.
// */
// BLOCK,
// /**
// * New box on the same line, as the previous context.
// */
// INLINE,
// /**
// * Not displayed. Child items aren't displayed too.
// */
// NONE;
// }
//
// Path: src/org/jbookreader/book/stylesheet/ETextAlign.java
// public enum ETextAlign {
// LEFT,
// RIGHT,
// CENTER,
// JUSTIFY;
// }
//
// Path: src/org/jbookreader/book/stylesheet/IStyleStack.java
// public interface IStyleStack {
// /**
// * Pushes new tag into the style stack.
// *
// * @param name the name of the tag
// * @param klass the class of the tag
// * @param id the id of the tag
// */
// void pushTag(String name, String klass, String id);
//
// /**
// * Pops last tag from the style stack.
// *
// */
// void popTag();
//
//
// /**
// * Returns the 'display' property of the node
// * @return display type of the node.
// */
// EDisplayType getDisplay();
//
// /**
// * Returns the left margin for the node.
// * @return the left margin for the node.
// */
// double getMarginLeft();
// /**
// * Returns the right margin for the node.
// * @return the right margin for the node.
// */
// double getMarginRight();
// /**
// * Returns the top margin for the node.
// * @return the top margin for the node.
// */
// double getMarginTop();
// /**
// * Returns the bottom margin for the node.
// * @return the bottom margin for the node.
// */
// double getMarginBottom();
//
// /**
// * Returns the indentation for the first line of the node.
// * @return the indentation for the first line of the node.
// */
// double getTextIndent();
// /**
// * Returns the relative line height.
// * @return the relative line height.
// */
// double getLineHeight();
// /**
// * Returns font family.
// * @return font family.
// */
// String getFontFamily();
// /**
// * Returns font size.
// * @return font size.
// */
// int getFontSize();
//
// /**
// * Sets default font family.
// *
// * @param fontFamily default font family
// */
// void setDefaultFontFamily(String fontFamily);
//
// /**
// * Sets default font size.
// *
// * @param size default font size
// */
// void setDefaultFontSize(int size);
//
// ETextAlign getTextAlign();
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import org.jbookreader.book.stylesheet.EDisplayType;
import org.jbookreader.book.stylesheet.ETextAlign;
import org.jbookreader.book.stylesheet.IStyleStack; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.book.stylesheet.fb2;
class FB2StyleStack implements IStyleStack {
private String myFontFamily = "Serif";
private int myFontSize = 12;
private List<SimpleNode> myNodesList = new ArrayList<SimpleNode>();
public void pushTag(String name, String klass, String id) {
this.myNodesList.add(new SimpleNode(name, klass, id));
}
public void popTag() {
this.myNodesList.remove(this.myNodesList.size()-1);
}
| // Path: src/org/jbookreader/book/stylesheet/EDisplayType.java
// public enum EDisplayType {
// /**
// * A new box.
// */
// BLOCK,
// /**
// * New box on the same line, as the previous context.
// */
// INLINE,
// /**
// * Not displayed. Child items aren't displayed too.
// */
// NONE;
// }
//
// Path: src/org/jbookreader/book/stylesheet/ETextAlign.java
// public enum ETextAlign {
// LEFT,
// RIGHT,
// CENTER,
// JUSTIFY;
// }
//
// Path: src/org/jbookreader/book/stylesheet/IStyleStack.java
// public interface IStyleStack {
// /**
// * Pushes new tag into the style stack.
// *
// * @param name the name of the tag
// * @param klass the class of the tag
// * @param id the id of the tag
// */
// void pushTag(String name, String klass, String id);
//
// /**
// * Pops last tag from the style stack.
// *
// */
// void popTag();
//
//
// /**
// * Returns the 'display' property of the node
// * @return display type of the node.
// */
// EDisplayType getDisplay();
//
// /**
// * Returns the left margin for the node.
// * @return the left margin for the node.
// */
// double getMarginLeft();
// /**
// * Returns the right margin for the node.
// * @return the right margin for the node.
// */
// double getMarginRight();
// /**
// * Returns the top margin for the node.
// * @return the top margin for the node.
// */
// double getMarginTop();
// /**
// * Returns the bottom margin for the node.
// * @return the bottom margin for the node.
// */
// double getMarginBottom();
//
// /**
// * Returns the indentation for the first line of the node.
// * @return the indentation for the first line of the node.
// */
// double getTextIndent();
// /**
// * Returns the relative line height.
// * @return the relative line height.
// */
// double getLineHeight();
// /**
// * Returns font family.
// * @return font family.
// */
// String getFontFamily();
// /**
// * Returns font size.
// * @return font size.
// */
// int getFontSize();
//
// /**
// * Sets default font family.
// *
// * @param fontFamily default font family
// */
// void setDefaultFontFamily(String fontFamily);
//
// /**
// * Sets default font size.
// *
// * @param size default font size
// */
// void setDefaultFontSize(int size);
//
// ETextAlign getTextAlign();
// }
// Path: src/org/jbookreader/book/stylesheet/fb2/FB2StyleStack.java
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import org.jbookreader.book.stylesheet.EDisplayType;
import org.jbookreader.book.stylesheet.ETextAlign;
import org.jbookreader.book.stylesheet.IStyleStack;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.book.stylesheet.fb2;
class FB2StyleStack implements IStyleStack {
private String myFontFamily = "Serif";
private int myFontSize = 12;
private List<SimpleNode> myNodesList = new ArrayList<SimpleNode>();
public void pushTag(String name, String klass, String id) {
this.myNodesList.add(new SimpleNode(name, klass, id));
}
public void popTag() {
this.myNodesList.remove(this.myNodesList.size()-1);
}
| public EDisplayType getDisplay() { |
lumag/JBookReader | src/org/jbookreader/book/stylesheet/fb2/FB2StyleStack.java | // Path: src/org/jbookreader/book/stylesheet/EDisplayType.java
// public enum EDisplayType {
// /**
// * A new box.
// */
// BLOCK,
// /**
// * New box on the same line, as the previous context.
// */
// INLINE,
// /**
// * Not displayed. Child items aren't displayed too.
// */
// NONE;
// }
//
// Path: src/org/jbookreader/book/stylesheet/ETextAlign.java
// public enum ETextAlign {
// LEFT,
// RIGHT,
// CENTER,
// JUSTIFY;
// }
//
// Path: src/org/jbookreader/book/stylesheet/IStyleStack.java
// public interface IStyleStack {
// /**
// * Pushes new tag into the style stack.
// *
// * @param name the name of the tag
// * @param klass the class of the tag
// * @param id the id of the tag
// */
// void pushTag(String name, String klass, String id);
//
// /**
// * Pops last tag from the style stack.
// *
// */
// void popTag();
//
//
// /**
// * Returns the 'display' property of the node
// * @return display type of the node.
// */
// EDisplayType getDisplay();
//
// /**
// * Returns the left margin for the node.
// * @return the left margin for the node.
// */
// double getMarginLeft();
// /**
// * Returns the right margin for the node.
// * @return the right margin for the node.
// */
// double getMarginRight();
// /**
// * Returns the top margin for the node.
// * @return the top margin for the node.
// */
// double getMarginTop();
// /**
// * Returns the bottom margin for the node.
// * @return the bottom margin for the node.
// */
// double getMarginBottom();
//
// /**
// * Returns the indentation for the first line of the node.
// * @return the indentation for the first line of the node.
// */
// double getTextIndent();
// /**
// * Returns the relative line height.
// * @return the relative line height.
// */
// double getLineHeight();
// /**
// * Returns font family.
// * @return font family.
// */
// String getFontFamily();
// /**
// * Returns font size.
// * @return font size.
// */
// int getFontSize();
//
// /**
// * Sets default font family.
// *
// * @param fontFamily default font family
// */
// void setDefaultFontFamily(String fontFamily);
//
// /**
// * Sets default font size.
// *
// * @param size default font size
// */
// void setDefaultFontSize(int size);
//
// ETextAlign getTextAlign();
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import org.jbookreader.book.stylesheet.EDisplayType;
import org.jbookreader.book.stylesheet.ETextAlign;
import org.jbookreader.book.stylesheet.IStyleStack; | }
public double getTextIndent() {
SimpleNode node = this.myNodesList.get(this.myNodesList.size()-1);
if (node.name.equals("p")) {
return 5;
}
return 0;
}
public double getLineHeight() {
return 1.2;
}
public String getFontFamily() {
return this.myFontFamily;
}
public int getFontSize() {
return this.myFontSize;
}
public void setDefaultFontFamily(String fontFamily) {
this.myFontFamily = fontFamily;
}
public void setDefaultFontSize(int size) {
this.myFontSize = size;
}
| // Path: src/org/jbookreader/book/stylesheet/EDisplayType.java
// public enum EDisplayType {
// /**
// * A new box.
// */
// BLOCK,
// /**
// * New box on the same line, as the previous context.
// */
// INLINE,
// /**
// * Not displayed. Child items aren't displayed too.
// */
// NONE;
// }
//
// Path: src/org/jbookreader/book/stylesheet/ETextAlign.java
// public enum ETextAlign {
// LEFT,
// RIGHT,
// CENTER,
// JUSTIFY;
// }
//
// Path: src/org/jbookreader/book/stylesheet/IStyleStack.java
// public interface IStyleStack {
// /**
// * Pushes new tag into the style stack.
// *
// * @param name the name of the tag
// * @param klass the class of the tag
// * @param id the id of the tag
// */
// void pushTag(String name, String klass, String id);
//
// /**
// * Pops last tag from the style stack.
// *
// */
// void popTag();
//
//
// /**
// * Returns the 'display' property of the node
// * @return display type of the node.
// */
// EDisplayType getDisplay();
//
// /**
// * Returns the left margin for the node.
// * @return the left margin for the node.
// */
// double getMarginLeft();
// /**
// * Returns the right margin for the node.
// * @return the right margin for the node.
// */
// double getMarginRight();
// /**
// * Returns the top margin for the node.
// * @return the top margin for the node.
// */
// double getMarginTop();
// /**
// * Returns the bottom margin for the node.
// * @return the bottom margin for the node.
// */
// double getMarginBottom();
//
// /**
// * Returns the indentation for the first line of the node.
// * @return the indentation for the first line of the node.
// */
// double getTextIndent();
// /**
// * Returns the relative line height.
// * @return the relative line height.
// */
// double getLineHeight();
// /**
// * Returns font family.
// * @return font family.
// */
// String getFontFamily();
// /**
// * Returns font size.
// * @return font size.
// */
// int getFontSize();
//
// /**
// * Sets default font family.
// *
// * @param fontFamily default font family
// */
// void setDefaultFontFamily(String fontFamily);
//
// /**
// * Sets default font size.
// *
// * @param size default font size
// */
// void setDefaultFontSize(int size);
//
// ETextAlign getTextAlign();
// }
// Path: src/org/jbookreader/book/stylesheet/fb2/FB2StyleStack.java
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import org.jbookreader.book.stylesheet.EDisplayType;
import org.jbookreader.book.stylesheet.ETextAlign;
import org.jbookreader.book.stylesheet.IStyleStack;
}
public double getTextIndent() {
SimpleNode node = this.myNodesList.get(this.myNodesList.size()-1);
if (node.name.equals("p")) {
return 5;
}
return 0;
}
public double getLineHeight() {
return 1.2;
}
public String getFontFamily() {
return this.myFontFamily;
}
public int getFontSize() {
return this.myFontSize;
}
public void setDefaultFontFamily(String fontFamily) {
this.myFontFamily = fontFamily;
}
public void setDefaultFontSize(int size) {
this.myFontSize = size;
}
| public ETextAlign getTextAlign() { |
lumag/JBookReader | src/org/jbookreader/book/stylesheet/fb2/FB2StyleSheet.java | // Path: src/org/jbookreader/book/stylesheet/EDisplayType.java
// public enum EDisplayType {
// /**
// * A new box.
// */
// BLOCK,
// /**
// * New box on the same line, as the previous context.
// */
// INLINE,
// /**
// * Not displayed. Child items aren't displayed too.
// */
// NONE;
// }
//
// Path: src/org/jbookreader/book/stylesheet/IStyleSheet.java
// public interface IStyleSheet {
// /**
// * Returns new style stack.
// * @return new style stack.
// */
// IStyleStack newStyleStateStack();
// }
//
// Path: src/org/jbookreader/book/stylesheet/IStyleStack.java
// public interface IStyleStack {
// /**
// * Pushes new tag into the style stack.
// *
// * @param name the name of the tag
// * @param klass the class of the tag
// * @param id the id of the tag
// */
// void pushTag(String name, String klass, String id);
//
// /**
// * Pops last tag from the style stack.
// *
// */
// void popTag();
//
//
// /**
// * Returns the 'display' property of the node
// * @return display type of the node.
// */
// EDisplayType getDisplay();
//
// /**
// * Returns the left margin for the node.
// * @return the left margin for the node.
// */
// double getMarginLeft();
// /**
// * Returns the right margin for the node.
// * @return the right margin for the node.
// */
// double getMarginRight();
// /**
// * Returns the top margin for the node.
// * @return the top margin for the node.
// */
// double getMarginTop();
// /**
// * Returns the bottom margin for the node.
// * @return the bottom margin for the node.
// */
// double getMarginBottom();
//
// /**
// * Returns the indentation for the first line of the node.
// * @return the indentation for the first line of the node.
// */
// double getTextIndent();
// /**
// * Returns the relative line height.
// * @return the relative line height.
// */
// double getLineHeight();
// /**
// * Returns font family.
// * @return font family.
// */
// String getFontFamily();
// /**
// * Returns font size.
// * @return font size.
// */
// int getFontSize();
//
// /**
// * Sets default font family.
// *
// * @param fontFamily default font family
// */
// void setDefaultFontFamily(String fontFamily);
//
// /**
// * Sets default font size.
// *
// * @param size default font size
// */
// void setDefaultFontSize(int size);
//
// ETextAlign getTextAlign();
// }
| import java.util.HashMap;
import java.util.Map;
import org.jbookreader.book.stylesheet.EDisplayType;
import org.jbookreader.book.stylesheet.IStyleSheet;
import org.jbookreader.book.stylesheet.IStyleStack; | };
/**
* These are <code>{display: inline;}</code> tags.
*/
private static final String[] FB2_INLINE_TAGS = {
"strong",
"emphasis",
"strikethrough",
"sub",
"sup",
"code",
"a",
"#text"
};
static {
for (String s: FB2_INLINE_TAGS) {
ourDisplayTypes.put(s, EDisplayType.INLINE);
}
for (String s: FB2_BLOCK_TAGS) {
ourDisplayTypes.put(s, EDisplayType.BLOCK);
}
}
static EDisplayType getDisplay(String name) {
return ourDisplayTypes.get(name);
}
| // Path: src/org/jbookreader/book/stylesheet/EDisplayType.java
// public enum EDisplayType {
// /**
// * A new box.
// */
// BLOCK,
// /**
// * New box on the same line, as the previous context.
// */
// INLINE,
// /**
// * Not displayed. Child items aren't displayed too.
// */
// NONE;
// }
//
// Path: src/org/jbookreader/book/stylesheet/IStyleSheet.java
// public interface IStyleSheet {
// /**
// * Returns new style stack.
// * @return new style stack.
// */
// IStyleStack newStyleStateStack();
// }
//
// Path: src/org/jbookreader/book/stylesheet/IStyleStack.java
// public interface IStyleStack {
// /**
// * Pushes new tag into the style stack.
// *
// * @param name the name of the tag
// * @param klass the class of the tag
// * @param id the id of the tag
// */
// void pushTag(String name, String klass, String id);
//
// /**
// * Pops last tag from the style stack.
// *
// */
// void popTag();
//
//
// /**
// * Returns the 'display' property of the node
// * @return display type of the node.
// */
// EDisplayType getDisplay();
//
// /**
// * Returns the left margin for the node.
// * @return the left margin for the node.
// */
// double getMarginLeft();
// /**
// * Returns the right margin for the node.
// * @return the right margin for the node.
// */
// double getMarginRight();
// /**
// * Returns the top margin for the node.
// * @return the top margin for the node.
// */
// double getMarginTop();
// /**
// * Returns the bottom margin for the node.
// * @return the bottom margin for the node.
// */
// double getMarginBottom();
//
// /**
// * Returns the indentation for the first line of the node.
// * @return the indentation for the first line of the node.
// */
// double getTextIndent();
// /**
// * Returns the relative line height.
// * @return the relative line height.
// */
// double getLineHeight();
// /**
// * Returns font family.
// * @return font family.
// */
// String getFontFamily();
// /**
// * Returns font size.
// * @return font size.
// */
// int getFontSize();
//
// /**
// * Sets default font family.
// *
// * @param fontFamily default font family
// */
// void setDefaultFontFamily(String fontFamily);
//
// /**
// * Sets default font size.
// *
// * @param size default font size
// */
// void setDefaultFontSize(int size);
//
// ETextAlign getTextAlign();
// }
// Path: src/org/jbookreader/book/stylesheet/fb2/FB2StyleSheet.java
import java.util.HashMap;
import java.util.Map;
import org.jbookreader.book.stylesheet.EDisplayType;
import org.jbookreader.book.stylesheet.IStyleSheet;
import org.jbookreader.book.stylesheet.IStyleStack;
};
/**
* These are <code>{display: inline;}</code> tags.
*/
private static final String[] FB2_INLINE_TAGS = {
"strong",
"emphasis",
"strikethrough",
"sub",
"sup",
"code",
"a",
"#text"
};
static {
for (String s: FB2_INLINE_TAGS) {
ourDisplayTypes.put(s, EDisplayType.INLINE);
}
for (String s: FB2_BLOCK_TAGS) {
ourDisplayTypes.put(s, EDisplayType.BLOCK);
}
}
static EDisplayType getDisplay(String name) {
return ourDisplayTypes.get(name);
}
| public IStyleStack newStyleStateStack() { |
lumag/JBookReader | src/org/jbookreader/formatengine/IBookPainter.java | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
| import java.io.InputStream;
import org.jbookreader.book.bom.INode; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine;
/**
* This interface represents a not-so-simple displaying device.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public interface IBookPainter {
/**
* Clears the output device, if it makes sense.
*
*/
void clear();
/**
* Returns the width of the device.
*
* @return the width of the device.
*/
double getWidth();
/**
* Returns the height of the device.
*
* @return the height of the device.
*/
double getHeight();
/**
* This adds the horizontal space of given size.
*
* @param size the size of necessary horizontal space.
*/
void addHorizontalStrut(double size);
/**
* This adds the vertical space of given size.
*
* @param size the size of necessary vertical space.
*/
void addVerticalStrut(double size);
/**
* Allocates and returns specified font.
*
* @param name the name of the font
* @param size font size
* @return the allocated font object.
*/
IFont getFont(String name, int size);
/**
* Returns current X coordinate.
*
* @return current X coordinate.
*/
double getXCoordinate();
/**
* Returns current Y coordinate.
*
* @return current Y coordinate.
*/
double getYCoordinate();
/**
* Returns a rendering object for the image or <code>null</code> if
* the image can't be rendered.
* @param node the node representing the image
* @param contentType the content type of the image
* @param stream the stream with the image
*
* @return a rendering object for the image.
*/ | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
// Path: src/org/jbookreader/formatengine/IBookPainter.java
import java.io.InputStream;
import org.jbookreader.book.bom.INode;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine;
/**
* This interface represents a not-so-simple displaying device.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public interface IBookPainter {
/**
* Clears the output device, if it makes sense.
*
*/
void clear();
/**
* Returns the width of the device.
*
* @return the width of the device.
*/
double getWidth();
/**
* Returns the height of the device.
*
* @return the height of the device.
*/
double getHeight();
/**
* This adds the horizontal space of given size.
*
* @param size the size of necessary horizontal space.
*/
void addHorizontalStrut(double size);
/**
* This adds the vertical space of given size.
*
* @param size the size of necessary vertical space.
*/
void addVerticalStrut(double size);
/**
* Allocates and returns specified font.
*
* @param name the name of the font
* @param size font size
* @return the allocated font object.
*/
IFont getFont(String name, int size);
/**
* Returns current X coordinate.
*
* @return current X coordinate.
*/
double getXCoordinate();
/**
* Returns current Y coordinate.
*
* @return current Y coordinate.
*/
double getYCoordinate();
/**
* Returns a rendering object for the image or <code>null</code> if
* the image can't be rendered.
* @param node the node representing the image
* @param contentType the content type of the image
* @param stream the stream with the image
*
* @return a rendering object for the image.
*/ | IInlineRenderingObject getImage(INode node, String contentType, InputStream stream); |
lumag/JBookReader | src/org/jbookreader/book/bom/impl/AbstractNode.java | // Path: src/org/jbookreader/book/bom/IContainerNode.java
// public interface IContainerNode extends INode {
//
// /**
// * Returns a collection of child (contained in this one) nodes.
// * @return a collection of child nodes.
// */
// List<INode> getChildNodes();
//
// /**
// * This creates new child text node with specified text.
// * @param text the text of created node
// * @return new text node.
// */
// INode newTextNode(String text);
// /**
// * Creates new child container node.
// * @param tagName the tag name of new node
// * @return new container node.
// */
// IContainerNode newContainerNode(String tagName);
//
// /**
// * Returns the title of the section.
// * @return the title of the section.
// */
// IContainerNode getTitle();
// /**
// * Allocates the title of the section.
// * @param tagName the tag name of the title node
// * @return newly created container node.
// */
// IContainerNode newTitle(String tagName);
//
// /**
// * Allocates new Image node.
// * @param tagName the tag name of the image node
// * @param href the url of the image
// * @return newly created image node.
// */
// IImageNode newImage(String tagName, String href);
//
// }
//
// Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
| import org.jbookreader.book.bom.IContainerNode;
import org.jbookreader.book.bom.INode; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.book.bom.impl;
/**
* This class represents an abstract book node.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
abstract class AbstractNode implements INode {
/**
* The tag-name of the node.
*/
private String myTagName;
/**
* The ID of the node
*/
private String myID;
/**
* The class of the node
*/
private String myNodeClass;
/**
* The parent of this node.
*/ | // Path: src/org/jbookreader/book/bom/IContainerNode.java
// public interface IContainerNode extends INode {
//
// /**
// * Returns a collection of child (contained in this one) nodes.
// * @return a collection of child nodes.
// */
// List<INode> getChildNodes();
//
// /**
// * This creates new child text node with specified text.
// * @param text the text of created node
// * @return new text node.
// */
// INode newTextNode(String text);
// /**
// * Creates new child container node.
// * @param tagName the tag name of new node
// * @return new container node.
// */
// IContainerNode newContainerNode(String tagName);
//
// /**
// * Returns the title of the section.
// * @return the title of the section.
// */
// IContainerNode getTitle();
// /**
// * Allocates the title of the section.
// * @param tagName the tag name of the title node
// * @return newly created container node.
// */
// IContainerNode newTitle(String tagName);
//
// /**
// * Allocates new Image node.
// * @param tagName the tag name of the image node
// * @param href the url of the image
// * @return newly created image node.
// */
// IImageNode newImage(String tagName, String href);
//
// }
//
// Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
// Path: src/org/jbookreader/book/bom/impl/AbstractNode.java
import org.jbookreader.book.bom.IContainerNode;
import org.jbookreader.book.bom.INode;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.book.bom.impl;
/**
* This class represents an abstract book node.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
abstract class AbstractNode implements INode {
/**
* The tag-name of the node.
*/
private String myTagName;
/**
* The ID of the node
*/
private String myID;
/**
* The class of the node
*/
private String myNodeClass;
/**
* The parent of this node.
*/ | private IContainerNode myParentNode; |
lumag/JBookReader | src/org/jbookreader/book/bom/IBook.java | // Path: src/org/jbookreader/book/stylesheet/IStyleSheet.java
// public interface IStyleSheet {
// /**
// * Returns new style stack.
// * @return new style stack.
// */
// IStyleStack newStyleStateStack();
// }
| import java.util.Collection;
import java.util.Map;
import org.jbookreader.book.stylesheet.IStyleSheet; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.book.bom;
/**
* This interface represents the main part of the BookObjectModel — the book itself.
*
* The book consists of metadata, one or more bodies and maybe some binary data.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public interface IBook {
/**
* Creates new body node with give tag and node names.
* @param tagName the tag name
* @param name the name of new body or null if it's main node.
* @return new body node.
*/
IContainerNode newBody(String tagName, String name);
/**
* Returns the main (the first) body of the book.
* @return the main body of the book
*/
IContainerNode getMainBody();
/**
* Returns a collection of book bodies.
* @return a collection of book bodies.
*/
Collection<IContainerNode> getBodies();
/**
* Allocates new binary data.
* @param id the id of given data
* @param contentType the content type of the data.
* @return new binary blob object.
*/
IBinaryData newBinaryData(String id, String contentType);
/**
* Returns the binary blob associated with specified <code>id</code>.
* If no corresponding blob is found, returns <code>null</code>.
* @param id the id of the blob
* @return the binary blob associated with specified id.
*/
IBinaryData getBinaryData(String id);
/**
* Returns an id->binary data mapping.
* @return an id->binary data mapping.
*/
Map<String, ? extends IBinaryData> getBinaryMap();
/**
* Returns the system stylesheet for specified book.
* @return the system stylesheet for specified book.
*/ | // Path: src/org/jbookreader/book/stylesheet/IStyleSheet.java
// public interface IStyleSheet {
// /**
// * Returns new style stack.
// * @return new style stack.
// */
// IStyleStack newStyleStateStack();
// }
// Path: src/org/jbookreader/book/bom/IBook.java
import java.util.Collection;
import java.util.Map;
import org.jbookreader.book.stylesheet.IStyleSheet;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.book.bom;
/**
* This interface represents the main part of the BookObjectModel — the book itself.
*
* The book consists of metadata, one or more bodies and maybe some binary data.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public interface IBook {
/**
* Creates new body node with give tag and node names.
* @param tagName the tag name
* @param name the name of new body or null if it's main node.
* @return new body node.
*/
IContainerNode newBody(String tagName, String name);
/**
* Returns the main (the first) body of the book.
* @return the main body of the book
*/
IContainerNode getMainBody();
/**
* Returns a collection of book bodies.
* @return a collection of book bodies.
*/
Collection<IContainerNode> getBodies();
/**
* Allocates new binary data.
* @param id the id of given data
* @param contentType the content type of the data.
* @return new binary blob object.
*/
IBinaryData newBinaryData(String id, String contentType);
/**
* Returns the binary blob associated with specified <code>id</code>.
* If no corresponding blob is found, returns <code>null</code>.
* @param id the id of the blob
* @return the binary blob associated with specified id.
*/
IBinaryData getBinaryData(String id);
/**
* Returns an id->binary data mapping.
* @return an id->binary data mapping.
*/
Map<String, ? extends IBinaryData> getBinaryMap();
/**
* Returns the system stylesheet for specified book.
* @return the system stylesheet for specified book.
*/ | IStyleSheet getSystemStyleSheet(); |
lumag/JBookReader | src/org/jbookreader/formatengine/objects/Line.java | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IInlineRenderingObject.java
// public interface IInlineRenderingObject extends IRenderingObject {
// /**
// * Returns the depth (the distance between the baseline
// * and the bottom) of the object.
// * @return the depth of the object.
// */
// double getDepth();
//
// void renderInline();
//
// int getAdjustability();
//
// void adjustWidth(double width) throws UnsupportedOperationException;
// }
| import java.util.LinkedList;
import java.util.List;
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IInlineRenderingObject; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine.objects;
/**
* This class represents the main object of rendering engine — a single line.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public class Line extends AbstractInlineRenderingObject {
/**
* The list of contained rendered objects.
*/
private final List<IInlineRenderingObject> myRObjects = new LinkedList<IInlineRenderingObject>();
private int myAdjustability;
/**
* This constructs new line for specified painter.
* @param painter the painter on which this line will be rendered
* @param node the paragraph node to which the line corresponds
*/ | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IInlineRenderingObject.java
// public interface IInlineRenderingObject extends IRenderingObject {
// /**
// * Returns the depth (the distance between the baseline
// * and the bottom) of the object.
// * @return the depth of the object.
// */
// double getDepth();
//
// void renderInline();
//
// int getAdjustability();
//
// void adjustWidth(double width) throws UnsupportedOperationException;
// }
// Path: src/org/jbookreader/formatengine/objects/Line.java
import java.util.LinkedList;
import java.util.List;
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IInlineRenderingObject;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine.objects;
/**
* This class represents the main object of rendering engine — a single line.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public class Line extends AbstractInlineRenderingObject {
/**
* The list of contained rendered objects.
*/
private final List<IInlineRenderingObject> myRObjects = new LinkedList<IInlineRenderingObject>();
private int myAdjustability;
/**
* This constructs new line for specified painter.
* @param painter the painter on which this line will be rendered
* @param node the paragraph node to which the line corresponds
*/ | public Line(IBookPainter painter, INode node) { |
lumag/JBookReader | src/org/jbookreader/formatengine/objects/Line.java | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IInlineRenderingObject.java
// public interface IInlineRenderingObject extends IRenderingObject {
// /**
// * Returns the depth (the distance between the baseline
// * and the bottom) of the object.
// * @return the depth of the object.
// */
// double getDepth();
//
// void renderInline();
//
// int getAdjustability();
//
// void adjustWidth(double width) throws UnsupportedOperationException;
// }
| import java.util.LinkedList;
import java.util.List;
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IInlineRenderingObject; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine.objects;
/**
* This class represents the main object of rendering engine — a single line.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public class Line extends AbstractInlineRenderingObject {
/**
* The list of contained rendered objects.
*/
private final List<IInlineRenderingObject> myRObjects = new LinkedList<IInlineRenderingObject>();
private int myAdjustability;
/**
* This constructs new line for specified painter.
* @param painter the painter on which this line will be rendered
* @param node the paragraph node to which the line corresponds
*/ | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IInlineRenderingObject.java
// public interface IInlineRenderingObject extends IRenderingObject {
// /**
// * Returns the depth (the distance between the baseline
// * and the bottom) of the object.
// * @return the depth of the object.
// */
// double getDepth();
//
// void renderInline();
//
// int getAdjustability();
//
// void adjustWidth(double width) throws UnsupportedOperationException;
// }
// Path: src/org/jbookreader/formatengine/objects/Line.java
import java.util.LinkedList;
import java.util.List;
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IInlineRenderingObject;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine.objects;
/**
* This class represents the main object of rendering engine — a single line.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public class Line extends AbstractInlineRenderingObject {
/**
* The list of contained rendered objects.
*/
private final List<IInlineRenderingObject> myRObjects = new LinkedList<IInlineRenderingObject>();
private int myAdjustability;
/**
* This constructs new line for specified painter.
* @param painter the painter on which this line will be rendered
* @param node the paragraph node to which the line corresponds
*/ | public Line(IBookPainter painter, INode node) { |
lumag/JBookReader | src/org/jbookreader/ui/swing/painter/SwingFont.java | // Path: src/org/jbookreader/formatengine/IFont.java
// public interface IFont {
// /**
// * Returns the family name of the font.
// * @return the family name of the font.
// */
// String getFontFamily();
//
// /**
// * Returns the size of the font.
// * @return the size of the font.
// */
//
// double getFontSize();
// /**
// * Returns the width of space in this font.
// * @return the width of space in this font.
// */
// double getSpaceWidth();
// /**
// * Calculates dimensions to be used for rendering the specified string part
// * with given font.
// * @param s the string to calculate dimensions for
// * @param start The index of the first character in the string
// * @param end The index of the character following the last character in the subsequence
// * @return the dimensions of the string when rendered.
// */
// RenderingDimensions calculateStringDimensions(String s, int start, int end);
// /**
// * Renders the string with given font
// * @param s the string to render
// * @param start The index of the first character in the string
// * @param end The index of the character following the last character in the subsequence
// */
// void renderString(String s, int start, int end);
//
// }
//
// Path: src/org/jbookreader/formatengine/RenderingDimensions.java
// public class RenderingDimensions {
// /**
// * The height of the string over the baseline.
// */
// public final double ascent;
// /**
// * The height of the string below the baseline.
// */
// public final double depth;
// /**
// * The width of the string.
// */
// public final double width;
//
// /**
// * Constructs new dimensions object from specified numbers.
// * @param ascent the height of the string over the baseline.
// * @param depth the height of the string below the baseline.
// * @param width the width of the string.
// */
// public RenderingDimensions(double ascent, double depth, double width) {
// this.ascent = ascent;
// this.depth = depth;
// this.width = width;
// }
//
// }
| import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.font.LineMetrics;
import java.awt.geom.Rectangle2D;
import org.jbookreader.formatengine.IFont;
import org.jbookreader.formatengine.RenderingDimensions; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.ui.swing.painter;
/**
* This is internal class used for representing Swing fonts for the FE.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
class SwingFont implements IFont {
/**
*
*/
private final SwingBookPainter myPainter;
/**
* Font object from AWT
*/
final Font myFont;
/**
* The width of single space in this font.
*/
double mySpaceWidth = 0;
/**
* This constructs the class representing the font with given name and size
* @param name the name of the font
* @param size the size of the font
* @param painter the painter containing this font
*/
public SwingFont(SwingBookPainter painter, String name, int size) {
this.myPainter = painter;
this.myFont = new Font(name, Font.PLAIN, size);
}
public double getSpaceWidth() {
if (this.mySpaceWidth == 0) {
FontRenderContext frc = this.myPainter.getGraphics().getFontRenderContext();
GlyphVector gv = this.myFont.createGlyphVector(frc, new char[]{' '});
Rectangle2D r2d = gv.getLogicalBounds();
this.mySpaceWidth = r2d.getMaxX() - r2d.getMinX();
}
return this.mySpaceWidth;
}
/**
* Returns the corresponding Swing Font object.
* @return the corresponding Swing Font object.
*/
public Font getFont() {
return this.myFont;
}
| // Path: src/org/jbookreader/formatengine/IFont.java
// public interface IFont {
// /**
// * Returns the family name of the font.
// * @return the family name of the font.
// */
// String getFontFamily();
//
// /**
// * Returns the size of the font.
// * @return the size of the font.
// */
//
// double getFontSize();
// /**
// * Returns the width of space in this font.
// * @return the width of space in this font.
// */
// double getSpaceWidth();
// /**
// * Calculates dimensions to be used for rendering the specified string part
// * with given font.
// * @param s the string to calculate dimensions for
// * @param start The index of the first character in the string
// * @param end The index of the character following the last character in the subsequence
// * @return the dimensions of the string when rendered.
// */
// RenderingDimensions calculateStringDimensions(String s, int start, int end);
// /**
// * Renders the string with given font
// * @param s the string to render
// * @param start The index of the first character in the string
// * @param end The index of the character following the last character in the subsequence
// */
// void renderString(String s, int start, int end);
//
// }
//
// Path: src/org/jbookreader/formatengine/RenderingDimensions.java
// public class RenderingDimensions {
// /**
// * The height of the string over the baseline.
// */
// public final double ascent;
// /**
// * The height of the string below the baseline.
// */
// public final double depth;
// /**
// * The width of the string.
// */
// public final double width;
//
// /**
// * Constructs new dimensions object from specified numbers.
// * @param ascent the height of the string over the baseline.
// * @param depth the height of the string below the baseline.
// * @param width the width of the string.
// */
// public RenderingDimensions(double ascent, double depth, double width) {
// this.ascent = ascent;
// this.depth = depth;
// this.width = width;
// }
//
// }
// Path: src/org/jbookreader/ui/swing/painter/SwingFont.java
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.font.LineMetrics;
import java.awt.geom.Rectangle2D;
import org.jbookreader.formatengine.IFont;
import org.jbookreader.formatengine.RenderingDimensions;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.ui.swing.painter;
/**
* This is internal class used for representing Swing fonts for the FE.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
class SwingFont implements IFont {
/**
*
*/
private final SwingBookPainter myPainter;
/**
* Font object from AWT
*/
final Font myFont;
/**
* The width of single space in this font.
*/
double mySpaceWidth = 0;
/**
* This constructs the class representing the font with given name and size
* @param name the name of the font
* @param size the size of the font
* @param painter the painter containing this font
*/
public SwingFont(SwingBookPainter painter, String name, int size) {
this.myPainter = painter;
this.myFont = new Font(name, Font.PLAIN, size);
}
public double getSpaceWidth() {
if (this.mySpaceWidth == 0) {
FontRenderContext frc = this.myPainter.getGraphics().getFontRenderContext();
GlyphVector gv = this.myFont.createGlyphVector(frc, new char[]{' '});
Rectangle2D r2d = gv.getLogicalBounds();
this.mySpaceWidth = r2d.getMaxX() - r2d.getMinX();
}
return this.mySpaceWidth;
}
/**
* Returns the corresponding Swing Font object.
* @return the corresponding Swing Font object.
*/
public Font getFont() {
return this.myFont;
}
| public RenderingDimensions calculateStringDimensions(String s, int start, int end) { |
lumag/JBookReader | src/org/jbookreader/ui/swing/MainWindowMouseWheelListener.java | // Path: src/org/jbookreader/ui/swing/actions/PageDownAction.java
// @SuppressWarnings("serial")
// public class PageDownAction extends AbstractAction {
//
// private PageDownAction() {
// putValue(NAME, Messages.getString("PageDownAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageDownAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageDown();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/PageUpAction.java
// @SuppressWarnings("serial")
// public class PageUpAction extends AbstractAction {
//
// private PageUpAction() {
// putValue(NAME, Messages.getString("PageUpAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageUpAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageUp();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollDownAction.java
// @SuppressWarnings("serial")
// public class ScrollDownAction extends AbstractAction {
//
// private ScrollDownAction() {
// putValue(NAME, Messages.getString("ScrollDownAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollDown(12);
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollUpAction.java
// @SuppressWarnings("serial")
// public class ScrollUpAction extends AbstractAction {
//
// private ScrollUpAction() {
// putValue(NAME, Messages.getString("ScrollUpAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollUp(12);
// }
//
// }
| import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import org.jbookreader.ui.swing.actions.PageDownAction;
import org.jbookreader.ui.swing.actions.PageUpAction;
import org.jbookreader.ui.swing.actions.ScrollDownAction;
import org.jbookreader.ui.swing.actions.ScrollUpAction; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
*
*/
package org.jbookreader.ui.swing;
class MainWindowMouseWheelListener implements MouseWheelListener {
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
// System.out.println("block scroll " + e.getWheelRotation());
if (e.getWheelRotation() > 0) { | // Path: src/org/jbookreader/ui/swing/actions/PageDownAction.java
// @SuppressWarnings("serial")
// public class PageDownAction extends AbstractAction {
//
// private PageDownAction() {
// putValue(NAME, Messages.getString("PageDownAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageDownAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageDown();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/PageUpAction.java
// @SuppressWarnings("serial")
// public class PageUpAction extends AbstractAction {
//
// private PageUpAction() {
// putValue(NAME, Messages.getString("PageUpAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageUpAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageUp();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollDownAction.java
// @SuppressWarnings("serial")
// public class ScrollDownAction extends AbstractAction {
//
// private ScrollDownAction() {
// putValue(NAME, Messages.getString("ScrollDownAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollDown(12);
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollUpAction.java
// @SuppressWarnings("serial")
// public class ScrollUpAction extends AbstractAction {
//
// private ScrollUpAction() {
// putValue(NAME, Messages.getString("ScrollUpAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollUp(12);
// }
//
// }
// Path: src/org/jbookreader/ui/swing/MainWindowMouseWheelListener.java
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import org.jbookreader.ui.swing.actions.PageDownAction;
import org.jbookreader.ui.swing.actions.PageUpAction;
import org.jbookreader.ui.swing.actions.ScrollDownAction;
import org.jbookreader.ui.swing.actions.ScrollUpAction;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
*
*/
package org.jbookreader.ui.swing;
class MainWindowMouseWheelListener implements MouseWheelListener {
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
// System.out.println("block scroll " + e.getWheelRotation());
if (e.getWheelRotation() > 0) { | PageUpAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!; |
lumag/JBookReader | src/org/jbookreader/ui/swing/MainWindowMouseWheelListener.java | // Path: src/org/jbookreader/ui/swing/actions/PageDownAction.java
// @SuppressWarnings("serial")
// public class PageDownAction extends AbstractAction {
//
// private PageDownAction() {
// putValue(NAME, Messages.getString("PageDownAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageDownAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageDown();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/PageUpAction.java
// @SuppressWarnings("serial")
// public class PageUpAction extends AbstractAction {
//
// private PageUpAction() {
// putValue(NAME, Messages.getString("PageUpAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageUpAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageUp();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollDownAction.java
// @SuppressWarnings("serial")
// public class ScrollDownAction extends AbstractAction {
//
// private ScrollDownAction() {
// putValue(NAME, Messages.getString("ScrollDownAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollDown(12);
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollUpAction.java
// @SuppressWarnings("serial")
// public class ScrollUpAction extends AbstractAction {
//
// private ScrollUpAction() {
// putValue(NAME, Messages.getString("ScrollUpAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollUp(12);
// }
//
// }
| import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import org.jbookreader.ui.swing.actions.PageDownAction;
import org.jbookreader.ui.swing.actions.PageUpAction;
import org.jbookreader.ui.swing.actions.ScrollDownAction;
import org.jbookreader.ui.swing.actions.ScrollUpAction; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
*
*/
package org.jbookreader.ui.swing;
class MainWindowMouseWheelListener implements MouseWheelListener {
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
// System.out.println("block scroll " + e.getWheelRotation());
if (e.getWheelRotation() > 0) {
PageUpAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!;
} else { | // Path: src/org/jbookreader/ui/swing/actions/PageDownAction.java
// @SuppressWarnings("serial")
// public class PageDownAction extends AbstractAction {
//
// private PageDownAction() {
// putValue(NAME, Messages.getString("PageDownAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageDownAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageDown();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/PageUpAction.java
// @SuppressWarnings("serial")
// public class PageUpAction extends AbstractAction {
//
// private PageUpAction() {
// putValue(NAME, Messages.getString("PageUpAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageUpAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageUp();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollDownAction.java
// @SuppressWarnings("serial")
// public class ScrollDownAction extends AbstractAction {
//
// private ScrollDownAction() {
// putValue(NAME, Messages.getString("ScrollDownAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollDown(12);
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollUpAction.java
// @SuppressWarnings("serial")
// public class ScrollUpAction extends AbstractAction {
//
// private ScrollUpAction() {
// putValue(NAME, Messages.getString("ScrollUpAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollUp(12);
// }
//
// }
// Path: src/org/jbookreader/ui/swing/MainWindowMouseWheelListener.java
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import org.jbookreader.ui.swing.actions.PageDownAction;
import org.jbookreader.ui.swing.actions.PageUpAction;
import org.jbookreader.ui.swing.actions.ScrollDownAction;
import org.jbookreader.ui.swing.actions.ScrollUpAction;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
*
*/
package org.jbookreader.ui.swing;
class MainWindowMouseWheelListener implements MouseWheelListener {
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
// System.out.println("block scroll " + e.getWheelRotation());
if (e.getWheelRotation() > 0) {
PageUpAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!;
} else { | PageDownAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!; |
lumag/JBookReader | src/org/jbookreader/ui/swing/MainWindowMouseWheelListener.java | // Path: src/org/jbookreader/ui/swing/actions/PageDownAction.java
// @SuppressWarnings("serial")
// public class PageDownAction extends AbstractAction {
//
// private PageDownAction() {
// putValue(NAME, Messages.getString("PageDownAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageDownAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageDown();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/PageUpAction.java
// @SuppressWarnings("serial")
// public class PageUpAction extends AbstractAction {
//
// private PageUpAction() {
// putValue(NAME, Messages.getString("PageUpAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageUpAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageUp();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollDownAction.java
// @SuppressWarnings("serial")
// public class ScrollDownAction extends AbstractAction {
//
// private ScrollDownAction() {
// putValue(NAME, Messages.getString("ScrollDownAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollDown(12);
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollUpAction.java
// @SuppressWarnings("serial")
// public class ScrollUpAction extends AbstractAction {
//
// private ScrollUpAction() {
// putValue(NAME, Messages.getString("ScrollUpAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollUp(12);
// }
//
// }
| import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import org.jbookreader.ui.swing.actions.PageDownAction;
import org.jbookreader.ui.swing.actions.PageUpAction;
import org.jbookreader.ui.swing.actions.ScrollDownAction;
import org.jbookreader.ui.swing.actions.ScrollUpAction; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
*
*/
package org.jbookreader.ui.swing;
class MainWindowMouseWheelListener implements MouseWheelListener {
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
// System.out.println("block scroll " + e.getWheelRotation());
if (e.getWheelRotation() > 0) {
PageUpAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!;
} else {
PageDownAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!;
}
} else {
int units = e.getUnitsToScroll();
// System.out.println("unit scroll " + units);
if (units > 0) {
while (units > 0) { | // Path: src/org/jbookreader/ui/swing/actions/PageDownAction.java
// @SuppressWarnings("serial")
// public class PageDownAction extends AbstractAction {
//
// private PageDownAction() {
// putValue(NAME, Messages.getString("PageDownAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageDownAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageDown();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/PageUpAction.java
// @SuppressWarnings("serial")
// public class PageUpAction extends AbstractAction {
//
// private PageUpAction() {
// putValue(NAME, Messages.getString("PageUpAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageUpAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageUp();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollDownAction.java
// @SuppressWarnings("serial")
// public class ScrollDownAction extends AbstractAction {
//
// private ScrollDownAction() {
// putValue(NAME, Messages.getString("ScrollDownAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollDown(12);
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollUpAction.java
// @SuppressWarnings("serial")
// public class ScrollUpAction extends AbstractAction {
//
// private ScrollUpAction() {
// putValue(NAME, Messages.getString("ScrollUpAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollUp(12);
// }
//
// }
// Path: src/org/jbookreader/ui/swing/MainWindowMouseWheelListener.java
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import org.jbookreader.ui.swing.actions.PageDownAction;
import org.jbookreader.ui.swing.actions.PageUpAction;
import org.jbookreader.ui.swing.actions.ScrollDownAction;
import org.jbookreader.ui.swing.actions.ScrollUpAction;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
*
*/
package org.jbookreader.ui.swing;
class MainWindowMouseWheelListener implements MouseWheelListener {
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
// System.out.println("block scroll " + e.getWheelRotation());
if (e.getWheelRotation() > 0) {
PageUpAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!;
} else {
PageDownAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!;
}
} else {
int units = e.getUnitsToScroll();
// System.out.println("unit scroll " + units);
if (units > 0) {
while (units > 0) { | ScrollDownAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!; |
lumag/JBookReader | src/org/jbookreader/ui/swing/MainWindowMouseWheelListener.java | // Path: src/org/jbookreader/ui/swing/actions/PageDownAction.java
// @SuppressWarnings("serial")
// public class PageDownAction extends AbstractAction {
//
// private PageDownAction() {
// putValue(NAME, Messages.getString("PageDownAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageDownAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageDown();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/PageUpAction.java
// @SuppressWarnings("serial")
// public class PageUpAction extends AbstractAction {
//
// private PageUpAction() {
// putValue(NAME, Messages.getString("PageUpAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageUpAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageUp();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollDownAction.java
// @SuppressWarnings("serial")
// public class ScrollDownAction extends AbstractAction {
//
// private ScrollDownAction() {
// putValue(NAME, Messages.getString("ScrollDownAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollDown(12);
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollUpAction.java
// @SuppressWarnings("serial")
// public class ScrollUpAction extends AbstractAction {
//
// private ScrollUpAction() {
// putValue(NAME, Messages.getString("ScrollUpAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollUp(12);
// }
//
// }
| import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import org.jbookreader.ui.swing.actions.PageDownAction;
import org.jbookreader.ui.swing.actions.PageUpAction;
import org.jbookreader.ui.swing.actions.ScrollDownAction;
import org.jbookreader.ui.swing.actions.ScrollUpAction; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
*
*/
package org.jbookreader.ui.swing;
class MainWindowMouseWheelListener implements MouseWheelListener {
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
// System.out.println("block scroll " + e.getWheelRotation());
if (e.getWheelRotation() > 0) {
PageUpAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!;
} else {
PageDownAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!;
}
} else {
int units = e.getUnitsToScroll();
// System.out.println("unit scroll " + units);
if (units > 0) {
while (units > 0) {
ScrollDownAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!;
units --;
}
} else {
while (units < 0) { | // Path: src/org/jbookreader/ui/swing/actions/PageDownAction.java
// @SuppressWarnings("serial")
// public class PageDownAction extends AbstractAction {
//
// private PageDownAction() {
// putValue(NAME, Messages.getString("PageDownAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageDownAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageDown();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/PageUpAction.java
// @SuppressWarnings("serial")
// public class PageUpAction extends AbstractAction {
//
// private PageUpAction() {
// putValue(NAME, Messages.getString("PageUpAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Messages.getString("PageUpAction.Mnemonic")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("PageUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new PageUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// MainWindow.getMainWindow().getBookComponent().scrollPageUp();
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollDownAction.java
// @SuppressWarnings("serial")
// public class ScrollDownAction extends AbstractAction {
//
// private ScrollDownAction() {
// putValue(NAME, Messages.getString("ScrollDownAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollDownAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollDownAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollDown(12);
// }
//
// }
//
// Path: src/org/jbookreader/ui/swing/actions/ScrollUpAction.java
// @SuppressWarnings("serial")
// public class ScrollUpAction extends AbstractAction {
//
// private ScrollUpAction() {
// putValue(NAME, Messages.getString("ScrollUpAction.Name")); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("ScrollUpAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new ScrollUpAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// // XXX: change to system property
// MainWindow.getMainWindow().getBookComponent().scrollUp(12);
// }
//
// }
// Path: src/org/jbookreader/ui/swing/MainWindowMouseWheelListener.java
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import org.jbookreader.ui.swing.actions.PageDownAction;
import org.jbookreader.ui.swing.actions.PageUpAction;
import org.jbookreader.ui.swing.actions.ScrollDownAction;
import org.jbookreader.ui.swing.actions.ScrollUpAction;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
*
*/
package org.jbookreader.ui.swing;
class MainWindowMouseWheelListener implements MouseWheelListener {
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
// System.out.println("block scroll " + e.getWheelRotation());
if (e.getWheelRotation() > 0) {
PageUpAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!;
} else {
PageDownAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!;
}
} else {
int units = e.getUnitsToScroll();
// System.out.println("unit scroll " + units);
if (units > 0) {
while (units > 0) {
ScrollDownAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!;
units --;
}
} else {
while (units < 0) { | ScrollUpAction.getAction().actionPerformed(null); // FIXME: provide cleaner way to do this!; |
lumag/JBookReader | src/org/jbookreader/book/bom/impl/ContainerNode.java | // Path: src/org/jbookreader/book/bom/IContainerNode.java
// public interface IContainerNode extends INode {
//
// /**
// * Returns a collection of child (contained in this one) nodes.
// * @return a collection of child nodes.
// */
// List<INode> getChildNodes();
//
// /**
// * This creates new child text node with specified text.
// * @param text the text of created node
// * @return new text node.
// */
// INode newTextNode(String text);
// /**
// * Creates new child container node.
// * @param tagName the tag name of new node
// * @return new container node.
// */
// IContainerNode newContainerNode(String tagName);
//
// /**
// * Returns the title of the section.
// * @return the title of the section.
// */
// IContainerNode getTitle();
// /**
// * Allocates the title of the section.
// * @param tagName the tag name of the title node
// * @return newly created container node.
// */
// IContainerNode newTitle(String tagName);
//
// /**
// * Allocates new Image node.
// * @param tagName the tag name of the image node
// * @param href the url of the image
// * @return newly created image node.
// */
// IImageNode newImage(String tagName, String href);
//
// }
//
// Path: src/org/jbookreader/book/bom/IImageNode.java
// public interface IImageNode extends INode {
//
// /**
// * Returns the location of the image. Probably you should only use internal locations ('#id') for now.
// * @return the location of the image.
// */
// String getHyperRef();
//
// /**
// * Sets the alternative text for the image.
// * @param text new alternative text
// */
// void setText(String text);
//
// /**
// * Returns the title of the image or null if there is no title.
// * @return the title of the image
// */
// String getTitle();
//
// /**
// * Sets the title of the image.
// * @param title new title
// */
// void setTitle(String title);
//
// }
//
// Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
| import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.jbookreader.book.bom.IContainerNode;
import org.jbookreader.book.bom.IImageNode;
import org.jbookreader.book.bom.INode; | _TextNode node = new _TextNode();
node.setText(text);
this.addChildNode(node);
return node;
}
public IContainerNode newContainerNode(String tagName) {
ContainerNode node = new ContainerNode();
node.setTagName(tagName);
this.addChildNode(node);
return node;
}
@Override
public void setTagName(String tagName) {
super.setTagName(tagName);
}
public IContainerNode getTitle() {
return this.myTitle;
}
public IContainerNode newTitle(String tagName) {
ContainerNode node = new ContainerNode();
node.setTagName(tagName);
this.addChildNode(node);
this.myTitle = node;
return node;
}
| // Path: src/org/jbookreader/book/bom/IContainerNode.java
// public interface IContainerNode extends INode {
//
// /**
// * Returns a collection of child (contained in this one) nodes.
// * @return a collection of child nodes.
// */
// List<INode> getChildNodes();
//
// /**
// * This creates new child text node with specified text.
// * @param text the text of created node
// * @return new text node.
// */
// INode newTextNode(String text);
// /**
// * Creates new child container node.
// * @param tagName the tag name of new node
// * @return new container node.
// */
// IContainerNode newContainerNode(String tagName);
//
// /**
// * Returns the title of the section.
// * @return the title of the section.
// */
// IContainerNode getTitle();
// /**
// * Allocates the title of the section.
// * @param tagName the tag name of the title node
// * @return newly created container node.
// */
// IContainerNode newTitle(String tagName);
//
// /**
// * Allocates new Image node.
// * @param tagName the tag name of the image node
// * @param href the url of the image
// * @return newly created image node.
// */
// IImageNode newImage(String tagName, String href);
//
// }
//
// Path: src/org/jbookreader/book/bom/IImageNode.java
// public interface IImageNode extends INode {
//
// /**
// * Returns the location of the image. Probably you should only use internal locations ('#id') for now.
// * @return the location of the image.
// */
// String getHyperRef();
//
// /**
// * Sets the alternative text for the image.
// * @param text new alternative text
// */
// void setText(String text);
//
// /**
// * Returns the title of the image or null if there is no title.
// * @return the title of the image
// */
// String getTitle();
//
// /**
// * Sets the title of the image.
// * @param title new title
// */
// void setTitle(String title);
//
// }
//
// Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
// Path: src/org/jbookreader/book/bom/impl/ContainerNode.java
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.jbookreader.book.bom.IContainerNode;
import org.jbookreader.book.bom.IImageNode;
import org.jbookreader.book.bom.INode;
_TextNode node = new _TextNode();
node.setText(text);
this.addChildNode(node);
return node;
}
public IContainerNode newContainerNode(String tagName) {
ContainerNode node = new ContainerNode();
node.setTagName(tagName);
this.addChildNode(node);
return node;
}
@Override
public void setTagName(String tagName) {
super.setTagName(tagName);
}
public IContainerNode getTitle() {
return this.myTitle;
}
public IContainerNode newTitle(String tagName) {
ContainerNode node = new ContainerNode();
node.setTagName(tagName);
this.addChildNode(node);
this.myTitle = node;
return node;
}
| public IImageNode newImage(String tagName, String href) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.