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 |
|---|---|---|---|---|---|---|
ePages-de/restdocs-wiremock | wiremock/src/test/java/org/springframework/restdocs/test/ExpectedSnippet.java | // Path: wiremock/src/test/java/org/springframework/restdocs/test/SnippetMatchers.java
// public static final class SnippetMatcher extends BaseMatcher<File> {
//
// private final TemplateFormat templateFormat;
//
// private Matcher<String> expectedContents;
//
// private SnippetMatcher(TemplateFormat templateFormat) {
// this.templateFormat = templateFormat;
// }
//
// @Override
// public boolean matches(Object item) {
// if (snippetFileExists(item)) {
// if (this.expectedContents != null) {
// try {
// return this.expectedContents.matches(read((File) item));
// }
// catch (IOException e) {
// return false;
// }
// }
// return true;
// }
// return false;
// }
//
// private boolean snippetFileExists(Object item) {
// return item instanceof File && ((File) item).isFile();
// }
//
// private String read(File snippetFile) throws IOException {
// return FileCopyUtils.copyToString(
// new InputStreamReader(new FileInputStream(snippetFile), "UTF-8"));
// }
//
// @Override
// public void describeMismatch(Object item, Description description) {
// if (!snippetFileExists(item)) {
// description.appendText("The file " + item + " does not exist");
// }
// else if (this.expectedContents != null) {
// try {
// this.expectedContents.describeMismatch(read((File) item),
// description);
// }
// catch (IOException e) {
// description
// .appendText("The contents of " + item + " cound not be read");
// }
// }
// }
//
// @Override
// public void describeTo(Description description) {
// if (this.expectedContents != null) {
// this.expectedContents.describeTo(description);
// }
// else {
// description
// .appendText(this.templateFormat.getFileExtension() + " snippet");
// }
// }
//
// public SnippetMatcher withContents(Matcher<String> matcher) {
// this.expectedContents = matcher;
// return this;
// }
//
// }
| import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import java.io.File;
import java.io.IOException;
import org.hamcrest.Matcher;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.springframework.restdocs.snippet.TemplatedSnippet;
import org.springframework.restdocs.templates.TemplateFormat;
import org.springframework.restdocs.test.SnippetMatchers.SnippetMatcher; | /*
* Copyright 2014-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.restdocs.test;
/**
* The {@code ExpectedSnippet} rule is used to verify that a {@link TemplatedSnippet} has
* generated the expected snippet.
*
* @author Andy Wilkinson
* @author Andreas Evers
*/
public class ExpectedSnippet implements TestRule {
private final TemplateFormat templateFormat;
| // Path: wiremock/src/test/java/org/springframework/restdocs/test/SnippetMatchers.java
// public static final class SnippetMatcher extends BaseMatcher<File> {
//
// private final TemplateFormat templateFormat;
//
// private Matcher<String> expectedContents;
//
// private SnippetMatcher(TemplateFormat templateFormat) {
// this.templateFormat = templateFormat;
// }
//
// @Override
// public boolean matches(Object item) {
// if (snippetFileExists(item)) {
// if (this.expectedContents != null) {
// try {
// return this.expectedContents.matches(read((File) item));
// }
// catch (IOException e) {
// return false;
// }
// }
// return true;
// }
// return false;
// }
//
// private boolean snippetFileExists(Object item) {
// return item instanceof File && ((File) item).isFile();
// }
//
// private String read(File snippetFile) throws IOException {
// return FileCopyUtils.copyToString(
// new InputStreamReader(new FileInputStream(snippetFile), "UTF-8"));
// }
//
// @Override
// public void describeMismatch(Object item, Description description) {
// if (!snippetFileExists(item)) {
// description.appendText("The file " + item + " does not exist");
// }
// else if (this.expectedContents != null) {
// try {
// this.expectedContents.describeMismatch(read((File) item),
// description);
// }
// catch (IOException e) {
// description
// .appendText("The contents of " + item + " cound not be read");
// }
// }
// }
//
// @Override
// public void describeTo(Description description) {
// if (this.expectedContents != null) {
// this.expectedContents.describeTo(description);
// }
// else {
// description
// .appendText(this.templateFormat.getFileExtension() + " snippet");
// }
// }
//
// public SnippetMatcher withContents(Matcher<String> matcher) {
// this.expectedContents = matcher;
// return this;
// }
//
// }
// Path: wiremock/src/test/java/org/springframework/restdocs/test/ExpectedSnippet.java
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import java.io.File;
import java.io.IOException;
import org.hamcrest.Matcher;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.springframework.restdocs.snippet.TemplatedSnippet;
import org.springframework.restdocs.templates.TemplateFormat;
import org.springframework.restdocs.test.SnippetMatchers.SnippetMatcher;
/*
* Copyright 2014-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.restdocs.test;
/**
* The {@code ExpectedSnippet} rule is used to verify that a {@link TemplatedSnippet} has
* generated the expected snippet.
*
* @author Andy Wilkinson
* @author Andreas Evers
*/
public class ExpectedSnippet implements TestRule {
private final TemplateFormat templateFormat;
| private final SnippetMatcher snippet; |
ePages-de/restdocs-wiremock | server/src/test/java/com/example/notes/ApiDocumentation.java | // Path: wiremock/src/main/java/com/epages/restdocs/WireMockDocumentation.java
// public static ResponseFieldTemplateDescriptor idFieldReplacedWithPathParameterValue() {
// return new ResponseFieldTemplateDescriptor("id").replacedWithWireMockTemplateExpression("request.requestLine.pathSegments.[1]");
// }
//
// Path: wiremock/src/main/java/com/epages/restdocs/WireMockDocumentation.java
// public static Snippet wiremockJson(ResponseFieldTemplateDescriptor... responseFieldTemplateDescriptors) {
// return new WireMockJsonSnippet(responseFieldTemplateDescriptors);
// }
| import static com.epages.restdocs.WireMockDocumentation.idFieldReplacedWithPathParameterValue;
import static com.epages.restdocs.WireMockDocumentation.wiremockJson;
import static java.util.Collections.singletonList;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName;
import static org.springframework.restdocs.headers.HeaderDocumentation.responseHeaders;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.patch;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.snippet.Attributes.key;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.RequestDispatcher;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.hateoas.MediaTypes;
import org.springframework.restdocs.JUnitRestDocumentation;
import org.springframework.restdocs.constraints.ConstraintDescriptions;
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.JsonFieldType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.util.StringUtils;
import org.springframework.web.context.WebApplicationContext;
import com.fasterxml.jackson.databind.ObjectMapper; | /*
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.notes;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = RestNotesSpringHateoas.class)
@WebAppConfiguration
public class ApiDocumentation {
@Rule
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("build/generated-snippets");
private RestDocumentationResultHandler documentationHandler;
@Autowired
private NoteRepository noteRepository;
@Autowired
private TagRepository tagRepository;
@Autowired
private ObjectMapper objectMapper;
@Autowired
private WebApplicationContext context;
private MockMvc mockMvc;
@Before
public void setUp() {
this.documentationHandler = document("{method-name}",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()), | // Path: wiremock/src/main/java/com/epages/restdocs/WireMockDocumentation.java
// public static ResponseFieldTemplateDescriptor idFieldReplacedWithPathParameterValue() {
// return new ResponseFieldTemplateDescriptor("id").replacedWithWireMockTemplateExpression("request.requestLine.pathSegments.[1]");
// }
//
// Path: wiremock/src/main/java/com/epages/restdocs/WireMockDocumentation.java
// public static Snippet wiremockJson(ResponseFieldTemplateDescriptor... responseFieldTemplateDescriptors) {
// return new WireMockJsonSnippet(responseFieldTemplateDescriptors);
// }
// Path: server/src/test/java/com/example/notes/ApiDocumentation.java
import static com.epages.restdocs.WireMockDocumentation.idFieldReplacedWithPathParameterValue;
import static com.epages.restdocs.WireMockDocumentation.wiremockJson;
import static java.util.Collections.singletonList;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName;
import static org.springframework.restdocs.headers.HeaderDocumentation.responseHeaders;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.patch;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.snippet.Attributes.key;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.RequestDispatcher;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.hateoas.MediaTypes;
import org.springframework.restdocs.JUnitRestDocumentation;
import org.springframework.restdocs.constraints.ConstraintDescriptions;
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.JsonFieldType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.util.StringUtils;
import org.springframework.web.context.WebApplicationContext;
import com.fasterxml.jackson.databind.ObjectMapper;
/*
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.notes;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = RestNotesSpringHateoas.class)
@WebAppConfiguration
public class ApiDocumentation {
@Rule
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("build/generated-snippets");
private RestDocumentationResultHandler documentationHandler;
@Autowired
private NoteRepository noteRepository;
@Autowired
private TagRepository tagRepository;
@Autowired
private ObjectMapper objectMapper;
@Autowired
private WebApplicationContext context;
private MockMvc mockMvc;
@Before
public void setUp() {
this.documentationHandler = document("{method-name}",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()), | wiremockJson() |
ePages-de/restdocs-wiremock | server/src/test/java/com/example/notes/ApiDocumentation.java | // Path: wiremock/src/main/java/com/epages/restdocs/WireMockDocumentation.java
// public static ResponseFieldTemplateDescriptor idFieldReplacedWithPathParameterValue() {
// return new ResponseFieldTemplateDescriptor("id").replacedWithWireMockTemplateExpression("request.requestLine.pathSegments.[1]");
// }
//
// Path: wiremock/src/main/java/com/epages/restdocs/WireMockDocumentation.java
// public static Snippet wiremockJson(ResponseFieldTemplateDescriptor... responseFieldTemplateDescriptors) {
// return new WireMockJsonSnippet(responseFieldTemplateDescriptors);
// }
| import static com.epages.restdocs.WireMockDocumentation.idFieldReplacedWithPathParameterValue;
import static com.epages.restdocs.WireMockDocumentation.wiremockJson;
import static java.util.Collections.singletonList;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName;
import static org.springframework.restdocs.headers.HeaderDocumentation.responseHeaders;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.patch;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.snippet.Attributes.key;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.RequestDispatcher;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.hateoas.MediaTypes;
import org.springframework.restdocs.JUnitRestDocumentation;
import org.springframework.restdocs.constraints.ConstraintDescriptions;
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.JsonFieldType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.util.StringUtils;
import org.springframework.web.context.WebApplicationContext;
import com.fasterxml.jackson.databind.ObjectMapper; | tag.put("name", "REST");
String tagLocation = this.mockMvc
.perform(post("/tags")
.contentType(MediaTypes.HAL_JSON)
.content(this.objectMapper.writeValueAsString(tag)))
.andExpect(status().isCreated())
.andReturn().getResponse().getHeader("Location");
Map<String, Object> note = new HashMap<String, Object>();
note.put("title", "REST maturity model");
note.put("body", "http://martinfowler.com/articles/richardsonMaturityModel.html");
note.put("tags", singletonList(tagLocation));
String noteLocation = this.mockMvc
.perform(post("/notes")
.contentType(MediaTypes.HAL_JSON)
.content(this.objectMapper.writeValueAsString(note)))
.andExpect(status().isCreated())
.andReturn().getResponse().getHeader("Location");
this.mockMvc
.perform(get("/notes/{id}", noteLocation.substring(noteLocation.lastIndexOf("/") + 1)))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("title", is(note.get("title"))))
.andExpect(jsonPath("body", is(note.get("body"))))
.andExpect(jsonPath("_links.self.href", is(noteLocation)))
.andExpect(jsonPath("_links.note-tags", is(notNullValue())))
.andDo(this.documentationHandler.document( | // Path: wiremock/src/main/java/com/epages/restdocs/WireMockDocumentation.java
// public static ResponseFieldTemplateDescriptor idFieldReplacedWithPathParameterValue() {
// return new ResponseFieldTemplateDescriptor("id").replacedWithWireMockTemplateExpression("request.requestLine.pathSegments.[1]");
// }
//
// Path: wiremock/src/main/java/com/epages/restdocs/WireMockDocumentation.java
// public static Snippet wiremockJson(ResponseFieldTemplateDescriptor... responseFieldTemplateDescriptors) {
// return new WireMockJsonSnippet(responseFieldTemplateDescriptors);
// }
// Path: server/src/test/java/com/example/notes/ApiDocumentation.java
import static com.epages.restdocs.WireMockDocumentation.idFieldReplacedWithPathParameterValue;
import static com.epages.restdocs.WireMockDocumentation.wiremockJson;
import static java.util.Collections.singletonList;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName;
import static org.springframework.restdocs.headers.HeaderDocumentation.responseHeaders;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.patch;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.snippet.Attributes.key;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.RequestDispatcher;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.hateoas.MediaTypes;
import org.springframework.restdocs.JUnitRestDocumentation;
import org.springframework.restdocs.constraints.ConstraintDescriptions;
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.JsonFieldType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.util.StringUtils;
import org.springframework.web.context.WebApplicationContext;
import com.fasterxml.jackson.databind.ObjectMapper;
tag.put("name", "REST");
String tagLocation = this.mockMvc
.perform(post("/tags")
.contentType(MediaTypes.HAL_JSON)
.content(this.objectMapper.writeValueAsString(tag)))
.andExpect(status().isCreated())
.andReturn().getResponse().getHeader("Location");
Map<String, Object> note = new HashMap<String, Object>();
note.put("title", "REST maturity model");
note.put("body", "http://martinfowler.com/articles/richardsonMaturityModel.html");
note.put("tags", singletonList(tagLocation));
String noteLocation = this.mockMvc
.perform(post("/notes")
.contentType(MediaTypes.HAL_JSON)
.content(this.objectMapper.writeValueAsString(note)))
.andExpect(status().isCreated())
.andReturn().getResponse().getHeader("Location");
this.mockMvc
.perform(get("/notes/{id}", noteLocation.substring(noteLocation.lastIndexOf("/") + 1)))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("title", is(note.get("title"))))
.andExpect(jsonPath("body", is(note.get("body"))))
.andExpect(jsonPath("_links.self.href", is(noteLocation)))
.andExpect(jsonPath("_links.note-tags", is(notNullValue())))
.andDo(this.documentationHandler.document( | wiremockJson(idFieldReplacedWithPathParameterValue()), |
ePages-de/restdocs-wiremock | server/src/main/java/com/example/notes/TagsController.java | // Path: server/src/main/java/com/example/notes/NoteResourceAssembler.java
// static class NoteResource extends Resource<Note> {
//
// public NoteResource(Note content) {
// super(content);
// }
// }
//
// Path: server/src/main/java/com/example/notes/TagResourceAssembler.java
// static class TagResource extends Resource<Tag> {
//
// public TagResource(Tag content) {
// super(content);
// }
// }
| import com.example.notes.NoteResourceAssembler.NoteResource;
import com.example.notes.TagResourceAssembler.TagResource;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController; | /*
* Copyright 2014-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.notes;
@RestController
@RequestMapping("tags")
public class TagsController {
private final TagRepository repository;
private final NoteResourceAssembler noteResourceAssembler;
private final TagResourceAssembler tagResourceAssembler;
@Autowired
public TagsController(TagRepository repository,
NoteResourceAssembler noteResourceAssembler,
TagResourceAssembler tagResourceAssembler) {
this.repository = repository;
this.noteResourceAssembler = noteResourceAssembler;
this.tagResourceAssembler = tagResourceAssembler;
}
@RequestMapping(method = RequestMethod.GET) | // Path: server/src/main/java/com/example/notes/NoteResourceAssembler.java
// static class NoteResource extends Resource<Note> {
//
// public NoteResource(Note content) {
// super(content);
// }
// }
//
// Path: server/src/main/java/com/example/notes/TagResourceAssembler.java
// static class TagResource extends Resource<Tag> {
//
// public TagResource(Tag content) {
// super(content);
// }
// }
// Path: server/src/main/java/com/example/notes/TagsController.java
import com.example.notes.NoteResourceAssembler.NoteResource;
import com.example.notes.TagResourceAssembler.TagResource;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
/*
* Copyright 2014-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.notes;
@RestController
@RequestMapping("tags")
public class TagsController {
private final TagRepository repository;
private final NoteResourceAssembler noteResourceAssembler;
private final TagResourceAssembler tagResourceAssembler;
@Autowired
public TagsController(TagRepository repository,
NoteResourceAssembler noteResourceAssembler,
TagResourceAssembler tagResourceAssembler) {
this.repository = repository;
this.noteResourceAssembler = noteResourceAssembler;
this.tagResourceAssembler = tagResourceAssembler;
}
@RequestMapping(method = RequestMethod.GET) | NestedContentResource<TagResource> all() { |
ePages-de/restdocs-wiremock | server/src/main/java/com/example/notes/TagsController.java | // Path: server/src/main/java/com/example/notes/NoteResourceAssembler.java
// static class NoteResource extends Resource<Note> {
//
// public NoteResource(Note content) {
// super(content);
// }
// }
//
// Path: server/src/main/java/com/example/notes/TagResourceAssembler.java
// static class TagResource extends Resource<Tag> {
//
// public TagResource(Tag content) {
// super(content);
// }
// }
| import com.example.notes.NoteResourceAssembler.NoteResource;
import com.example.notes.TagResourceAssembler.TagResource;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController; | }
@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(method = RequestMethod.POST)
HttpHeaders create(@RequestBody TagInput tagInput) {
Tag tag = new Tag();
tag.setName(tagInput.getName());
this.repository.save(tag);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(linkTo(TagsController.class).slash(tag.getId()).toUri());
return httpHeaders;
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
void delete(@PathVariable("id") long id) {
this.repository.delete(id);
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
Resource<Tag> tag(@PathVariable("id") long id) {
Tag tag = findTagById(id);
return this.tagResourceAssembler.toResource(tag);
}
@RequestMapping(value = "/{id}/notes", method = RequestMethod.GET)
ResourceSupport tagNotes(@PathVariable("id") long id) {
Tag tag = findTagById(id); | // Path: server/src/main/java/com/example/notes/NoteResourceAssembler.java
// static class NoteResource extends Resource<Note> {
//
// public NoteResource(Note content) {
// super(content);
// }
// }
//
// Path: server/src/main/java/com/example/notes/TagResourceAssembler.java
// static class TagResource extends Resource<Tag> {
//
// public TagResource(Tag content) {
// super(content);
// }
// }
// Path: server/src/main/java/com/example/notes/TagsController.java
import com.example.notes.NoteResourceAssembler.NoteResource;
import com.example.notes.TagResourceAssembler.TagResource;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
}
@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(method = RequestMethod.POST)
HttpHeaders create(@RequestBody TagInput tagInput) {
Tag tag = new Tag();
tag.setName(tagInput.getName());
this.repository.save(tag);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(linkTo(TagsController.class).slash(tag.getId()).toUri());
return httpHeaders;
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
void delete(@PathVariable("id") long id) {
this.repository.delete(id);
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
Resource<Tag> tag(@PathVariable("id") long id) {
Tag tag = findTagById(id);
return this.tagResourceAssembler.toResource(tag);
}
@RequestMapping(value = "/{id}/notes", method = RequestMethod.GET)
ResourceSupport tagNotes(@PathVariable("id") long id) {
Tag tag = findTagById(id); | return new NestedContentResource<NoteResource>( |
ePages-de/restdocs-wiremock | wiremock/src/test/java/com/epages/restdocs/ResponseTemplateProcessorTest.java | // Path: wiremock/src/main/java/com/epages/restdocs/WireMockDocumentation.java
// public static ResponseFieldTemplateDescriptor templatedResponseField(String path ) {
// return new ResponseFieldTemplateDescriptor(path);
// }
| import static com.epages.restdocs.WireMockDocumentation.templatedResponseField;
import static java.util.Collections.singletonList;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
import java.util.Arrays;
import java.util.Collections;
import org.junit.Test;
import org.springframework.web.util.UriTemplate; | package com.epages.restdocs;
public class ResponseTemplateProcessorTest {
private String jsonBody = "{\n" +
" \"id\": \"the-id\",\n" +
" \"name\": \"some\"\n" +
"}";
@Test
public void should_replace_with_uri_variable_expression() { | // Path: wiremock/src/main/java/com/epages/restdocs/WireMockDocumentation.java
// public static ResponseFieldTemplateDescriptor templatedResponseField(String path ) {
// return new ResponseFieldTemplateDescriptor(path);
// }
// Path: wiremock/src/test/java/com/epages/restdocs/ResponseTemplateProcessorTest.java
import static com.epages.restdocs.WireMockDocumentation.templatedResponseField;
import static java.util.Collections.singletonList;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
import java.util.Arrays;
import java.util.Collections;
import org.junit.Test;
import org.springframework.web.util.UriTemplate;
package com.epages.restdocs;
public class ResponseTemplateProcessorTest {
private String jsonBody = "{\n" +
" \"id\": \"the-id\",\n" +
" \"name\": \"some\"\n" +
"}";
@Test
public void should_replace_with_uri_variable_expression() { | ResponseFieldTemplateDescriptor templateDescriptor = templatedResponseField("id").replacedWithUriTemplateVariableValue("someId"); |
ePages-de/restdocs-wiremock | server/src/main/java/com/example/notes/NotesController.java | // Path: server/src/main/java/com/example/notes/NoteResourceAssembler.java
// static class NoteResource extends Resource<Note> {
//
// public NoteResource(Note content) {
// super(content);
// }
// }
//
// Path: server/src/main/java/com/example/notes/TagResourceAssembler.java
// static class TagResource extends Resource<Tag> {
//
// public TagResource(Tag content) {
// super(content);
// }
// }
| import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriTemplate;
import com.example.notes.NoteResourceAssembler.NoteResource;
import com.example.notes.TagResourceAssembler.TagResource; | /*
* Copyright 2014-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.notes;
@RestController
@RequestMapping("/notes")
public class NotesController {
private static final UriTemplate TAG_URI_TEMPLATE = new UriTemplate("/tags/{id}");
private final NoteRepository noteRepository;
private final TagRepository tagRepository;
private final NoteResourceAssembler noteResourceAssembler;
private final TagResourceAssembler tagResourceAssembler;
@Autowired
public NotesController(NoteRepository noteRepository, TagRepository tagRepository,
NoteResourceAssembler noteResourceAssembler,
TagResourceAssembler tagResourceAssembler) {
this.noteRepository = noteRepository;
this.tagRepository = tagRepository;
this.noteResourceAssembler = noteResourceAssembler;
this.tagResourceAssembler = tagResourceAssembler;
}
@RequestMapping(method = RequestMethod.GET) | // Path: server/src/main/java/com/example/notes/NoteResourceAssembler.java
// static class NoteResource extends Resource<Note> {
//
// public NoteResource(Note content) {
// super(content);
// }
// }
//
// Path: server/src/main/java/com/example/notes/TagResourceAssembler.java
// static class TagResource extends Resource<Tag> {
//
// public TagResource(Tag content) {
// super(content);
// }
// }
// Path: server/src/main/java/com/example/notes/NotesController.java
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriTemplate;
import com.example.notes.NoteResourceAssembler.NoteResource;
import com.example.notes.TagResourceAssembler.TagResource;
/*
* Copyright 2014-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.notes;
@RestController
@RequestMapping("/notes")
public class NotesController {
private static final UriTemplate TAG_URI_TEMPLATE = new UriTemplate("/tags/{id}");
private final NoteRepository noteRepository;
private final TagRepository tagRepository;
private final NoteResourceAssembler noteResourceAssembler;
private final TagResourceAssembler tagResourceAssembler;
@Autowired
public NotesController(NoteRepository noteRepository, TagRepository tagRepository,
NoteResourceAssembler noteResourceAssembler,
TagResourceAssembler tagResourceAssembler) {
this.noteRepository = noteRepository;
this.tagRepository = tagRepository;
this.noteResourceAssembler = noteResourceAssembler;
this.tagResourceAssembler = tagResourceAssembler;
}
@RequestMapping(method = RequestMethod.GET) | NestedContentResource<NoteResource> all() { |
ePages-de/restdocs-wiremock | server/src/main/java/com/example/notes/NotesController.java | // Path: server/src/main/java/com/example/notes/NoteResourceAssembler.java
// static class NoteResource extends Resource<Note> {
//
// public NoteResource(Note content) {
// super(content);
// }
// }
//
// Path: server/src/main/java/com/example/notes/TagResourceAssembler.java
// static class TagResource extends Resource<Tag> {
//
// public TagResource(Tag content) {
// super(content);
// }
// }
| import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriTemplate;
import com.example.notes.NoteResourceAssembler.NoteResource;
import com.example.notes.TagResourceAssembler.TagResource; |
@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(method = RequestMethod.POST)
HttpHeaders create(@RequestBody NoteInput noteInput) {
Note note = new Note();
note.setTitle(noteInput.getTitle());
note.setBody(noteInput.getBody());
note.setTags(getTags(noteInput.getTagUris()));
this.noteRepository.save(note);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders
.setLocation(linkTo(NotesController.class).slash(note.getId()).toUri());
return httpHeaders;
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
void delete(@PathVariable("id") UUID id) {
this.noteRepository.delete(id);
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
Resource<Note> note(@PathVariable("id") UUID id) {
return this.noteResourceAssembler.toResource(findNoteById(id));
}
@RequestMapping(value = "/{id}/tags", method = RequestMethod.GET)
ResourceSupport noteTags(@PathVariable("id") UUID id) { | // Path: server/src/main/java/com/example/notes/NoteResourceAssembler.java
// static class NoteResource extends Resource<Note> {
//
// public NoteResource(Note content) {
// super(content);
// }
// }
//
// Path: server/src/main/java/com/example/notes/TagResourceAssembler.java
// static class TagResource extends Resource<Tag> {
//
// public TagResource(Tag content) {
// super(content);
// }
// }
// Path: server/src/main/java/com/example/notes/NotesController.java
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriTemplate;
import com.example.notes.NoteResourceAssembler.NoteResource;
import com.example.notes.TagResourceAssembler.TagResource;
@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(method = RequestMethod.POST)
HttpHeaders create(@RequestBody NoteInput noteInput) {
Note note = new Note();
note.setTitle(noteInput.getTitle());
note.setBody(noteInput.getBody());
note.setTags(getTags(noteInput.getTagUris()));
this.noteRepository.save(note);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders
.setLocation(linkTo(NotesController.class).slash(note.getId()).toUri());
return httpHeaders;
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
void delete(@PathVariable("id") UUID id) {
this.noteRepository.delete(id);
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
Resource<Note> note(@PathVariable("id") UUID id) {
return this.noteResourceAssembler.toResource(findNoteById(id));
}
@RequestMapping(value = "/{id}/tags", method = RequestMethod.GET)
ResourceSupport noteTags(@PathVariable("id") UUID id) { | return new NestedContentResource<TagResource>( |
jmnarloch/spring-jax-rs-client-proxy | src/test/java/com/github/jmnarloch/spring/jaxrs/client/cxf/EnableCxfClientTest.java | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactory.java
// public interface JaxRsClientProxyFactory {
//
// /**
// * Creates the proxy class out of specific interface. The proxy is being created for the service interface.
// *
// * @param serviceClass the service class
// * @param serviceUrl the service url
// * @param <T> the service type
// * @return the created proxy
// */
// <T> T createClientProxy(Class<T> serviceClass, String serviceUrl);
// }
| import com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientProxyFactory;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; | /**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.cxf;
/**
* Tests the {@link EnableCxfClient} class.
*
* @author Jakub Narloch
*/
public class EnableCxfClientTest {
/**
* Tests the registration of the proxy factory in application context.
*/
@Test
public void shouldRegisterClientProxyFactory() {
// given
final AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(TestConfig.class);
// when | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactory.java
// public interface JaxRsClientProxyFactory {
//
// /**
// * Creates the proxy class out of specific interface. The proxy is being created for the service interface.
// *
// * @param serviceClass the service class
// * @param serviceUrl the service url
// * @param <T> the service type
// * @return the created proxy
// */
// <T> T createClientProxy(Class<T> serviceClass, String serviceUrl);
// }
// Path: src/test/java/com/github/jmnarloch/spring/jaxrs/client/cxf/EnableCxfClientTest.java
import com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientProxyFactory;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.cxf;
/**
* Tests the {@link EnableCxfClient} class.
*
* @author Jakub Narloch
*/
public class EnableCxfClientTest {
/**
* Tests the registration of the proxy factory in application context.
*/
@Test
public void shouldRegisterClientProxyFactory() {
// given
final AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(TestConfig.class);
// when | JaxRsClientProxyFactory factory = context.getBean(JaxRsClientProxyFactory.class); |
jmnarloch/spring-jax-rs-client-proxy | src/test/java/com/github/jmnarloch/spring/jaxrs/client/jersey/EnableJerseyClientTest.java | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactory.java
// public interface JaxRsClientProxyFactory {
//
// /**
// * Creates the proxy class out of specific interface. The proxy is being created for the service interface.
// *
// * @param serviceClass the service class
// * @param serviceUrl the service url
// * @param <T> the service type
// * @return the created proxy
// */
// <T> T createClientProxy(Class<T> serviceClass, String serviceUrl);
// }
| import com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientProxyFactory;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; | /**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.jersey;
/**
* Tests the {@link EnableJerseyClient} class.
*
* @author Jakub Narloch
*/
public class EnableJerseyClientTest {
/**
* Tests the registration of the proxy factory in application context.
*/
@Test
public void shouldRegisterClientProxyFactory() {
// given
final AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(TestConfig.class);
// when | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactory.java
// public interface JaxRsClientProxyFactory {
//
// /**
// * Creates the proxy class out of specific interface. The proxy is being created for the service interface.
// *
// * @param serviceClass the service class
// * @param serviceUrl the service url
// * @param <T> the service type
// * @return the created proxy
// */
// <T> T createClientProxy(Class<T> serviceClass, String serviceUrl);
// }
// Path: src/test/java/com/github/jmnarloch/spring/jaxrs/client/jersey/EnableJerseyClientTest.java
import com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientProxyFactory;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.jersey;
/**
* Tests the {@link EnableJerseyClient} class.
*
* @author Jakub Narloch
*/
public class EnableJerseyClientTest {
/**
* Tests the registration of the proxy factory in application context.
*/
@Test
public void shouldRegisterClientProxyFactory() {
// given
final AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(TestConfig.class);
// when | JaxRsClientProxyFactory factory = context.getBean(JaxRsClientProxyFactory.class); |
jmnarloch/spring-jax-rs-client-proxy | src/test/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactoryBeanTest.java | // Path: src/test/java/com/github/jmnarloch/spring/jaxrs/resource/EchoResource.java
// @Path("/echo")
// public interface EchoResource {
//
// /**
// * Retrieves the echo message.
// *
// * @param name the name
// * @return the message
// */
// @GET
// String get(@PathParam("name") String name);
// }
| import com.github.jmnarloch.spring.jaxrs.resource.EchoResource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; | /**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.support;
/**
* Tests the {@link JaxRsClientProxyFactoryBean} class.
*
* @author Jakub Narloch
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class JaxRsClientProxyFactoryBeanTest {
private JaxRsClientProxyFactoryBean instance;
@Autowired
private ApplicationContext applicationContext;
@Before
public void setUp() throws Exception {
instance = new JaxRsClientProxyFactoryBean();
}
@Test
public void shouldResolveSpelProperty() throws Exception {
| // Path: src/test/java/com/github/jmnarloch/spring/jaxrs/resource/EchoResource.java
// @Path("/echo")
// public interface EchoResource {
//
// /**
// * Retrieves the echo message.
// *
// * @param name the name
// * @return the message
// */
// @GET
// String get(@PathParam("name") String name);
// }
// Path: src/test/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactoryBeanTest.java
import com.github.jmnarloch.spring.jaxrs.resource.EchoResource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.support;
/**
* Tests the {@link JaxRsClientProxyFactoryBean} class.
*
* @author Jakub Narloch
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class JaxRsClientProxyFactoryBeanTest {
private JaxRsClientProxyFactoryBean instance;
@Autowired
private ApplicationContext applicationContext;
@Before
public void setUp() throws Exception {
instance = new JaxRsClientProxyFactoryBean();
}
@Test
public void shouldResolveSpelProperty() throws Exception {
| final Class<EchoResource> serviceClass = EchoResource.class; |
jmnarloch/spring-jax-rs-client-proxy | src/test/java/com/github/jmnarloch/spring/jaxrs/client/resteasy/EnableRestEasyClientTest.java | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactory.java
// public interface JaxRsClientProxyFactory {
//
// /**
// * Creates the proxy class out of specific interface. The proxy is being created for the service interface.
// *
// * @param serviceClass the service class
// * @param serviceUrl the service url
// * @param <T> the service type
// * @return the created proxy
// */
// <T> T createClientProxy(Class<T> serviceClass, String serviceUrl);
// }
| import com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientProxyFactory;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; | /**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.resteasy;
/**
* Tests the {@link EnableRestEasyClient} class.
*
* @author Jakub Narloch
*/
public class EnableRestEasyClientTest {
/**
* Tests the registration of the proxy factory in application context.
*/
@Test
public void shouldRegisterClientProxyFactory() {
// given
final AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(TestConfig.class);
// when | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactory.java
// public interface JaxRsClientProxyFactory {
//
// /**
// * Creates the proxy class out of specific interface. The proxy is being created for the service interface.
// *
// * @param serviceClass the service class
// * @param serviceUrl the service url
// * @param <T> the service type
// * @return the created proxy
// */
// <T> T createClientProxy(Class<T> serviceClass, String serviceUrl);
// }
// Path: src/test/java/com/github/jmnarloch/spring/jaxrs/client/resteasy/EnableRestEasyClientTest.java
import com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientProxyFactory;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.resteasy;
/**
* Tests the {@link EnableRestEasyClient} class.
*
* @author Jakub Narloch
*/
public class EnableRestEasyClientTest {
/**
* Tests the registration of the proxy factory in application context.
*/
@Test
public void shouldRegisterClientProxyFactory() {
// given
final AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(TestConfig.class);
// when | JaxRsClientProxyFactory factory = context.getBean(JaxRsClientProxyFactory.class); |
jmnarloch/spring-jax-rs-client-proxy | src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientClassPathScanner.java | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/annotation/ServiceUrlProvider.java
// public interface ServiceUrlProvider {
//
// /**
// * Retrieves the service url.
// *
// * @return the service url
// */
// String getServiceUrl();
// }
| import com.github.jmnarloch.spring.jaxrs.client.annotation.ServiceUrlProvider;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import javax.ws.rs.Path;
import java.util.Set; | /**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.support;
/**
* A class path scanner that scans the configured the base packages searching for JAX-RS {@link @Path}
* annotated interfaces.
*
* @author Jakub Narloch
*/
class JaxRsClientClassPathScanner extends ClassPathBeanDefinitionScanner {
/**
* The service url.
*/
private String serviceUrl;
/**
* The service url provider.
*/ | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/annotation/ServiceUrlProvider.java
// public interface ServiceUrlProvider {
//
// /**
// * Retrieves the service url.
// *
// * @return the service url
// */
// String getServiceUrl();
// }
// Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientClassPathScanner.java
import com.github.jmnarloch.spring.jaxrs.client.annotation.ServiceUrlProvider;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import javax.ws.rs.Path;
import java.util.Set;
/**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.support;
/**
* A class path scanner that scans the configured the base packages searching for JAX-RS {@link @Path}
* annotated interfaces.
*
* @author Jakub Narloch
*/
class JaxRsClientClassPathScanner extends ClassPathBeanDefinitionScanner {
/**
* The service url.
*/
private String serviceUrl;
/**
* The service url provider.
*/ | private Class<? extends ServiceUrlProvider> serviceUrlProvider; |
jmnarloch/spring-jax-rs-client-proxy | src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientRegistrar.java | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/annotation/ServiceUrlProvider.java
// public interface ServiceUrlProvider {
//
// /**
// * Retrieves the service url.
// *
// * @return the service url
// */
// String getServiceUrl();
// }
| import com.github.jmnarloch.spring.jaxrs.client.annotation.EnableJaxRsClient;
import com.github.jmnarloch.spring.jaxrs.client.annotation.ServiceUrlProvider;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map; | /**
* Copyright (c) 2015 the original author or authors
* <p/>
* 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.
*/
package com.github.jmnarloch.spring.jaxrs.client.support;
/**
* Registers the JAX-RS client proxy capabilities into the Spring application context.
*
* @author Jakub Narloch
*/
public class JaxRsClientRegistrar implements ImportBeanDefinitionRegistrar {
/**
* The annotation class.
*/
private static final Class<EnableJaxRsClient> ANNOTATION_CLASS = EnableJaxRsClient.class;
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
final List<String> basePackages = new ArrayList<String>();
final Map<String, Object> attributes = annotationMetadata
.getAnnotationAttributes(ANNOTATION_CLASS.getName(), false);
| // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/annotation/ServiceUrlProvider.java
// public interface ServiceUrlProvider {
//
// /**
// * Retrieves the service url.
// *
// * @return the service url
// */
// String getServiceUrl();
// }
// Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientRegistrar.java
import com.github.jmnarloch.spring.jaxrs.client.annotation.EnableJaxRsClient;
import com.github.jmnarloch.spring.jaxrs.client.annotation.ServiceUrlProvider;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* Copyright (c) 2015 the original author or authors
* <p/>
* 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.
*/
package com.github.jmnarloch.spring.jaxrs.client.support;
/**
* Registers the JAX-RS client proxy capabilities into the Spring application context.
*
* @author Jakub Narloch
*/
public class JaxRsClientRegistrar implements ImportBeanDefinitionRegistrar {
/**
* The annotation class.
*/
private static final Class<EnableJaxRsClient> ANNOTATION_CLASS = EnableJaxRsClient.class;
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
final List<String> basePackages = new ArrayList<String>();
final Map<String, Object> attributes = annotationMetadata
.getAnnotationAttributes(ANNOTATION_CLASS.getName(), false);
| final Class<? extends ServiceUrlProvider> serviceUrlProvider = get(attributes, "serviceUrlProvider"); |
jmnarloch/spring-jax-rs-client-proxy | src/test/java/com/github/jmnarloch/spring/jaxrs/client/resteasy/RestEasyClientProxyFactoryTest.java | // Path: src/test/java/com/github/jmnarloch/spring/jaxrs/resource/EchoResource.java
// @Path("/echo")
// public interface EchoResource {
//
// /**
// * Retrieves the echo message.
// *
// * @param name the name
// * @return the message
// */
// @GET
// String get(@PathParam("name") String name);
// }
| import com.github.jmnarloch.spring.jaxrs.resource.EchoResource;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertNotNull; | /**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.resteasy;
/**
* Tests the {@link RestEasyClientProxyFactory} class.
*
* @author Jakub Narloch
*/
public class RestEasyClientProxyFactoryTest {
/**
* The instance of tested class.
*/
private RestEasyClientProxyFactory instance;
/**
* Sets up the test environment.
*
* @throws Exception if any error occurs
*/
@Before
public void setUp() throws Exception {
instance = new RestEasyClientProxyFactory();
}
/**
* Test the creation of the service proxy.
*/
@Test
public void shouldCreateServiceProxy() {
// given | // Path: src/test/java/com/github/jmnarloch/spring/jaxrs/resource/EchoResource.java
// @Path("/echo")
// public interface EchoResource {
//
// /**
// * Retrieves the echo message.
// *
// * @param name the name
// * @return the message
// */
// @GET
// String get(@PathParam("name") String name);
// }
// Path: src/test/java/com/github/jmnarloch/spring/jaxrs/client/resteasy/RestEasyClientProxyFactoryTest.java
import com.github.jmnarloch.spring.jaxrs.resource.EchoResource;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
/**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.resteasy;
/**
* Tests the {@link RestEasyClientProxyFactory} class.
*
* @author Jakub Narloch
*/
public class RestEasyClientProxyFactoryTest {
/**
* The instance of tested class.
*/
private RestEasyClientProxyFactory instance;
/**
* Sets up the test environment.
*
* @throws Exception if any error occurs
*/
@Before
public void setUp() throws Exception {
instance = new RestEasyClientProxyFactory();
}
/**
* Test the creation of the service proxy.
*/
@Test
public void shouldCreateServiceProxy() {
// given | final Class<EchoResource> serviceClass = EchoResource.class; |
jmnarloch/spring-jax-rs-client-proxy | src/test/java/com/github/jmnarloch/spring/jaxrs/client/cxf/CxfClientProxyFactoryTest.java | // Path: src/test/java/com/github/jmnarloch/spring/jaxrs/resource/EchoResource.java
// @Path("/echo")
// public interface EchoResource {
//
// /**
// * Retrieves the echo message.
// *
// * @param name the name
// * @return the message
// */
// @GET
// String get(@PathParam("name") String name);
// }
| import com.github.jmnarloch.spring.jaxrs.resource.EchoResource;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertNotNull; | /**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.cxf;
/**
* Tests the {@link CxfClientProxyFactory} class.
*
* @author Jakub Narloch
*/
public class CxfClientProxyFactoryTest {
/**
* The instance of tested class.
*/
private CxfClientProxyFactory instance;
/**
* Sets up the test environment.
*
* @throws Exception if any error occurs
*/
@Before
public void setUp() throws Exception {
instance = new CxfClientProxyFactory();
}
/**
* Test the creation of the service proxy.
*/
@Test
public void shouldCreateServiceProxy() {
// given | // Path: src/test/java/com/github/jmnarloch/spring/jaxrs/resource/EchoResource.java
// @Path("/echo")
// public interface EchoResource {
//
// /**
// * Retrieves the echo message.
// *
// * @param name the name
// * @return the message
// */
// @GET
// String get(@PathParam("name") String name);
// }
// Path: src/test/java/com/github/jmnarloch/spring/jaxrs/client/cxf/CxfClientProxyFactoryTest.java
import com.github.jmnarloch.spring.jaxrs.resource.EchoResource;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
/**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.cxf;
/**
* Tests the {@link CxfClientProxyFactory} class.
*
* @author Jakub Narloch
*/
public class CxfClientProxyFactoryTest {
/**
* The instance of tested class.
*/
private CxfClientProxyFactory instance;
/**
* Sets up the test environment.
*
* @throws Exception if any error occurs
*/
@Before
public void setUp() throws Exception {
instance = new CxfClientProxyFactory();
}
/**
* Test the creation of the service proxy.
*/
@Test
public void shouldCreateServiceProxy() {
// given | final Class<EchoResource> serviceClass = EchoResource.class; |
jmnarloch/spring-jax-rs-client-proxy | src/test/java/com/github/jmnarloch/spring/jaxrs/client/jersey/JerseyClientConfigurationTest.java | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactory.java
// public interface JaxRsClientProxyFactory {
//
// /**
// * Creates the proxy class out of specific interface. The proxy is being created for the service interface.
// *
// * @param serviceClass the service class
// * @param serviceUrl the service url
// * @param <T> the service type
// * @return the created proxy
// */
// <T> T createClientProxy(Class<T> serviceClass, String serviceUrl);
// }
| import com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientProxyFactory;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; | /**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.jersey;
/**
* Tests the {@link JerseyClientConfiguration} class.
*
* @author Jakub Narloch
*/
public class JerseyClientConfigurationTest {
/**
* Tests the registration of the proxy factory in application context.
*/
@Test
public void shouldRegisterClientProxyFactory() {
// given
final AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(JerseyClientConfiguration.class);
// when | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactory.java
// public interface JaxRsClientProxyFactory {
//
// /**
// * Creates the proxy class out of specific interface. The proxy is being created for the service interface.
// *
// * @param serviceClass the service class
// * @param serviceUrl the service url
// * @param <T> the service type
// * @return the created proxy
// */
// <T> T createClientProxy(Class<T> serviceClass, String serviceUrl);
// }
// Path: src/test/java/com/github/jmnarloch/spring/jaxrs/client/jersey/JerseyClientConfigurationTest.java
import com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientProxyFactory;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.jersey;
/**
* Tests the {@link JerseyClientConfiguration} class.
*
* @author Jakub Narloch
*/
public class JerseyClientConfigurationTest {
/**
* Tests the registration of the proxy factory in application context.
*/
@Test
public void shouldRegisterClientProxyFactory() {
// given
final AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(JerseyClientConfiguration.class);
// when | JaxRsClientProxyFactory factory = context.getBean(JaxRsClientProxyFactory.class); |
jmnarloch/spring-jax-rs-client-proxy | src/test/java/com/github/jmnarloch/spring/jaxrs/client/resteasy/RestEasyClientConfigurationTest.java | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactory.java
// public interface JaxRsClientProxyFactory {
//
// /**
// * Creates the proxy class out of specific interface. The proxy is being created for the service interface.
// *
// * @param serviceClass the service class
// * @param serviceUrl the service url
// * @param <T> the service type
// * @return the created proxy
// */
// <T> T createClientProxy(Class<T> serviceClass, String serviceUrl);
// }
| import com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientProxyFactory;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; | /**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.resteasy;
/**
* Tests the {@link RestEasyClientConfiguration} class.
*
* @author Jakub Narloch
*/
public class RestEasyClientConfigurationTest {
/**
* Tests the registration of the proxy factory in application context.
*/
@Test
public void shouldRegisterClientProxyFactory() {
// given
final AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(RestEasyClientConfiguration.class);
// when | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactory.java
// public interface JaxRsClientProxyFactory {
//
// /**
// * Creates the proxy class out of specific interface. The proxy is being created for the service interface.
// *
// * @param serviceClass the service class
// * @param serviceUrl the service url
// * @param <T> the service type
// * @return the created proxy
// */
// <T> T createClientProxy(Class<T> serviceClass, String serviceUrl);
// }
// Path: src/test/java/com/github/jmnarloch/spring/jaxrs/client/resteasy/RestEasyClientConfigurationTest.java
import com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientProxyFactory;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.resteasy;
/**
* Tests the {@link RestEasyClientConfiguration} class.
*
* @author Jakub Narloch
*/
public class RestEasyClientConfigurationTest {
/**
* Tests the registration of the proxy factory in application context.
*/
@Test
public void shouldRegisterClientProxyFactory() {
// given
final AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(RestEasyClientConfiguration.class);
// when | JaxRsClientProxyFactory factory = context.getBean(JaxRsClientProxyFactory.class); |
jmnarloch/spring-jax-rs-client-proxy | src/test/java/com/github/jmnarloch/spring/jaxrs/client/jersey/JerseyClientProxyFactoryTest.java | // Path: src/test/java/com/github/jmnarloch/spring/jaxrs/resource/EchoResource.java
// @Path("/echo")
// public interface EchoResource {
//
// /**
// * Retrieves the echo message.
// *
// * @param name the name
// * @return the message
// */
// @GET
// String get(@PathParam("name") String name);
// }
| import com.github.jmnarloch.spring.jaxrs.resource.EchoResource;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertNotNull; | /**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.jersey;
/**
* Tests the {@link JerseyClientProxyFactory} class.
*
* @author Jakub Narloch
*/
public class JerseyClientProxyFactoryTest {
/**
* The instance of tested class.
*/
private JerseyClientProxyFactory instance;
/**
* Sets up the test environment.
*
* @throws Exception if any error occurs
*/
@Before
public void setUp() throws Exception {
instance = new JerseyClientProxyFactory();
}
/**
* Test the creation of the service proxy.
*/
@Test
public void shouldCreateServiceProxy() {
// given | // Path: src/test/java/com/github/jmnarloch/spring/jaxrs/resource/EchoResource.java
// @Path("/echo")
// public interface EchoResource {
//
// /**
// * Retrieves the echo message.
// *
// * @param name the name
// * @return the message
// */
// @GET
// String get(@PathParam("name") String name);
// }
// Path: src/test/java/com/github/jmnarloch/spring/jaxrs/client/jersey/JerseyClientProxyFactoryTest.java
import com.github.jmnarloch.spring.jaxrs.resource.EchoResource;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
/**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.jersey;
/**
* Tests the {@link JerseyClientProxyFactory} class.
*
* @author Jakub Narloch
*/
public class JerseyClientProxyFactoryTest {
/**
* The instance of tested class.
*/
private JerseyClientProxyFactory instance;
/**
* Sets up the test environment.
*
* @throws Exception if any error occurs
*/
@Before
public void setUp() throws Exception {
instance = new JerseyClientProxyFactory();
}
/**
* Test the creation of the service proxy.
*/
@Test
public void shouldCreateServiceProxy() {
// given | final Class<EchoResource> serviceClass = EchoResource.class; |
jmnarloch/spring-jax-rs-client-proxy | src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactoryBean.java | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/annotation/ServiceUrlProvider.java
// public interface ServiceUrlProvider {
//
// /**
// * Retrieves the service url.
// *
// * @return the service url
// */
// String getServiceUrl();
// }
| import com.github.jmnarloch.spring.jaxrs.client.annotation.ServiceUrlProvider;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.beans.factory.config.BeanExpressionContext;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; | /**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.support;
/**
* An factory bean that is responsible for instation of specific proxy class.
*
* @author Jakub Narloch
*/
class JaxRsClientProxyFactoryBean implements ApplicationContextAware, FactoryBean {
/**
* The application context.
*/
private ApplicationContext applicationContext;
/**
* The target service class.
*/
private Class<?> serviceClass;
/**
* The service url.
*/
private String serviceUrl;
/**
* The service url provider.
*/ | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/annotation/ServiceUrlProvider.java
// public interface ServiceUrlProvider {
//
// /**
// * Retrieves the service url.
// *
// * @return the service url
// */
// String getServiceUrl();
// }
// Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactoryBean.java
import com.github.jmnarloch.spring.jaxrs.client.annotation.ServiceUrlProvider;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.beans.factory.config.BeanExpressionContext;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.support;
/**
* An factory bean that is responsible for instation of specific proxy class.
*
* @author Jakub Narloch
*/
class JaxRsClientProxyFactoryBean implements ApplicationContextAware, FactoryBean {
/**
* The application context.
*/
private ApplicationContext applicationContext;
/**
* The target service class.
*/
private Class<?> serviceClass;
/**
* The service url.
*/
private String serviceUrl;
/**
* The service url provider.
*/ | private Class<? extends ServiceUrlProvider> serviceUrlProvider; |
jmnarloch/spring-jax-rs-client-proxy | src/test/java/com/github/jmnarloch/spring/jaxrs/client/cxf/CxfClientConfigurationTest.java | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactory.java
// public interface JaxRsClientProxyFactory {
//
// /**
// * Creates the proxy class out of specific interface. The proxy is being created for the service interface.
// *
// * @param serviceClass the service class
// * @param serviceUrl the service url
// * @param <T> the service type
// * @return the created proxy
// */
// <T> T createClientProxy(Class<T> serviceClass, String serviceUrl);
// }
| import com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientProxyFactory;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; | /**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.cxf;
/**
* Tests the {@link CxfClientConfiguration} class.
*
* @author Jakub Narloch
*/
public class CxfClientConfigurationTest {
/**
* Tests the registration of the proxy factory in application context.
*/
@Test
public void shouldRegisterClientProxyFactory() {
// given
final AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(CxfClientConfiguration.class);
// when | // Path: src/main/java/com/github/jmnarloch/spring/jaxrs/client/support/JaxRsClientProxyFactory.java
// public interface JaxRsClientProxyFactory {
//
// /**
// * Creates the proxy class out of specific interface. The proxy is being created for the service interface.
// *
// * @param serviceClass the service class
// * @param serviceUrl the service url
// * @param <T> the service type
// * @return the created proxy
// */
// <T> T createClientProxy(Class<T> serviceClass, String serviceUrl);
// }
// Path: src/test/java/com/github/jmnarloch/spring/jaxrs/client/cxf/CxfClientConfigurationTest.java
import com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientProxyFactory;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* Copyright (c) 2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jmnarloch.spring.jaxrs.client.cxf;
/**
* Tests the {@link CxfClientConfiguration} class.
*
* @author Jakub Narloch
*/
public class CxfClientConfigurationTest {
/**
* Tests the registration of the proxy factory in application context.
*/
@Test
public void shouldRegisterClientProxyFactory() {
// given
final AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(CxfClientConfiguration.class);
// when | JaxRsClientProxyFactory factory = context.getBean(JaxRsClientProxyFactory.class); |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/annotations/PositionedField.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface PositionedField { | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/annotations/PositionedField.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface PositionedField { | FieldPolicy policy() default FieldPolicy.DEFAULT; |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/EndPatronSession.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("35")
@TestCaseDefault("3519700101 010000AA|AC|AD|AO|")
@TestCasePopulated("3519700101 010000AApatronIdentifier|ACterminalPassword|ADpatronPassword|AOinstitutionId|")
public class EndPatronSession extends Message {
private static final long serialVersionUID = -1263417214546161837L;
@PositionedField(start = 2, end = 19)
private java.util.Date transactionDate;
@TaggedField()
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/EndPatronSession.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("35")
@TestCaseDefault("3519700101 010000AA|AC|AD|AO|")
@TestCasePopulated("3519700101 010000AApatronIdentifier|ACterminalPassword|ADpatronPassword|AOinstitutionId|")
public class EndPatronSession extends Message {
private static final long serialVersionUID = -1263417214546161837L;
@PositionedField(start = 2, end = 19)
private java.util.Date transactionDate;
@TaggedField()
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/ItemStatusUpdateResponse.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("20")
@TestCaseDefault("20019700101 010000AB|")
@TestCasePopulated("20119700101 010000ABitemIdentifier|AFscreenMessage|AGprintLine|AJtitleIdentifier|CHitemProperties|")
public class ItemStatusUpdateResponse extends Message {
private static final long serialVersionUID = 428496319623237121L;
@PositionedField(start = 2, end = 2)
private Boolean ok;
@PositionedField(start = 3, end = 20)
private java.util.Date transactionDate; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/ItemStatusUpdateResponse.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("20")
@TestCaseDefault("20019700101 010000AB|")
@TestCasePopulated("20119700101 010000ABitemIdentifier|AFscreenMessage|AGprintLine|AJtitleIdentifier|CHitemProperties|")
public class ItemStatusUpdateResponse extends Message {
private static final long serialVersionUID = 428496319623237121L;
@PositionedField(start = 2, end = 2)
private Boolean ok;
@PositionedField(start = 3, end = 20)
private java.util.Date transactionDate; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/annotations/Field.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Field {
String tag() default "";
int length() default 0; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/annotations/Field.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Field {
String tag() default "";
int length() default 0; | FieldPolicy policy() default FieldPolicy.DEFAULT; |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/Renew.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("29")
@TestCaseDefault("29NN19700101 010000 AA|AO|")
@TestCasePopulated("29YY19700101 01000019700101 010000AApatronIdentifier|ABitemIdentifier|ACterminalPassword|ADpatronPassword|AJtitleIdentifier|AOinstitutionId|BOY|CHitemProperties|")
public class Renew extends Message {
private static final long serialVersionUID = 158409818027250051L;
@PositionedField(start = 2, end = 2)
private Boolean thirdPartyAllowed;
@PositionedField(start = 3, end = 3)
private Boolean noBlock;
@PositionedField(start = 4, end = 21)
private java.util.Date transactionDate;
@PositionedField(start = 22, end = 39)
private java.util.Date nbDueDate;
@TaggedField
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/Renew.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("29")
@TestCaseDefault("29NN19700101 010000 AA|AO|")
@TestCasePopulated("29YY19700101 01000019700101 010000AApatronIdentifier|ABitemIdentifier|ACterminalPassword|ADpatronPassword|AJtitleIdentifier|AOinstitutionId|BOY|CHitemProperties|")
public class Renew extends Message {
private static final long serialVersionUID = 158409818027250051L;
@PositionedField(start = 2, end = 2)
private Boolean thirdPartyAllowed;
@PositionedField(start = 3, end = 3)
private Boolean noBlock;
@PositionedField(start = 4, end = 21)
private java.util.Date transactionDate;
@PositionedField(start = 22, end = 39)
private java.util.Date nbDueDate;
@TaggedField
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/PatronEnable.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("25")
@TestCaseDefault("2519700101 010000AA|AO|")
@TestCasePopulated("2519700101 010000AApatronIdentifier|ACterminalPassword|ADpatronPassword|AOinstitutionId|")
public class PatronEnable extends Message {
private static final long serialVersionUID = -5425998497345962069L;
@PositionedField(start = 2, end = 19)
private java.util.Date transactionDate;
@TaggedField
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/PatronEnable.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("25")
@TestCaseDefault("2519700101 010000AA|AO|")
@TestCasePopulated("2519700101 010000AApatronIdentifier|ACterminalPassword|ADpatronPassword|AOinstitutionId|")
public class PatronEnable extends Message {
private static final long serialVersionUID = -5425998497345962069L;
@PositionedField(start = 2, end = 19)
private java.util.Date transactionDate;
@TaggedField
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/CheckIn.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("09")
@TestCaseDefault("09N19700101 010000 AB|AC|AO|AP|")
@TestCasePopulated("09Y19700101 01000019700101 010000ABitemIdentifier|ACterminalPassword|AOinstitutionId|APcurrentLocation|BIY|CHitemProperties|")
public class CheckIn extends Message {
private static final long serialVersionUID = -7321140594135175919L;
@PositionedField(start = 2, end = 2)
private Boolean noBlock;
@PositionedField(start = 3, end = 20)
private Date transactionDate;
@PositionedField(start = 21, end = 38)
private Date returnDate; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/CheckIn.java
import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("09")
@TestCaseDefault("09N19700101 010000 AB|AC|AO|AP|")
@TestCasePopulated("09Y19700101 01000019700101 010000ABitemIdentifier|ACterminalPassword|AOinstitutionId|APcurrentLocation|BIY|CHitemProperties|")
public class CheckIn extends Message {
private static final long serialVersionUID = -7321140594135175919L;
@PositionedField(start = 2, end = 2)
private Boolean noBlock;
@PositionedField(start = 3, end = 20)
private Date transactionDate;
@PositionedField(start = 21, end = 38)
private Date returnDate; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/netty/server/SIPServerInitializer.java | // Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageDecoder.java
// @Sharable
// public class SIPMessageDecoder extends MessageToMessageDecoder<String> {
// private boolean strictChecksumChecking = false;
//
// public SIPMessageDecoder() {}
//
// public SIPMessageDecoder(boolean strictChecksumChecking)
// {
// this.strictChecksumChecking = strictChecksumChecking;
// }
//
// @Override
// protected void decode(ChannelHandlerContext ctx, String msg, List<Object> out) throws Exception {
// out.add(Message.decode(msg, null, strictChecksumChecking));
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageEncoder.java
// @Sharable
// public class SIPMessageEncoder extends MessageToMessageEncoder<Message> {
//
// public SIPMessageEncoder() {}
//
// @Override
// protected void encode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
// out.add(msg.encode() + "\r");
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/channel/SIPChannelHandler.java
// @Sharable
// public class SIPChannelHandler extends SimpleChannelInboundHandler<Message> {
// private static Log logger = LogFactory.getLog(SIPChannelHandler.class);
//
// private com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory driverFactory;
//
// public SIPChannelHandler(DriverFactory driverFactory)
// {
// this.driverFactory = driverFactory;
// }
//
// @Override
// public void channelActive(ChannelHandlerContext ctx) throws Exception {
// // ctx.flush();
// }
//
// private Message process(Message request) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, MessageNotUnderstood, InstantiationException {
// Driver driver = driverFactory.getDriver();
//
// Method[] handlerMethods = driver.getClass().getMethods();
//
// for (Method handlerMethod : handlerMethods) {
// Class<?> types[] = handlerMethod.getParameterTypes();
// if (types.length == 1) {
// if (request.getClass() == types[0]) {
// return (Message) handlerMethod.invoke(driver, new Object[] { request });
// }
// }
// }
// throw new MessageNotUnderstood();
// }
//
//
// Message response = null;
//
// @Override
// public void channelRead0(ChannelHandlerContext ctx, Message request) throws Exception {
// if (!(request instanceof ACSResend)) {
// response = process(request);
// } else if (response == null) {
// response = new SCResend();
// }
//
// response.setSequenceCharacter(request.getSequenceCharacter());
//
// ChannelFuture future = ctx.write(response);
// }
//
// @Override
// public void channelReadComplete(ChannelHandlerContext ctx) {
// ctx.flush();
// }
//
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// if (cause instanceof java.io.IOException) {
// logger.debug(cause.getMessage());
// } else {
// logger.error("Transient communications error", cause);
// // cause.printStackTrace();
// try {
// ctx.write(new SCResend().encode(null));
// ctx.flush();
// } catch (Exception e1) {
// logger.error("Transient communications error", e1);
// ctx.close();
// }
// }
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/DriverFactory.java
// public interface DriverFactory {
// Driver getDriver();
// }
| import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslContext;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageDecoder;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageEncoder;
import com.ceridwen.circulation.SIP.netty.server.channel.SIPChannelHandler;
import com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.logging.LogLevel; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.netty.server;
public class SIPServerInitializer extends ChannelInitializer<SocketChannel> {
private final StringDecoder DECODER = new StringDecoder();
private final StringEncoder ENCODER = new StringEncoder(); | // Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageDecoder.java
// @Sharable
// public class SIPMessageDecoder extends MessageToMessageDecoder<String> {
// private boolean strictChecksumChecking = false;
//
// public SIPMessageDecoder() {}
//
// public SIPMessageDecoder(boolean strictChecksumChecking)
// {
// this.strictChecksumChecking = strictChecksumChecking;
// }
//
// @Override
// protected void decode(ChannelHandlerContext ctx, String msg, List<Object> out) throws Exception {
// out.add(Message.decode(msg, null, strictChecksumChecking));
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageEncoder.java
// @Sharable
// public class SIPMessageEncoder extends MessageToMessageEncoder<Message> {
//
// public SIPMessageEncoder() {}
//
// @Override
// protected void encode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
// out.add(msg.encode() + "\r");
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/channel/SIPChannelHandler.java
// @Sharable
// public class SIPChannelHandler extends SimpleChannelInboundHandler<Message> {
// private static Log logger = LogFactory.getLog(SIPChannelHandler.class);
//
// private com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory driverFactory;
//
// public SIPChannelHandler(DriverFactory driverFactory)
// {
// this.driverFactory = driverFactory;
// }
//
// @Override
// public void channelActive(ChannelHandlerContext ctx) throws Exception {
// // ctx.flush();
// }
//
// private Message process(Message request) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, MessageNotUnderstood, InstantiationException {
// Driver driver = driverFactory.getDriver();
//
// Method[] handlerMethods = driver.getClass().getMethods();
//
// for (Method handlerMethod : handlerMethods) {
// Class<?> types[] = handlerMethod.getParameterTypes();
// if (types.length == 1) {
// if (request.getClass() == types[0]) {
// return (Message) handlerMethod.invoke(driver, new Object[] { request });
// }
// }
// }
// throw new MessageNotUnderstood();
// }
//
//
// Message response = null;
//
// @Override
// public void channelRead0(ChannelHandlerContext ctx, Message request) throws Exception {
// if (!(request instanceof ACSResend)) {
// response = process(request);
// } else if (response == null) {
// response = new SCResend();
// }
//
// response.setSequenceCharacter(request.getSequenceCharacter());
//
// ChannelFuture future = ctx.write(response);
// }
//
// @Override
// public void channelReadComplete(ChannelHandlerContext ctx) {
// ctx.flush();
// }
//
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// if (cause instanceof java.io.IOException) {
// logger.debug(cause.getMessage());
// } else {
// logger.error("Transient communications error", cause);
// // cause.printStackTrace();
// try {
// ctx.write(new SCResend().encode(null));
// ctx.flush();
// } catch (Exception e1) {
// logger.error("Transient communications error", e1);
// ctx.close();
// }
// }
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/DriverFactory.java
// public interface DriverFactory {
// Driver getDriver();
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/SIPServerInitializer.java
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslContext;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageDecoder;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageEncoder;
import com.ceridwen.circulation.SIP.netty.server.channel.SIPChannelHandler;
import com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.logging.LogLevel;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.netty.server;
public class SIPServerInitializer extends ChannelInitializer<SocketChannel> {
private final StringDecoder DECODER = new StringDecoder();
private final StringEncoder ENCODER = new StringEncoder(); | private SIPMessageDecoder SIPDECODER; |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/netty/server/SIPServerInitializer.java | // Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageDecoder.java
// @Sharable
// public class SIPMessageDecoder extends MessageToMessageDecoder<String> {
// private boolean strictChecksumChecking = false;
//
// public SIPMessageDecoder() {}
//
// public SIPMessageDecoder(boolean strictChecksumChecking)
// {
// this.strictChecksumChecking = strictChecksumChecking;
// }
//
// @Override
// protected void decode(ChannelHandlerContext ctx, String msg, List<Object> out) throws Exception {
// out.add(Message.decode(msg, null, strictChecksumChecking));
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageEncoder.java
// @Sharable
// public class SIPMessageEncoder extends MessageToMessageEncoder<Message> {
//
// public SIPMessageEncoder() {}
//
// @Override
// protected void encode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
// out.add(msg.encode() + "\r");
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/channel/SIPChannelHandler.java
// @Sharable
// public class SIPChannelHandler extends SimpleChannelInboundHandler<Message> {
// private static Log logger = LogFactory.getLog(SIPChannelHandler.class);
//
// private com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory driverFactory;
//
// public SIPChannelHandler(DriverFactory driverFactory)
// {
// this.driverFactory = driverFactory;
// }
//
// @Override
// public void channelActive(ChannelHandlerContext ctx) throws Exception {
// // ctx.flush();
// }
//
// private Message process(Message request) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, MessageNotUnderstood, InstantiationException {
// Driver driver = driverFactory.getDriver();
//
// Method[] handlerMethods = driver.getClass().getMethods();
//
// for (Method handlerMethod : handlerMethods) {
// Class<?> types[] = handlerMethod.getParameterTypes();
// if (types.length == 1) {
// if (request.getClass() == types[0]) {
// return (Message) handlerMethod.invoke(driver, new Object[] { request });
// }
// }
// }
// throw new MessageNotUnderstood();
// }
//
//
// Message response = null;
//
// @Override
// public void channelRead0(ChannelHandlerContext ctx, Message request) throws Exception {
// if (!(request instanceof ACSResend)) {
// response = process(request);
// } else if (response == null) {
// response = new SCResend();
// }
//
// response.setSequenceCharacter(request.getSequenceCharacter());
//
// ChannelFuture future = ctx.write(response);
// }
//
// @Override
// public void channelReadComplete(ChannelHandlerContext ctx) {
// ctx.flush();
// }
//
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// if (cause instanceof java.io.IOException) {
// logger.debug(cause.getMessage());
// } else {
// logger.error("Transient communications error", cause);
// // cause.printStackTrace();
// try {
// ctx.write(new SCResend().encode(null));
// ctx.flush();
// } catch (Exception e1) {
// logger.error("Transient communications error", e1);
// ctx.close();
// }
// }
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/DriverFactory.java
// public interface DriverFactory {
// Driver getDriver();
// }
| import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslContext;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageDecoder;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageEncoder;
import com.ceridwen.circulation.SIP.netty.server.channel.SIPChannelHandler;
import com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.logging.LogLevel; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.netty.server;
public class SIPServerInitializer extends ChannelInitializer<SocketChannel> {
private final StringDecoder DECODER = new StringDecoder();
private final StringEncoder ENCODER = new StringEncoder();
private SIPMessageDecoder SIPDECODER; | // Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageDecoder.java
// @Sharable
// public class SIPMessageDecoder extends MessageToMessageDecoder<String> {
// private boolean strictChecksumChecking = false;
//
// public SIPMessageDecoder() {}
//
// public SIPMessageDecoder(boolean strictChecksumChecking)
// {
// this.strictChecksumChecking = strictChecksumChecking;
// }
//
// @Override
// protected void decode(ChannelHandlerContext ctx, String msg, List<Object> out) throws Exception {
// out.add(Message.decode(msg, null, strictChecksumChecking));
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageEncoder.java
// @Sharable
// public class SIPMessageEncoder extends MessageToMessageEncoder<Message> {
//
// public SIPMessageEncoder() {}
//
// @Override
// protected void encode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
// out.add(msg.encode() + "\r");
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/channel/SIPChannelHandler.java
// @Sharable
// public class SIPChannelHandler extends SimpleChannelInboundHandler<Message> {
// private static Log logger = LogFactory.getLog(SIPChannelHandler.class);
//
// private com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory driverFactory;
//
// public SIPChannelHandler(DriverFactory driverFactory)
// {
// this.driverFactory = driverFactory;
// }
//
// @Override
// public void channelActive(ChannelHandlerContext ctx) throws Exception {
// // ctx.flush();
// }
//
// private Message process(Message request) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, MessageNotUnderstood, InstantiationException {
// Driver driver = driverFactory.getDriver();
//
// Method[] handlerMethods = driver.getClass().getMethods();
//
// for (Method handlerMethod : handlerMethods) {
// Class<?> types[] = handlerMethod.getParameterTypes();
// if (types.length == 1) {
// if (request.getClass() == types[0]) {
// return (Message) handlerMethod.invoke(driver, new Object[] { request });
// }
// }
// }
// throw new MessageNotUnderstood();
// }
//
//
// Message response = null;
//
// @Override
// public void channelRead0(ChannelHandlerContext ctx, Message request) throws Exception {
// if (!(request instanceof ACSResend)) {
// response = process(request);
// } else if (response == null) {
// response = new SCResend();
// }
//
// response.setSequenceCharacter(request.getSequenceCharacter());
//
// ChannelFuture future = ctx.write(response);
// }
//
// @Override
// public void channelReadComplete(ChannelHandlerContext ctx) {
// ctx.flush();
// }
//
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// if (cause instanceof java.io.IOException) {
// logger.debug(cause.getMessage());
// } else {
// logger.error("Transient communications error", cause);
// // cause.printStackTrace();
// try {
// ctx.write(new SCResend().encode(null));
// ctx.flush();
// } catch (Exception e1) {
// logger.error("Transient communications error", e1);
// ctx.close();
// }
// }
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/DriverFactory.java
// public interface DriverFactory {
// Driver getDriver();
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/SIPServerInitializer.java
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslContext;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageDecoder;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageEncoder;
import com.ceridwen.circulation.SIP.netty.server.channel.SIPChannelHandler;
import com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.logging.LogLevel;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.netty.server;
public class SIPServerInitializer extends ChannelInitializer<SocketChannel> {
private final StringDecoder DECODER = new StringDecoder();
private final StringEncoder ENCODER = new StringEncoder();
private SIPMessageDecoder SIPDECODER; | private final SIPMessageEncoder SIPENCODER = new SIPMessageEncoder(); |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/netty/server/SIPServerInitializer.java | // Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageDecoder.java
// @Sharable
// public class SIPMessageDecoder extends MessageToMessageDecoder<String> {
// private boolean strictChecksumChecking = false;
//
// public SIPMessageDecoder() {}
//
// public SIPMessageDecoder(boolean strictChecksumChecking)
// {
// this.strictChecksumChecking = strictChecksumChecking;
// }
//
// @Override
// protected void decode(ChannelHandlerContext ctx, String msg, List<Object> out) throws Exception {
// out.add(Message.decode(msg, null, strictChecksumChecking));
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageEncoder.java
// @Sharable
// public class SIPMessageEncoder extends MessageToMessageEncoder<Message> {
//
// public SIPMessageEncoder() {}
//
// @Override
// protected void encode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
// out.add(msg.encode() + "\r");
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/channel/SIPChannelHandler.java
// @Sharable
// public class SIPChannelHandler extends SimpleChannelInboundHandler<Message> {
// private static Log logger = LogFactory.getLog(SIPChannelHandler.class);
//
// private com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory driverFactory;
//
// public SIPChannelHandler(DriverFactory driverFactory)
// {
// this.driverFactory = driverFactory;
// }
//
// @Override
// public void channelActive(ChannelHandlerContext ctx) throws Exception {
// // ctx.flush();
// }
//
// private Message process(Message request) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, MessageNotUnderstood, InstantiationException {
// Driver driver = driverFactory.getDriver();
//
// Method[] handlerMethods = driver.getClass().getMethods();
//
// for (Method handlerMethod : handlerMethods) {
// Class<?> types[] = handlerMethod.getParameterTypes();
// if (types.length == 1) {
// if (request.getClass() == types[0]) {
// return (Message) handlerMethod.invoke(driver, new Object[] { request });
// }
// }
// }
// throw new MessageNotUnderstood();
// }
//
//
// Message response = null;
//
// @Override
// public void channelRead0(ChannelHandlerContext ctx, Message request) throws Exception {
// if (!(request instanceof ACSResend)) {
// response = process(request);
// } else if (response == null) {
// response = new SCResend();
// }
//
// response.setSequenceCharacter(request.getSequenceCharacter());
//
// ChannelFuture future = ctx.write(response);
// }
//
// @Override
// public void channelReadComplete(ChannelHandlerContext ctx) {
// ctx.flush();
// }
//
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// if (cause instanceof java.io.IOException) {
// logger.debug(cause.getMessage());
// } else {
// logger.error("Transient communications error", cause);
// // cause.printStackTrace();
// try {
// ctx.write(new SCResend().encode(null));
// ctx.flush();
// } catch (Exception e1) {
// logger.error("Transient communications error", e1);
// ctx.close();
// }
// }
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/DriverFactory.java
// public interface DriverFactory {
// Driver getDriver();
// }
| import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslContext;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageDecoder;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageEncoder;
import com.ceridwen.circulation.SIP.netty.server.channel.SIPChannelHandler;
import com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.logging.LogLevel; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.netty.server;
public class SIPServerInitializer extends ChannelInitializer<SocketChannel> {
private final StringDecoder DECODER = new StringDecoder();
private final StringEncoder ENCODER = new StringEncoder();
private SIPMessageDecoder SIPDECODER;
private final SIPMessageEncoder SIPENCODER = new SIPMessageEncoder();
| // Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageDecoder.java
// @Sharable
// public class SIPMessageDecoder extends MessageToMessageDecoder<String> {
// private boolean strictChecksumChecking = false;
//
// public SIPMessageDecoder() {}
//
// public SIPMessageDecoder(boolean strictChecksumChecking)
// {
// this.strictChecksumChecking = strictChecksumChecking;
// }
//
// @Override
// protected void decode(ChannelHandlerContext ctx, String msg, List<Object> out) throws Exception {
// out.add(Message.decode(msg, null, strictChecksumChecking));
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageEncoder.java
// @Sharable
// public class SIPMessageEncoder extends MessageToMessageEncoder<Message> {
//
// public SIPMessageEncoder() {}
//
// @Override
// protected void encode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
// out.add(msg.encode() + "\r");
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/channel/SIPChannelHandler.java
// @Sharable
// public class SIPChannelHandler extends SimpleChannelInboundHandler<Message> {
// private static Log logger = LogFactory.getLog(SIPChannelHandler.class);
//
// private com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory driverFactory;
//
// public SIPChannelHandler(DriverFactory driverFactory)
// {
// this.driverFactory = driverFactory;
// }
//
// @Override
// public void channelActive(ChannelHandlerContext ctx) throws Exception {
// // ctx.flush();
// }
//
// private Message process(Message request) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, MessageNotUnderstood, InstantiationException {
// Driver driver = driverFactory.getDriver();
//
// Method[] handlerMethods = driver.getClass().getMethods();
//
// for (Method handlerMethod : handlerMethods) {
// Class<?> types[] = handlerMethod.getParameterTypes();
// if (types.length == 1) {
// if (request.getClass() == types[0]) {
// return (Message) handlerMethod.invoke(driver, new Object[] { request });
// }
// }
// }
// throw new MessageNotUnderstood();
// }
//
//
// Message response = null;
//
// @Override
// public void channelRead0(ChannelHandlerContext ctx, Message request) throws Exception {
// if (!(request instanceof ACSResend)) {
// response = process(request);
// } else if (response == null) {
// response = new SCResend();
// }
//
// response.setSequenceCharacter(request.getSequenceCharacter());
//
// ChannelFuture future = ctx.write(response);
// }
//
// @Override
// public void channelReadComplete(ChannelHandlerContext ctx) {
// ctx.flush();
// }
//
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// if (cause instanceof java.io.IOException) {
// logger.debug(cause.getMessage());
// } else {
// logger.error("Transient communications error", cause);
// // cause.printStackTrace();
// try {
// ctx.write(new SCResend().encode(null));
// ctx.flush();
// } catch (Exception e1) {
// logger.error("Transient communications error", e1);
// ctx.close();
// }
// }
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/DriverFactory.java
// public interface DriverFactory {
// Driver getDriver();
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/SIPServerInitializer.java
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslContext;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageDecoder;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageEncoder;
import com.ceridwen.circulation.SIP.netty.server.channel.SIPChannelHandler;
import com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.logging.LogLevel;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.netty.server;
public class SIPServerInitializer extends ChannelInitializer<SocketChannel> {
private final StringDecoder DECODER = new StringDecoder();
private final StringEncoder ENCODER = new StringEncoder();
private SIPMessageDecoder SIPDECODER;
private final SIPMessageEncoder SIPENCODER = new SIPMessageEncoder();
| private SIPChannelHandler SERVER_HANDLER; |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/netty/server/SIPServerInitializer.java | // Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageDecoder.java
// @Sharable
// public class SIPMessageDecoder extends MessageToMessageDecoder<String> {
// private boolean strictChecksumChecking = false;
//
// public SIPMessageDecoder() {}
//
// public SIPMessageDecoder(boolean strictChecksumChecking)
// {
// this.strictChecksumChecking = strictChecksumChecking;
// }
//
// @Override
// protected void decode(ChannelHandlerContext ctx, String msg, List<Object> out) throws Exception {
// out.add(Message.decode(msg, null, strictChecksumChecking));
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageEncoder.java
// @Sharable
// public class SIPMessageEncoder extends MessageToMessageEncoder<Message> {
//
// public SIPMessageEncoder() {}
//
// @Override
// protected void encode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
// out.add(msg.encode() + "\r");
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/channel/SIPChannelHandler.java
// @Sharable
// public class SIPChannelHandler extends SimpleChannelInboundHandler<Message> {
// private static Log logger = LogFactory.getLog(SIPChannelHandler.class);
//
// private com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory driverFactory;
//
// public SIPChannelHandler(DriverFactory driverFactory)
// {
// this.driverFactory = driverFactory;
// }
//
// @Override
// public void channelActive(ChannelHandlerContext ctx) throws Exception {
// // ctx.flush();
// }
//
// private Message process(Message request) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, MessageNotUnderstood, InstantiationException {
// Driver driver = driverFactory.getDriver();
//
// Method[] handlerMethods = driver.getClass().getMethods();
//
// for (Method handlerMethod : handlerMethods) {
// Class<?> types[] = handlerMethod.getParameterTypes();
// if (types.length == 1) {
// if (request.getClass() == types[0]) {
// return (Message) handlerMethod.invoke(driver, new Object[] { request });
// }
// }
// }
// throw new MessageNotUnderstood();
// }
//
//
// Message response = null;
//
// @Override
// public void channelRead0(ChannelHandlerContext ctx, Message request) throws Exception {
// if (!(request instanceof ACSResend)) {
// response = process(request);
// } else if (response == null) {
// response = new SCResend();
// }
//
// response.setSequenceCharacter(request.getSequenceCharacter());
//
// ChannelFuture future = ctx.write(response);
// }
//
// @Override
// public void channelReadComplete(ChannelHandlerContext ctx) {
// ctx.flush();
// }
//
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// if (cause instanceof java.io.IOException) {
// logger.debug(cause.getMessage());
// } else {
// logger.error("Transient communications error", cause);
// // cause.printStackTrace();
// try {
// ctx.write(new SCResend().encode(null));
// ctx.flush();
// } catch (Exception e1) {
// logger.error("Transient communications error", e1);
// ctx.close();
// }
// }
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/DriverFactory.java
// public interface DriverFactory {
// Driver getDriver();
// }
| import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslContext;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageDecoder;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageEncoder;
import com.ceridwen.circulation.SIP.netty.server.channel.SIPChannelHandler;
import com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.logging.LogLevel; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.netty.server;
public class SIPServerInitializer extends ChannelInitializer<SocketChannel> {
private final StringDecoder DECODER = new StringDecoder();
private final StringEncoder ENCODER = new StringEncoder();
private SIPMessageDecoder SIPDECODER;
private final SIPMessageEncoder SIPENCODER = new SIPMessageEncoder();
private SIPChannelHandler SERVER_HANDLER;
private final SslContext sslCtx;
private ByteBuf[] getDelimiters() {
return new ByteBuf[] {
Unpooled.wrappedBuffer(new byte[] { '\r', '\n' }),
Unpooled.wrappedBuffer(new byte[] { '\r' }),
Unpooled.wrappedBuffer(new byte[] { '\n' }),
};
}
| // Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageDecoder.java
// @Sharable
// public class SIPMessageDecoder extends MessageToMessageDecoder<String> {
// private boolean strictChecksumChecking = false;
//
// public SIPMessageDecoder() {}
//
// public SIPMessageDecoder(boolean strictChecksumChecking)
// {
// this.strictChecksumChecking = strictChecksumChecking;
// }
//
// @Override
// protected void decode(ChannelHandlerContext ctx, String msg, List<Object> out) throws Exception {
// out.add(Message.decode(msg, null, strictChecksumChecking));
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/codec/SIPMessageEncoder.java
// @Sharable
// public class SIPMessageEncoder extends MessageToMessageEncoder<Message> {
//
// public SIPMessageEncoder() {}
//
// @Override
// protected void encode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
// out.add(msg.encode() + "\r");
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/channel/SIPChannelHandler.java
// @Sharable
// public class SIPChannelHandler extends SimpleChannelInboundHandler<Message> {
// private static Log logger = LogFactory.getLog(SIPChannelHandler.class);
//
// private com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory driverFactory;
//
// public SIPChannelHandler(DriverFactory driverFactory)
// {
// this.driverFactory = driverFactory;
// }
//
// @Override
// public void channelActive(ChannelHandlerContext ctx) throws Exception {
// // ctx.flush();
// }
//
// private Message process(Message request) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, MessageNotUnderstood, InstantiationException {
// Driver driver = driverFactory.getDriver();
//
// Method[] handlerMethods = driver.getClass().getMethods();
//
// for (Method handlerMethod : handlerMethods) {
// Class<?> types[] = handlerMethod.getParameterTypes();
// if (types.length == 1) {
// if (request.getClass() == types[0]) {
// return (Message) handlerMethod.invoke(driver, new Object[] { request });
// }
// }
// }
// throw new MessageNotUnderstood();
// }
//
//
// Message response = null;
//
// @Override
// public void channelRead0(ChannelHandlerContext ctx, Message request) throws Exception {
// if (!(request instanceof ACSResend)) {
// response = process(request);
// } else if (response == null) {
// response = new SCResend();
// }
//
// response.setSequenceCharacter(request.getSequenceCharacter());
//
// ChannelFuture future = ctx.write(response);
// }
//
// @Override
// public void channelReadComplete(ChannelHandlerContext ctx) {
// ctx.flush();
// }
//
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// if (cause instanceof java.io.IOException) {
// logger.debug(cause.getMessage());
// } else {
// logger.error("Transient communications error", cause);
// // cause.printStackTrace();
// try {
// ctx.write(new SCResend().encode(null));
// ctx.flush();
// } catch (Exception e1) {
// logger.error("Transient communications error", e1);
// ctx.close();
// }
// }
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/DriverFactory.java
// public interface DriverFactory {
// Driver getDriver();
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/SIPServerInitializer.java
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslContext;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageDecoder;
import com.ceridwen.circulation.SIP.netty.codec.SIPMessageEncoder;
import com.ceridwen.circulation.SIP.netty.server.channel.SIPChannelHandler;
import com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.logging.LogLevel;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.netty.server;
public class SIPServerInitializer extends ChannelInitializer<SocketChannel> {
private final StringDecoder DECODER = new StringDecoder();
private final StringEncoder ENCODER = new StringEncoder();
private SIPMessageDecoder SIPDECODER;
private final SIPMessageEncoder SIPENCODER = new SIPMessageEncoder();
private SIPChannelHandler SERVER_HANDLER;
private final SslContext sslCtx;
private ByteBuf[] getDelimiters() {
return new ByteBuf[] {
Unpooled.wrappedBuffer(new byte[] { '\r', '\n' }),
Unpooled.wrappedBuffer(new byte[] { '\r' }),
Unpooled.wrappedBuffer(new byte[] { '\n' }),
};
}
| public SIPServerInitializer(DriverFactory driverFactory, boolean strictChecksumChecking, SslContext sslCtx) { |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/annotations/TaggedField.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface TaggedField { | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/annotations/TaggedField.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface TaggedField { | FieldPolicy value() default FieldPolicy.DEFAULT; |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/CheckInResponse.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/MediaType.java
// public enum MediaType implements AbstractEnumeration {
// OTHER("000"),
// BOOK("001"),
// MAGAZINE("002"),
// BOUND_JOURNAL("003"),
// AUDIO_TAPE("004"),
// VIDEO_TAPE("005"),
// CD("006"),
// DISKETTE("007"),
// BOOK_WITH_DISKETTE("008"),
// BOOK_WITH_CD("009"),
// BOOK_WITH_AUDIO_TAPE("010");
//
// private final String code;
//
// private MediaType(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : MediaType.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
| import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.MediaType; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("10")
@TestCaseDefault("100NUN19700101 010000AB|AO|AQ|")
@TestCasePopulated("101YYY19700101 010000AApatronIdentifier|ABitemIdentifier|AFscreenMessage|AGprintLine|AJtitleIdentifier|AOinstitutionId|AQpermanentLocation|CHitemProperties|CK010|CLsortBin|")
public class CheckInResponse extends Message {
private static final long serialVersionUID = -3403534383487215711L;
@PositionedField(start = 2, end = 2)
private Boolean ok;
@PositionedField(start = 3, end = 3)
private Boolean resensitize;
@PositionedField(start = 4, end = 4)
private Boolean magneticMedia;
@PositionedField(start = 5, end = 5)
private Boolean alert;
@PositionedField(start = 6, end = 23)
private Date transactionDate;
@TaggedField
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/MediaType.java
// public enum MediaType implements AbstractEnumeration {
// OTHER("000"),
// BOOK("001"),
// MAGAZINE("002"),
// BOUND_JOURNAL("003"),
// AUDIO_TAPE("004"),
// VIDEO_TAPE("005"),
// CD("006"),
// DISKETTE("007"),
// BOOK_WITH_DISKETTE("008"),
// BOOK_WITH_CD("009"),
// BOOK_WITH_AUDIO_TAPE("010");
//
// private final String code;
//
// private MediaType(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : MediaType.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/CheckInResponse.java
import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.MediaType;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("10")
@TestCaseDefault("100NUN19700101 010000AB|AO|AQ|")
@TestCasePopulated("101YYY19700101 010000AApatronIdentifier|ABitemIdentifier|AFscreenMessage|AGprintLine|AJtitleIdentifier|AOinstitutionId|AQpermanentLocation|CHitemProperties|CK010|CLsortBin|")
public class CheckInResponse extends Message {
private static final long serialVersionUID = -3403534383487215711L;
@PositionedField(start = 2, end = 2)
private Boolean ok;
@PositionedField(start = 3, end = 3)
private Boolean resensitize;
@PositionedField(start = 4, end = 4)
private Boolean magneticMedia;
@PositionedField(start = 5, end = 5)
private Boolean alert;
@PositionedField(start = 6, end = 23)
private Date transactionDate;
@TaggedField
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/CheckInResponse.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/MediaType.java
// public enum MediaType implements AbstractEnumeration {
// OTHER("000"),
// BOOK("001"),
// MAGAZINE("002"),
// BOUND_JOURNAL("003"),
// AUDIO_TAPE("004"),
// VIDEO_TAPE("005"),
// CD("006"),
// DISKETTE("007"),
// BOOK_WITH_DISKETTE("008"),
// BOOK_WITH_CD("009"),
// BOOK_WITH_AUDIO_TAPE("010");
//
// private final String code;
//
// private MediaType(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : MediaType.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
| import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.MediaType; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("10")
@TestCaseDefault("100NUN19700101 010000AB|AO|AQ|")
@TestCasePopulated("101YYY19700101 010000AApatronIdentifier|ABitemIdentifier|AFscreenMessage|AGprintLine|AJtitleIdentifier|AOinstitutionId|AQpermanentLocation|CHitemProperties|CK010|CLsortBin|")
public class CheckInResponse extends Message {
private static final long serialVersionUID = -3403534383487215711L;
@PositionedField(start = 2, end = 2)
private Boolean ok;
@PositionedField(start = 3, end = 3)
private Boolean resensitize;
@PositionedField(start = 4, end = 4)
private Boolean magneticMedia;
@PositionedField(start = 5, end = 5)
private Boolean alert;
@PositionedField(start = 6, end = 23)
private Date transactionDate;
@TaggedField
private String institutionId;
@TaggedField(FieldPolicy.REQUIRED)
private String itemIdentifier;
@TaggedField(FieldPolicy.REQUIRED)
private String permanentLocation;
@TaggedField(FieldPolicy.NOT_REQUIRED)
private String titleIdentifier;
@TaggedField
private String sortBin;
@TaggedField(FieldPolicy.NOT_REQUIRED)
private String patronIdentifier;
@TaggedField | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/MediaType.java
// public enum MediaType implements AbstractEnumeration {
// OTHER("000"),
// BOOK("001"),
// MAGAZINE("002"),
// BOUND_JOURNAL("003"),
// AUDIO_TAPE("004"),
// VIDEO_TAPE("005"),
// CD("006"),
// DISKETTE("007"),
// BOOK_WITH_DISKETTE("008"),
// BOOK_WITH_CD("009"),
// BOOK_WITH_AUDIO_TAPE("010");
//
// private final String code;
//
// private MediaType(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : MediaType.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/CheckInResponse.java
import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.MediaType;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("10")
@TestCaseDefault("100NUN19700101 010000AB|AO|AQ|")
@TestCasePopulated("101YYY19700101 010000AApatronIdentifier|ABitemIdentifier|AFscreenMessage|AGprintLine|AJtitleIdentifier|AOinstitutionId|AQpermanentLocation|CHitemProperties|CK010|CLsortBin|")
public class CheckInResponse extends Message {
private static final long serialVersionUID = -3403534383487215711L;
@PositionedField(start = 2, end = 2)
private Boolean ok;
@PositionedField(start = 3, end = 3)
private Boolean resensitize;
@PositionedField(start = 4, end = 4)
private Boolean magneticMedia;
@PositionedField(start = 5, end = 5)
private Boolean alert;
@PositionedField(start = 6, end = 23)
private Date transactionDate;
@TaggedField
private String institutionId;
@TaggedField(FieldPolicy.REQUIRED)
private String itemIdentifier;
@TaggedField(FieldPolicy.REQUIRED)
private String permanentLocation;
@TaggedField(FieldPolicy.NOT_REQUIRED)
private String titleIdentifier;
@TaggedField
private String sortBin;
@TaggedField(FieldPolicy.NOT_REQUIRED)
private String patronIdentifier;
@TaggedField | private MediaType mediaType; |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/FeePaidResponse.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("38")
@TestCaseDefault("38N19700101 010000AA|AO|")
@TestCasePopulated("38Y19700101 010000AApatronIdentifier|AFscreenMessage|AGprintLine|AOinstitutionId|BKtransactionId|")
public class FeePaidResponse extends Message {
private static final long serialVersionUID = 3684506970071368895L;
@PositionedField(start = 2, end = 2)
private Boolean paymentAccepted;
@PositionedField(start = 3, end = 20)
private java.util.Date transactionDate;
@TaggedField
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/FeePaidResponse.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("38")
@TestCaseDefault("38N19700101 010000AA|AO|")
@TestCasePopulated("38Y19700101 010000AApatronIdentifier|AFscreenMessage|AGprintLine|AOinstitutionId|BKtransactionId|")
public class FeePaidResponse extends Message {
private static final long serialVersionUID = 3684506970071368895L;
@PositionedField(start = 2, end = 2)
private Boolean paymentAccepted;
@PositionedField(start = 3, end = 20)
private java.util.Date transactionDate;
@TaggedField
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/PatronStatusRequest.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/Language.java
// public enum Language implements AbstractEnumeration {
// UNKNOWN("000"),
// ENGLISH("001"),
// FRENCH("002"),
// GERMAN("003"),
// ITALIAN("004"),
// DUTCH("005"),
// SWEDISH("006"),
// FINNISH("007"),
// SPANISH("008"),
// DANISH("009"),
// PORTUGUESE("010"),
// CANADIAN_FRENCH("011"),
// NORWEGIAN("012"),
// HEBREW("013"),
// JAPANESE("014"),
// RUSSIAN("015"),
// ARABIC("016"),
// POLISH("017"),
// GREEK("018"),
// CHINESE("019"),
// KOREAN("020"),
// NORTH_AMERICAN_SPANISH("021"),
// TAMIL("022"),
// MALAY("023"),
// UNITED_KINGDOM("024"),
// ICELANDIC("025"),
// BELGIAN("026"),
// TAIWANESE("027");
//
// private final String code;
//
// private Language(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : Language.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
| import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.Language; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("23")
@TestCaseDefault("2300019700101 010000AA|AC|AD|AO|")
@TestCasePopulated("2302719700101 010000AApatronIdentifier|ACterminalPassword|ADpatronPassword|AOinstitutionId|")
public class PatronStatusRequest extends Message {
private static final long serialVersionUID = -4867507215519281871L;
@PositionedField(start = 2, end = 4) | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/Language.java
// public enum Language implements AbstractEnumeration {
// UNKNOWN("000"),
// ENGLISH("001"),
// FRENCH("002"),
// GERMAN("003"),
// ITALIAN("004"),
// DUTCH("005"),
// SWEDISH("006"),
// FINNISH("007"),
// SPANISH("008"),
// DANISH("009"),
// PORTUGUESE("010"),
// CANADIAN_FRENCH("011"),
// NORWEGIAN("012"),
// HEBREW("013"),
// JAPANESE("014"),
// RUSSIAN("015"),
// ARABIC("016"),
// POLISH("017"),
// GREEK("018"),
// CHINESE("019"),
// KOREAN("020"),
// NORTH_AMERICAN_SPANISH("021"),
// TAMIL("022"),
// MALAY("023"),
// UNITED_KINGDOM("024"),
// ICELANDIC("025"),
// BELGIAN("026"),
// TAIWANESE("027");
//
// private final String code;
//
// private Language(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : Language.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/PatronStatusRequest.java
import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.Language;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("23")
@TestCaseDefault("2300019700101 010000AA|AC|AD|AO|")
@TestCasePopulated("2302719700101 010000AApatronIdentifier|ACterminalPassword|ADpatronPassword|AOinstitutionId|")
public class PatronStatusRequest extends Message {
private static final long serialVersionUID = -4867507215519281871L;
@PositionedField(start = 2, end = 4) | private Language language; |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/PatronStatusRequest.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/Language.java
// public enum Language implements AbstractEnumeration {
// UNKNOWN("000"),
// ENGLISH("001"),
// FRENCH("002"),
// GERMAN("003"),
// ITALIAN("004"),
// DUTCH("005"),
// SWEDISH("006"),
// FINNISH("007"),
// SPANISH("008"),
// DANISH("009"),
// PORTUGUESE("010"),
// CANADIAN_FRENCH("011"),
// NORWEGIAN("012"),
// HEBREW("013"),
// JAPANESE("014"),
// RUSSIAN("015"),
// ARABIC("016"),
// POLISH("017"),
// GREEK("018"),
// CHINESE("019"),
// KOREAN("020"),
// NORTH_AMERICAN_SPANISH("021"),
// TAMIL("022"),
// MALAY("023"),
// UNITED_KINGDOM("024"),
// ICELANDIC("025"),
// BELGIAN("026"),
// TAIWANESE("027");
//
// private final String code;
//
// private Language(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : Language.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
| import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.Language; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("23")
@TestCaseDefault("2300019700101 010000AA|AC|AD|AO|")
@TestCasePopulated("2302719700101 010000AApatronIdentifier|ACterminalPassword|ADpatronPassword|AOinstitutionId|")
public class PatronStatusRequest extends Message {
private static final long serialVersionUID = -4867507215519281871L;
@PositionedField(start = 2, end = 4)
private Language language;
@PositionedField(start = 5, end = 22)
private Date transactionDate;
@TaggedField
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/Language.java
// public enum Language implements AbstractEnumeration {
// UNKNOWN("000"),
// ENGLISH("001"),
// FRENCH("002"),
// GERMAN("003"),
// ITALIAN("004"),
// DUTCH("005"),
// SWEDISH("006"),
// FINNISH("007"),
// SPANISH("008"),
// DANISH("009"),
// PORTUGUESE("010"),
// CANADIAN_FRENCH("011"),
// NORWEGIAN("012"),
// HEBREW("013"),
// JAPANESE("014"),
// RUSSIAN("015"),
// ARABIC("016"),
// POLISH("017"),
// GREEK("018"),
// CHINESE("019"),
// KOREAN("020"),
// NORTH_AMERICAN_SPANISH("021"),
// TAMIL("022"),
// MALAY("023"),
// UNITED_KINGDOM("024"),
// ICELANDIC("025"),
// BELGIAN("026"),
// TAIWANESE("027");
//
// private final String code;
//
// private Language(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : Language.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/PatronStatusRequest.java
import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.Language;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("23")
@TestCaseDefault("2300019700101 010000AA|AC|AD|AO|")
@TestCasePopulated("2302719700101 010000AApatronIdentifier|ACterminalPassword|ADpatronPassword|AOinstitutionId|")
public class PatronStatusRequest extends Message {
private static final long serialVersionUID = -4867507215519281871L;
@PositionedField(start = 2, end = 4)
private Language language;
@PositionedField(start = 5, end = 22)
private Date transactionDate;
@TaggedField
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/HoldResponse.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("16")
@TestCaseDefault("160N19700101 010000AA|AO|")
@TestCasePopulated("161Y19700101 010000AApatronIdentifier|ABitemIdentifier|AFscreenMessage|AGprintLine|AJtitleIdentifier|AOinstitutionId|BR123456789|BSpickupLocation|BW19700101 010000|")
public class HoldResponse extends Message {
private static final long serialVersionUID = 2267131763722749419L;
@PositionedField(start = 2, end = 2)
private Boolean ok;
@PositionedField(start = 3, end = 3)
private Boolean available;
@PositionedField(start = 4, end = 21)
private java.util.Date transactionDate;
@TaggedField
private java.util.Date expirationDate;
@TaggedField
private Integer queuePosition;
@TaggedField
private String pickupLocation;
@TaggedField
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/HoldResponse.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("16")
@TestCaseDefault("160N19700101 010000AA|AO|")
@TestCasePopulated("161Y19700101 010000AApatronIdentifier|ABitemIdentifier|AFscreenMessage|AGprintLine|AJtitleIdentifier|AOinstitutionId|BR123456789|BSpickupLocation|BW19700101 010000|")
public class HoldResponse extends Message {
private static final long serialVersionUID = 2267131763722749419L;
@PositionedField(start = 2, end = 2)
private Boolean ok;
@PositionedField(start = 3, end = 3)
private Boolean available;
@PositionedField(start = 4, end = 21)
private java.util.Date transactionDate;
@TaggedField
private java.util.Date expirationDate;
@TaggedField
private Integer queuePosition;
@TaggedField
private String pickupLocation;
@TaggedField
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/SCStatus.java | // Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/ProtocolVersion.java
// public enum ProtocolVersion implements AbstractEnumeration {
// VERSION_2_00("2.00"),
// VERSION_1_00("1.00");
//
// private final String code;
//
// private ProtocolVersion(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : ProtocolVersion.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/StatusCode.java
// public enum StatusCode implements AbstractEnumeration {
// OK("0"),
// OUT_OF_PAPER("1"),
// SHUTTING_DOWN("2");
//
// private final String code;
//
// private StatusCode(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : StatusCode.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.types.enumerations.ProtocolVersion;
import com.ceridwen.circulation.SIP.types.enumerations.StatusCode; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("99")
@TestCaseDefault("9900002.00")
@TestCasePopulated("9921231.00")
public class SCStatus extends Message {
private static final long serialVersionUID = -6198644705404364776L;
@PositionedField(start = 2, end = 2) | // Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/ProtocolVersion.java
// public enum ProtocolVersion implements AbstractEnumeration {
// VERSION_2_00("2.00"),
// VERSION_1_00("1.00");
//
// private final String code;
//
// private ProtocolVersion(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : ProtocolVersion.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/StatusCode.java
// public enum StatusCode implements AbstractEnumeration {
// OK("0"),
// OUT_OF_PAPER("1"),
// SHUTTING_DOWN("2");
//
// private final String code;
//
// private StatusCode(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : StatusCode.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/SCStatus.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.types.enumerations.ProtocolVersion;
import com.ceridwen.circulation.SIP.types.enumerations.StatusCode;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("99")
@TestCaseDefault("9900002.00")
@TestCasePopulated("9921231.00")
public class SCStatus extends Message {
private static final long serialVersionUID = -6198644705404364776L;
@PositionedField(start = 2, end = 2) | private StatusCode statusCode; |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/SCStatus.java | // Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/ProtocolVersion.java
// public enum ProtocolVersion implements AbstractEnumeration {
// VERSION_2_00("2.00"),
// VERSION_1_00("1.00");
//
// private final String code;
//
// private ProtocolVersion(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : ProtocolVersion.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/StatusCode.java
// public enum StatusCode implements AbstractEnumeration {
// OK("0"),
// OUT_OF_PAPER("1"),
// SHUTTING_DOWN("2");
//
// private final String code;
//
// private StatusCode(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : StatusCode.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.types.enumerations.ProtocolVersion;
import com.ceridwen.circulation.SIP.types.enumerations.StatusCode; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("99")
@TestCaseDefault("9900002.00")
@TestCasePopulated("9921231.00")
public class SCStatus extends Message {
private static final long serialVersionUID = -6198644705404364776L;
@PositionedField(start = 2, end = 2)
private StatusCode statusCode;
@PositionedField(start = 3, end = 5)
private Integer maxPrintWidth;
@PositionedField(start = 6, end = 9) | // Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/ProtocolVersion.java
// public enum ProtocolVersion implements AbstractEnumeration {
// VERSION_2_00("2.00"),
// VERSION_1_00("1.00");
//
// private final String code;
//
// private ProtocolVersion(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : ProtocolVersion.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/StatusCode.java
// public enum StatusCode implements AbstractEnumeration {
// OK("0"),
// OUT_OF_PAPER("1"),
// SHUTTING_DOWN("2");
//
// private final String code;
//
// private StatusCode(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : StatusCode.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/SCStatus.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.types.enumerations.ProtocolVersion;
import com.ceridwen.circulation.SIP.types.enumerations.StatusCode;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("99")
@TestCaseDefault("9900002.00")
@TestCasePopulated("9921231.00")
public class SCStatus extends Message {
private static final long serialVersionUID = -6198644705404364776L;
@PositionedField(start = 2, end = 2)
private StatusCode statusCode;
@PositionedField(start = 3, end = 5)
private Integer maxPrintWidth;
@PositionedField(start = 6, end = 9) | private ProtocolVersion protocolVersion; |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/ItemInformation.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("17")
@TestCaseDefault("1719700101 010000AB|AO|")
@TestCasePopulated("1719700101 010000ABitemIdentifier|ACterminalPassword|AOinstitutionId|")
public class ItemInformation extends Message {
private static final long serialVersionUID = 7398126890693645623L;
@PositionedField(start = 2, end = 19)
private Date transactionDate;
@TaggedField
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/ItemInformation.java
import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("17")
@TestCaseDefault("1719700101 010000AB|AO|")
@TestCasePopulated("1719700101 010000ABitemIdentifier|ACterminalPassword|AOinstitutionId|")
public class ItemInformation extends Message {
private static final long serialVersionUID = 7398126890693645623L;
@PositionedField(start = 2, end = 19)
private Date transactionDate;
@TaggedField
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/ItemStatusUpdate.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("19")
@TestCaseDefault("1919700101 010000AB|AO|CH|")
@TestCasePopulated("1919700101 010000ABitemIdentifier|ACterminalPassword|AOinstitutionId|CHitemProperties|")
public class ItemStatusUpdate extends Message {
private static final long serialVersionUID = -2127793191374183987L;
@PositionedField(start = 2, end = 19)
private java.util.Date transactionDate;
@TaggedField
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/ItemStatusUpdate.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("19")
@TestCaseDefault("1919700101 010000AB|AO|CH|")
@TestCasePopulated("1919700101 010000ABitemIdentifier|ACterminalPassword|AOinstitutionId|CHitemProperties|")
public class ItemStatusUpdate extends Message {
private static final long serialVersionUID = -2127793191374183987L;
@PositionedField(start = 2, end = 19)
private java.util.Date transactionDate;
@TaggedField
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/Hold.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/HoldMode.java
// public enum HoldMode implements AbstractEnumeration {
// CHANGE("*"),
// ADD("+"),
// DELETE("-");
//
// private final String code;
//
// private HoldMode(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : HoldMode.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/HoldType.java
// public enum HoldType implements AbstractEnumeration {
// OTHER("1"),
// ANY_COPY("2"),
// SPECIFIC_COPY("3"),
// SUBLOCATION_COPY("4");
//
// private final String code;
//
// private HoldType(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : HoldType.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.HoldMode;
import com.ceridwen.circulation.SIP.types.enumerations.HoldType; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("15")
@TestCaseDefault("15*19700101 010000AA|AO|")
@TestCasePopulated("15-19700101 010000AApatronIdentifier|ABitemIdentifier|ACterminalPassword|ADpatronPassword|AJtitleIdentifier|AOinstitutionId|BOY|BSpickupLocation|BW19700101 010000|BY4|")
public class Hold extends Message {
private static final long serialVersionUID = -6526613321625525740L;
@PositionedField(start = 2, end = 2) | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/HoldMode.java
// public enum HoldMode implements AbstractEnumeration {
// CHANGE("*"),
// ADD("+"),
// DELETE("-");
//
// private final String code;
//
// private HoldMode(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : HoldMode.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/HoldType.java
// public enum HoldType implements AbstractEnumeration {
// OTHER("1"),
// ANY_COPY("2"),
// SPECIFIC_COPY("3"),
// SUBLOCATION_COPY("4");
//
// private final String code;
//
// private HoldType(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : HoldType.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/Hold.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.HoldMode;
import com.ceridwen.circulation.SIP.types.enumerations.HoldType;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("15")
@TestCaseDefault("15*19700101 010000AA|AO|")
@TestCasePopulated("15-19700101 010000AApatronIdentifier|ABitemIdentifier|ACterminalPassword|ADpatronPassword|AJtitleIdentifier|AOinstitutionId|BOY|BSpickupLocation|BW19700101 010000|BY4|")
public class Hold extends Message {
private static final long serialVersionUID = -6526613321625525740L;
@PositionedField(start = 2, end = 2) | private HoldMode holdMode; |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/Hold.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/HoldMode.java
// public enum HoldMode implements AbstractEnumeration {
// CHANGE("*"),
// ADD("+"),
// DELETE("-");
//
// private final String code;
//
// private HoldMode(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : HoldMode.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/HoldType.java
// public enum HoldType implements AbstractEnumeration {
// OTHER("1"),
// ANY_COPY("2"),
// SPECIFIC_COPY("3"),
// SUBLOCATION_COPY("4");
//
// private final String code;
//
// private HoldType(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : HoldType.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.HoldMode;
import com.ceridwen.circulation.SIP.types.enumerations.HoldType; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("15")
@TestCaseDefault("15*19700101 010000AA|AO|")
@TestCasePopulated("15-19700101 010000AApatronIdentifier|ABitemIdentifier|ACterminalPassword|ADpatronPassword|AJtitleIdentifier|AOinstitutionId|BOY|BSpickupLocation|BW19700101 010000|BY4|")
public class Hold extends Message {
private static final long serialVersionUID = -6526613321625525740L;
@PositionedField(start = 2, end = 2)
private HoldMode holdMode;
@PositionedField(start = 3, end = 20)
private java.util.Date transactionDate;
@TaggedField
private java.util.Date expirationDate;
@TaggedField
private String pickupLocation;
@TaggedField | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/HoldMode.java
// public enum HoldMode implements AbstractEnumeration {
// CHANGE("*"),
// ADD("+"),
// DELETE("-");
//
// private final String code;
//
// private HoldMode(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : HoldMode.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/HoldType.java
// public enum HoldType implements AbstractEnumeration {
// OTHER("1"),
// ANY_COPY("2"),
// SPECIFIC_COPY("3"),
// SUBLOCATION_COPY("4");
//
// private final String code;
//
// private HoldType(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : HoldType.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/Hold.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.HoldMode;
import com.ceridwen.circulation.SIP.types.enumerations.HoldType;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("15")
@TestCaseDefault("15*19700101 010000AA|AO|")
@TestCasePopulated("15-19700101 010000AApatronIdentifier|ABitemIdentifier|ACterminalPassword|ADpatronPassword|AJtitleIdentifier|AOinstitutionId|BOY|BSpickupLocation|BW19700101 010000|BY4|")
public class Hold extends Message {
private static final long serialVersionUID = -6526613321625525740L;
@PositionedField(start = 2, end = 2)
private HoldMode holdMode;
@PositionedField(start = 3, end = 20)
private java.util.Date transactionDate;
@TaggedField
private java.util.Date expirationDate;
@TaggedField
private String pickupLocation;
@TaggedField | private HoldType holdType; |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/Hold.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/HoldMode.java
// public enum HoldMode implements AbstractEnumeration {
// CHANGE("*"),
// ADD("+"),
// DELETE("-");
//
// private final String code;
//
// private HoldMode(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : HoldMode.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/HoldType.java
// public enum HoldType implements AbstractEnumeration {
// OTHER("1"),
// ANY_COPY("2"),
// SPECIFIC_COPY("3"),
// SUBLOCATION_COPY("4");
//
// private final String code;
//
// private HoldType(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : HoldType.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.HoldMode;
import com.ceridwen.circulation.SIP.types.enumerations.HoldType; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("15")
@TestCaseDefault("15*19700101 010000AA|AO|")
@TestCasePopulated("15-19700101 010000AApatronIdentifier|ABitemIdentifier|ACterminalPassword|ADpatronPassword|AJtitleIdentifier|AOinstitutionId|BOY|BSpickupLocation|BW19700101 010000|BY4|")
public class Hold extends Message {
private static final long serialVersionUID = -6526613321625525740L;
@PositionedField(start = 2, end = 2)
private HoldMode holdMode;
@PositionedField(start = 3, end = 20)
private java.util.Date transactionDate;
@TaggedField
private java.util.Date expirationDate;
@TaggedField
private String pickupLocation;
@TaggedField
private HoldType holdType;
@TaggedField
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/HoldMode.java
// public enum HoldMode implements AbstractEnumeration {
// CHANGE("*"),
// ADD("+"),
// DELETE("-");
//
// private final String code;
//
// private HoldMode(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : HoldMode.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/types/enumerations/HoldType.java
// public enum HoldType implements AbstractEnumeration {
// OTHER("1"),
// ANY_COPY("2"),
// SPECIFIC_COPY("3"),
// SUBLOCATION_COPY("4");
//
// private final String code;
//
// private HoldType(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return this.getCode();
// }
//
// @Override
// public final String getCode() {
// return this.code;
// }
//
// @Override
// public final AbstractEnumeration getKey(String code) {
// for (AbstractEnumeration i : HoldType.values()) {
// if (i.getCode().equals(code)) {
// return i;
// }
// }
// return null;
// }
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/Hold.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
import com.ceridwen.circulation.SIP.types.enumerations.HoldMode;
import com.ceridwen.circulation.SIP.types.enumerations.HoldType;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("15")
@TestCaseDefault("15*19700101 010000AA|AO|")
@TestCasePopulated("15-19700101 010000AApatronIdentifier|ABitemIdentifier|ACterminalPassword|ADpatronPassword|AJtitleIdentifier|AOinstitutionId|BOY|BSpickupLocation|BW19700101 010000|BY4|")
public class Hold extends Message {
private static final long serialVersionUID = -6526613321625525740L;
@PositionedField(start = 2, end = 2)
private HoldMode holdMode;
@PositionedField(start = 3, end = 20)
private java.util.Date transactionDate;
@TaggedField
private java.util.Date expirationDate;
@TaggedField
private String pickupLocation;
@TaggedField
private HoldType holdType;
@TaggedField
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/CheckOut.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("11")
@TestCaseDefault("11NN19700101 010000 AA|AB|AC|AO|")
@TestCasePopulated("11YY19700101 01000019700101 010000AApatronIdentifier|ABitemIdentifier|ACterminalPassword|ADpatronPassword|AOinstitutionId|BIY|BOY|CHitemProperties|")
public class CheckOut extends Message {
private static final long serialVersionUID = 8454866593857815453L;
@PositionedField(start = 2, end = 2)
private Boolean SCRenewalPolicy;
@PositionedField(start = 3, end = 3)
private Boolean noBlock;
@PositionedField(start = 4, end = 21)
private Date transactionDate;
@PositionedField(start = 22, end = 39)
private Date nbDueDate;
@TaggedField
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/CheckOut.java
import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("11")
@TestCaseDefault("11NN19700101 010000 AA|AB|AC|AO|")
@TestCasePopulated("11YY19700101 01000019700101 010000AApatronIdentifier|ABitemIdentifier|ACterminalPassword|ADpatronPassword|AOinstitutionId|BIY|BOY|CHitemProperties|")
public class CheckOut extends Message {
private static final long serialVersionUID = 8454866593857815453L;
@PositionedField(start = 2, end = 2)
private Boolean SCRenewalPolicy;
@PositionedField(start = 3, end = 3)
private Boolean noBlock;
@PositionedField(start = 4, end = 21)
private Date transactionDate;
@PositionedField(start = 22, end = 39)
private Date nbDueDate;
@TaggedField
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/RenewAll.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("65")
@TestCaseDefault("6519700101 010000AA|AO|")
@TestCasePopulated("6519700101 010000AApatronIdentifier|ACterminalPassword|ADpatronPassword|AOinstitutionId|BOY|")
public class RenewAll extends Message {
private static final long serialVersionUID = -7106820916482094784L;
@PositionedField(start = 2, end = 19)
private java.util.Date transactionDate;
@TaggedField
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/RenewAll.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("65")
@TestCaseDefault("6519700101 010000AA|AO|")
@TestCasePopulated("6519700101 010000AApatronIdentifier|ACterminalPassword|ADpatronPassword|AOinstitutionId|BOY|")
public class RenewAll extends Message {
private static final long serialVersionUID = -7106820916482094784L;
@PositionedField(start = 2, end = 19)
private java.util.Date transactionDate;
@TaggedField
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/netty/server/SIPDaemon.java | // Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/DriverFactory.java
// public interface DriverFactory {
// Driver getDriver();
// }
| import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.util.concurrent.GenericFutureListener;
import io.netty.util.internal.StringUtil;
import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.netty.server;
public class SIPDaemon implements GenericFutureListener<ChannelFuture> {
private static final Log log = LogFactory.getLog(SIPDaemon.class);
private final String name;
private final String ip;
private final int port;
private final File keyCertChainFile;
private final File keyFile;
private final String keyPassword; | // Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/DriverFactory.java
// public interface DriverFactory {
// Driver getDriver();
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/SIPDaemon.java
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.util.concurrent.GenericFutureListener;
import io.netty.util.internal.StringUtil;
import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.netty.server;
public class SIPDaemon implements GenericFutureListener<ChannelFuture> {
private static final Log log = LogFactory.getLog(SIPDaemon.class);
private final String name;
private final String ip;
private final int port;
private final File keyCertChainFile;
private final File keyFile;
private final String keyPassword; | private final DriverFactory driverFactory; |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/EndSessionResponse.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("36")
@TestCaseDefault("36N19700101 010000AA|AO|")
@TestCasePopulated("36Y19700101 010000AApatronIdentifier|AFscreenMessage|AGprintLine|AOinstitutionId|")
public class EndSessionResponse extends Message {
private static final long serialVersionUID = 8955079727656656773L;
@PositionedField(start = 2, end = 2)
private Boolean endSession;
@PositionedField(start = 3, end = 20)
private Date transactionDate;
@TaggedField
private String institutionId; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/EndSessionResponse.java
import java.util.Date;
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("36")
@TestCaseDefault("36N19700101 010000AA|AO|")
@TestCasePopulated("36Y19700101 010000AApatronIdentifier|AFscreenMessage|AGprintLine|AOinstitutionId|")
public class EndSessionResponse extends Message {
private static final long serialVersionUID = 8955079727656656773L;
@PositionedField(start = 2, end = 2)
private Boolean endSession;
@PositionedField(start = 3, end = 20)
private Date transactionDate;
@TaggedField
private String institutionId; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/messages/BlockPatron.java | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
| import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("01")
@TestCaseDefault("01N19700101 010000AA|AC|AL|AO|")
@TestCasePopulated("01Y19700101 010000AApatronIdentifier|ACterminalPassword|ALblockedCardMessage|AOinstitutionId|")
public class BlockPatron extends Message {
private static final long serialVersionUID = 7336173091305475737L;
@PositionedField(start = 2, end = 2)
private Boolean cardRetained;
@PositionedField(start = 3, end = 20)
private java.util.Date transactionDate;
@TaggedField
private String institutionId;
@TaggedField
private String blockedCardMessage; | // Path: src/main/java/com/ceridwen/circulation/SIP/fields/FieldPolicy.java
// public enum FieldPolicy {
// REQUIRED,
// NOT_REQUIRED,
// DEFAULT;
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/messages/BlockPatron.java
import com.ceridwen.circulation.SIP.annotations.Command;
import com.ceridwen.circulation.SIP.annotations.PositionedField;
import com.ceridwen.circulation.SIP.annotations.TaggedField;
import com.ceridwen.circulation.SIP.annotations.TestCaseDefault;
import com.ceridwen.circulation.SIP.annotations.TestCasePopulated;
import com.ceridwen.circulation.SIP.fields.FieldPolicy;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.messages;
@Command("01")
@TestCaseDefault("01N19700101 010000AA|AC|AL|AO|")
@TestCasePopulated("01Y19700101 010000AApatronIdentifier|ACterminalPassword|ALblockedCardMessage|AOinstitutionId|")
public class BlockPatron extends Message {
private static final long serialVersionUID = 7336173091305475737L;
@PositionedField(start = 2, end = 2)
private Boolean cardRetained;
@PositionedField(start = 3, end = 20)
private java.util.Date transactionDate;
@TaggedField
private String institutionId;
@TaggedField
private String blockedCardMessage; | @TaggedField(FieldPolicy.REQUIRED) |
ceridwen-com/ceridwen-standard-interchange-protocol-library | src/main/java/com/ceridwen/circulation/SIP/samples/netty/DummyDriverFactory.java | // Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/Driver.java
// public interface Driver extends RequestResendOperation, StatusOperation {
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/DriverFactory.java
// public interface DriverFactory {
// Driver getDriver();
// }
| import com.ceridwen.circulation.SIP.netty.server.driver.Driver;
import com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory; | /*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.samples.netty;
/**
*
* @author Matthew
*/
public class DummyDriverFactory implements DriverFactory {
@Override | // Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/Driver.java
// public interface Driver extends RequestResendOperation, StatusOperation {
// }
//
// Path: src/main/java/com/ceridwen/circulation/SIP/netty/server/driver/DriverFactory.java
// public interface DriverFactory {
// Driver getDriver();
// }
// Path: src/main/java/com/ceridwen/circulation/SIP/samples/netty/DummyDriverFactory.java
import com.ceridwen.circulation.SIP.netty.server.driver.Driver;
import com.ceridwen.circulation.SIP.netty.server.driver.DriverFactory;
/*
* Copyright (C) 2020 Ceridwen Limited
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package com.ceridwen.circulation.SIP.samples.netty;
/**
*
* @author Matthew
*/
public class DummyDriverFactory implements DriverFactory {
@Override | public Driver getDriver() { |
hugmanrique/PokeData | src/test/java/BitRangeTest.java | // Path: src/main/java/me/hugmanrique/pokedata/utils/BitConverter.java
// public class BitConverter {
// protected BitConverter() {}
//
// public static long toInt32(byte[] bytes) {
// // AB CD EF 08 -> 08EFCDAB
// return (long) ((bytes[0] & 0xFF) + ((bytes[1] & 0xFF) << 8) + ((bytes[2] & 0xFF) << 16) + ((bytes[3] & 0xFF) << 24));
// }
//
// public static int shortenPointer(long pointer) {
// return (int)(pointer & 0x1FFFFFF);
// }
//
// public static byte[] getBytes(long i) {
// return new byte[] {
// (byte)((i & 0xFF000000) >> 24),
// (byte)((i & 0x00FF0000) >> 16),
// (byte)((i & 0x0000FF00) >> 8),
// (byte)((i & 0x000000FF))
// };
// }
//
// public static int[] getInts(long i) {
// return new int[] {
// (int)((i & 0xFF000000) >> 24),
// (int)((i & 0x00FF0000) >> 16),
// (int)((i & 0x0000FF00) >> 8),
// (int)((i & 0x000000FF))
// };
// }
//
// public static byte[] reverseBytes(byte[] bytes) {
// byte[] result = new byte[bytes.length];
//
// for (int i = 0; i < bytes.length; i++) {
// result[i] = bytes[bytes.length - 1 - i];
// }
//
// return result;
// }
//
// public static byte[] getBytes(byte[] array, int offset, int length) {
// byte[] result = new byte[length];
//
// for (int i = 0; i < length; i++) {
// try {
// result[i] = array[offset + i];
// } catch (ArrayIndexOutOfBoundsException e) {
// String message = String.format("Tried to read outside of bounds (%05X, %s)", offset, i);
//
// System.out.println(message);
// }
// }
//
// return result;
// }
//
// public static int[] grabBytesAsInts(byte[] array, int offset, int length) {
// if (length > array.length) {
// length = array.length;
// }
//
// int[] result = new int[length];
//
// for (int i = 0; i < length; i++) {
// result[i] = (array[offset + i] & 0xFF);
// }
//
// return result;
// }
//
// public static byte[] putBytes(byte[] array, byte[] toPut, int offset) {
// for (int i = 0; i < toPut.length; i++) {
// array[offset + i] = toPut[i];
// }
//
// return array;
// }
//
// public static int[] toInts(byte[] array) {
// return grabBytesAsInts(array, 0, array.length);
// }
//
// public static String toHexString(int loc) {
// return toHexString(loc, false);
// }
//
// // Use absolute value to prevent negative bytes
//
// public static String toHexString(int loc, boolean spacing) {
// if (spacing) {
// return String.format("%02X", Math.abs(loc));
// } else {
// return String.format("%X", Math.abs(loc));
// }
// }
//
// public static String toDwordString(int b, boolean spacing) {
// if (spacing) {
// return String.format("%06X", Math.abs(b));
// } else {
// return String.format("%X", Math.abs(b));
// }
// }
//
// public static String byteToStringNoZero(int b) {
// if(b != 0) {
// return String.format("%X", Math.abs(b));
// } else {
// return "";
// }
// }
//
//
// public static byte[] toBytes(int[] data) {
// byte[] result = new byte[data.length];
//
// for (int i = 0; i < result.length; i++) {
// result[i] = (byte)(data[i]);
// }
//
// return result;
// }
//
// public static boolean zeroedOut(int... words) {
// for (int i : words) {
// if (i != 0) {
// return false;
// }
// }
//
// return true;
// }
//
// public static boolean isBitSet(byte value, int index) {
// return (value & (1 << index)) != 0;
// }
//
// /**
// * Left-to-right bit range of 2 bytes
// * @param from The bits from 0 (left)
// * @param to The bits from 0 (left)
// */
// public static int getBitRange(int value, int from, int to) {
// int fromA = 16 - to;
// to = 16 - from;
//
// from = fromA;
//
// int bits = to - from;
// int rightShifted = value >>> from;
// int mask = (1 << bits) - 1;
//
// return rightShifted & mask;
// }
// }
| import me.hugmanrique.pokedata.utils.BitConverter;
import org.junit.Test;
import static org.junit.Assert.assertEquals; |
/**
* @author Hugmanrique
* @since 28/05/2017
*/
public class BitRangeTest {
@Test
public void test16BitRanges() { | // Path: src/main/java/me/hugmanrique/pokedata/utils/BitConverter.java
// public class BitConverter {
// protected BitConverter() {}
//
// public static long toInt32(byte[] bytes) {
// // AB CD EF 08 -> 08EFCDAB
// return (long) ((bytes[0] & 0xFF) + ((bytes[1] & 0xFF) << 8) + ((bytes[2] & 0xFF) << 16) + ((bytes[3] & 0xFF) << 24));
// }
//
// public static int shortenPointer(long pointer) {
// return (int)(pointer & 0x1FFFFFF);
// }
//
// public static byte[] getBytes(long i) {
// return new byte[] {
// (byte)((i & 0xFF000000) >> 24),
// (byte)((i & 0x00FF0000) >> 16),
// (byte)((i & 0x0000FF00) >> 8),
// (byte)((i & 0x000000FF))
// };
// }
//
// public static int[] getInts(long i) {
// return new int[] {
// (int)((i & 0xFF000000) >> 24),
// (int)((i & 0x00FF0000) >> 16),
// (int)((i & 0x0000FF00) >> 8),
// (int)((i & 0x000000FF))
// };
// }
//
// public static byte[] reverseBytes(byte[] bytes) {
// byte[] result = new byte[bytes.length];
//
// for (int i = 0; i < bytes.length; i++) {
// result[i] = bytes[bytes.length - 1 - i];
// }
//
// return result;
// }
//
// public static byte[] getBytes(byte[] array, int offset, int length) {
// byte[] result = new byte[length];
//
// for (int i = 0; i < length; i++) {
// try {
// result[i] = array[offset + i];
// } catch (ArrayIndexOutOfBoundsException e) {
// String message = String.format("Tried to read outside of bounds (%05X, %s)", offset, i);
//
// System.out.println(message);
// }
// }
//
// return result;
// }
//
// public static int[] grabBytesAsInts(byte[] array, int offset, int length) {
// if (length > array.length) {
// length = array.length;
// }
//
// int[] result = new int[length];
//
// for (int i = 0; i < length; i++) {
// result[i] = (array[offset + i] & 0xFF);
// }
//
// return result;
// }
//
// public static byte[] putBytes(byte[] array, byte[] toPut, int offset) {
// for (int i = 0; i < toPut.length; i++) {
// array[offset + i] = toPut[i];
// }
//
// return array;
// }
//
// public static int[] toInts(byte[] array) {
// return grabBytesAsInts(array, 0, array.length);
// }
//
// public static String toHexString(int loc) {
// return toHexString(loc, false);
// }
//
// // Use absolute value to prevent negative bytes
//
// public static String toHexString(int loc, boolean spacing) {
// if (spacing) {
// return String.format("%02X", Math.abs(loc));
// } else {
// return String.format("%X", Math.abs(loc));
// }
// }
//
// public static String toDwordString(int b, boolean spacing) {
// if (spacing) {
// return String.format("%06X", Math.abs(b));
// } else {
// return String.format("%X", Math.abs(b));
// }
// }
//
// public static String byteToStringNoZero(int b) {
// if(b != 0) {
// return String.format("%X", Math.abs(b));
// } else {
// return "";
// }
// }
//
//
// public static byte[] toBytes(int[] data) {
// byte[] result = new byte[data.length];
//
// for (int i = 0; i < result.length; i++) {
// result[i] = (byte)(data[i]);
// }
//
// return result;
// }
//
// public static boolean zeroedOut(int... words) {
// for (int i : words) {
// if (i != 0) {
// return false;
// }
// }
//
// return true;
// }
//
// public static boolean isBitSet(byte value, int index) {
// return (value & (1 << index)) != 0;
// }
//
// /**
// * Left-to-right bit range of 2 bytes
// * @param from The bits from 0 (left)
// * @param to The bits from 0 (left)
// */
// public static int getBitRange(int value, int from, int to) {
// int fromA = 16 - to;
// to = 16 - from;
//
// from = fromA;
//
// int bits = to - from;
// int rightShifted = value >>> from;
// int mask = (1 << bits) - 1;
//
// return rightShifted & mask;
// }
// }
// Path: src/test/java/BitRangeTest.java
import me.hugmanrique.pokedata.utils.BitConverter;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author Hugmanrique
* @since 28/05/2017
*/
public class BitRangeTest {
@Test
public void test16BitRanges() { | assertEquals(0b10, BitConverter.getBitRange(0b1000000000000000, 0, 2)); |
hugmanrique/PokeData | src/main/java/me/hugmanrique/pokedata/maps/blocks/TripleType.java | // Path: src/main/java/me/hugmanrique/pokedata/roms/Game.java
// @AllArgsConstructor
// @Getter
// public enum Game {
// RUBY("AXV"),
// SAPPHIRE("AXP"),
// FIRE_RED("BPR"),
// LEAF_GREEN("BPG"),
// EMERALD("BPE"),
// CUSTOM("___");
//
// private String id;
//
// public static Game byId(String id) {
// for (Game game : values()) {
// // IDs are in xxxx format
// // Language is the last char, ignore it
// if (id.startsWith(game.getId())) {
// return game;
// }
// }
//
// return CUSTOM;
// }
//
// /**
// * Returns true if the EngineVersion of the game is 1
// */
// public boolean isElements() {
// return this == FIRE_RED || this == LEAF_GREEN;
// }
//
// /**
// * Returns true if the EngineVersion of the game is 0
// */
// public boolean isGem() {
// return this == RUBY || this == SAPPHIRE || this == EMERALD;
// }
// }
| import me.hugmanrique.pokedata.roms.Game; | package me.hugmanrique.pokedata.maps.blocks;
/**
* @author Hugmanrique
* @since 02/07/2017
*/
public enum TripleType {
NONE,
LEGACY,
LEGACY2,
REFERENCE;
| // Path: src/main/java/me/hugmanrique/pokedata/roms/Game.java
// @AllArgsConstructor
// @Getter
// public enum Game {
// RUBY("AXV"),
// SAPPHIRE("AXP"),
// FIRE_RED("BPR"),
// LEAF_GREEN("BPG"),
// EMERALD("BPE"),
// CUSTOM("___");
//
// private String id;
//
// public static Game byId(String id) {
// for (Game game : values()) {
// // IDs are in xxxx format
// // Language is the last char, ignore it
// if (id.startsWith(game.getId())) {
// return game;
// }
// }
//
// return CUSTOM;
// }
//
// /**
// * Returns true if the EngineVersion of the game is 1
// */
// public boolean isElements() {
// return this == FIRE_RED || this == LEAF_GREEN;
// }
//
// /**
// * Returns true if the EngineVersion of the game is 0
// */
// public boolean isGem() {
// return this == RUBY || this == SAPPHIRE || this == EMERALD;
// }
// }
// Path: src/main/java/me/hugmanrique/pokedata/maps/blocks/TripleType.java
import me.hugmanrique.pokedata.roms.Game;
package me.hugmanrique.pokedata.maps.blocks;
/**
* @author Hugmanrique
* @since 02/07/2017
*/
public enum TripleType {
NONE,
LEGACY,
LEGACY2,
REFERENCE;
| public static TripleType getType(long behaviour, Game game) { |
hugmanrique/PokeData | src/main/java/me/hugmanrique/pokedata/items/Pocket.java | // Path: src/main/java/me/hugmanrique/pokedata/roms/Game.java
// @AllArgsConstructor
// @Getter
// public enum Game {
// RUBY("AXV"),
// SAPPHIRE("AXP"),
// FIRE_RED("BPR"),
// LEAF_GREEN("BPG"),
// EMERALD("BPE"),
// CUSTOM("___");
//
// private String id;
//
// public static Game byId(String id) {
// for (Game game : values()) {
// // IDs are in xxxx format
// // Language is the last char, ignore it
// if (id.startsWith(game.getId())) {
// return game;
// }
// }
//
// return CUSTOM;
// }
//
// /**
// * Returns true if the EngineVersion of the game is 1
// */
// public boolean isElements() {
// return this == FIRE_RED || this == LEAF_GREEN;
// }
//
// /**
// * Returns true if the EngineVersion of the game is 0
// */
// public boolean isGem() {
// return this == RUBY || this == SAPPHIRE || this == EMERALD;
// }
// }
| import lombok.Getter;
import me.hugmanrique.pokedata.roms.Game; | package me.hugmanrique.pokedata.items;
/**
* @author Hugmanrique
* @since 28/05/2017
*/
@Getter
public enum Pocket {
ITEMS(1, 1),
KEY_ITEMS(2, 0),
POKE_BALLS(3, 2),
BERRIES(4, 4),
TMS_AND_HMS(5, 3);
/**
* ID for FireRed and LeafGreen games
*/
private byte element;
/**
* ID for Emerald, Ruby and Sapphire games
*/
private byte gem;
Pocket(int element, int gem) {
this.element = (byte) element;
this.gem = (byte) gem;
}
| // Path: src/main/java/me/hugmanrique/pokedata/roms/Game.java
// @AllArgsConstructor
// @Getter
// public enum Game {
// RUBY("AXV"),
// SAPPHIRE("AXP"),
// FIRE_RED("BPR"),
// LEAF_GREEN("BPG"),
// EMERALD("BPE"),
// CUSTOM("___");
//
// private String id;
//
// public static Game byId(String id) {
// for (Game game : values()) {
// // IDs are in xxxx format
// // Language is the last char, ignore it
// if (id.startsWith(game.getId())) {
// return game;
// }
// }
//
// return CUSTOM;
// }
//
// /**
// * Returns true if the EngineVersion of the game is 1
// */
// public boolean isElements() {
// return this == FIRE_RED || this == LEAF_GREEN;
// }
//
// /**
// * Returns true if the EngineVersion of the game is 0
// */
// public boolean isGem() {
// return this == RUBY || this == SAPPHIRE || this == EMERALD;
// }
// }
// Path: src/main/java/me/hugmanrique/pokedata/items/Pocket.java
import lombok.Getter;
import me.hugmanrique.pokedata.roms.Game;
package me.hugmanrique.pokedata.items;
/**
* @author Hugmanrique
* @since 28/05/2017
*/
@Getter
public enum Pocket {
ITEMS(1, 1),
KEY_ITEMS(2, 0),
POKE_BALLS(3, 2),
BERRIES(4, 4),
TMS_AND_HMS(5, 3);
/**
* ID for FireRed and LeafGreen games
*/
private byte element;
/**
* ID for Emerald, Ruby and Sapphire games
*/
private byte gem;
Pocket(int element, int gem) {
this.element = (byte) element;
this.gem = (byte) gem;
}
| public static Pocket byId(Game game, byte id) { |
hugmanrique/PokeData | src/main/java/me/hugmanrique/pokedata/compression/huff/HuffTreeNode.java | // Path: src/main/java/me/hugmanrique/pokedata/compression/HexInputStream.java
// public class HexInputStream {
// private volatile InputStream stream;
// private Stack<Long> positionStack;
//
// @Getter
// private volatile long pos;
//
// public HexInputStream(InputStream baseStream) {
// this.stream = baseStream;
// this.pos = 0;
// this.positionStack = new Stack<>();
// }
//
// public void skip(long n) throws IOException {
// pos += stream.skip(n);
// }
//
// public void setPosition(long newPos) throws IOException {
// skip(newPos - pos);
// }
//
// /**
// * Returns an estimate of the number of bytes left to read until the EOF
// * @see InputStream#available()
// */
// public int available() throws IOException {
// return stream.available();
// }
//
// /**
// * Reads a byte
// */
// public int readU8() throws IOException {
// int b = stream.read();
// pos++;
//
// return b;
// }
//
// /**
// * Reads a BigEndian s16
// */
// public short readS16() throws IOException {
// short word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = (short) (word | (readU8() << (8 * i)));
// }
//
// return word;
// }
//
// /**
// * Reads a LittleEndian s16
// */
// public short readLS16() throws IOException {
// short word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = (short) ((word << 8) | readU8());
// }
//
// return word;
// }
//
// /**
// * Reads a BigEndian u16
// */
// public int readU16() throws IOException {
// int word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = word | (readU8() << (8 * i));
// }
//
// return word;
// }
//
// /**
// * Reads a LittleEndian u16
// */
// public int readLU16() throws IOException {
// int word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = (word << 8) | readU8();
// }
//
// return word;
// }
//
// /**
// * Reads a BigEndian s32 (signed int)
// */
// public int readS32() throws IOException {
// int dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = dword | (readU8() << (8 * i));
// }
//
// return dword;
// }
//
// /**
// * Reads a LittleEndian s32 (unsigned int)
// */
// public int readLS32() throws IOException {
// int dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = (dword << 8) | readU8();
// }
//
// return dword;
// }
//
// /**
// * Reads a BigEndian u32 (unsigned int)
// */
// public long readU32() throws IOException {
// long dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = dword | (readU8() << (8 * i));
// }
//
// return dword;
// }
//
// /**
// * Reads a LittleEndian u32 (unsigned int)
// */
// public long readLU32() throws IOException {
// long dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = (dword << 8) | readU8();
// }
//
// return dword;
// }
//
// /**
// * Reads a BigEndian s64 (signed int)
// */
// public long readS64() throws IOException {
// long qword = 0;
//
// for (int i = 0; i < 8; i++) {
// qword = qword | (readU8() << (8 * i));
// }
//
// return qword;
// }
//
// /**
// * Reads a LittleEndian s64 (signed int)
// */
// public long readLS64() throws IOException {
// long qword = 0;
//
// for (int i = 0; i < 8; i++) {
// qword = (qword << 8) | readU8();
// }
//
// return qword;
// }
// }
//
// Path: src/main/java/me/hugmanrique/pokedata/utils/Pair.java
// @AllArgsConstructor
// @Data
// public class Pair<T, U> {
// private T first;
// private U second;
//
// public Pair() {
// this(null, null);
// }
//
// public boolean allSet() {
// return first != null && second != null;
// }
// }
| import lombok.Setter;
import me.hugmanrique.pokedata.compression.HexInputStream;
import me.hugmanrique.pokedata.utils.Pair;
import java.io.IOException; | package me.hugmanrique.pokedata.compression.huff;
/**
* @author Hugmanrique
* @since 29/05/2017
*/
public class HuffTreeNode {
@Setter
private static int maxInPos = 0;
HuffTreeNode node0, node1;
int data = -1; // [-1, 0xFF]
| // Path: src/main/java/me/hugmanrique/pokedata/compression/HexInputStream.java
// public class HexInputStream {
// private volatile InputStream stream;
// private Stack<Long> positionStack;
//
// @Getter
// private volatile long pos;
//
// public HexInputStream(InputStream baseStream) {
// this.stream = baseStream;
// this.pos = 0;
// this.positionStack = new Stack<>();
// }
//
// public void skip(long n) throws IOException {
// pos += stream.skip(n);
// }
//
// public void setPosition(long newPos) throws IOException {
// skip(newPos - pos);
// }
//
// /**
// * Returns an estimate of the number of bytes left to read until the EOF
// * @see InputStream#available()
// */
// public int available() throws IOException {
// return stream.available();
// }
//
// /**
// * Reads a byte
// */
// public int readU8() throws IOException {
// int b = stream.read();
// pos++;
//
// return b;
// }
//
// /**
// * Reads a BigEndian s16
// */
// public short readS16() throws IOException {
// short word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = (short) (word | (readU8() << (8 * i)));
// }
//
// return word;
// }
//
// /**
// * Reads a LittleEndian s16
// */
// public short readLS16() throws IOException {
// short word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = (short) ((word << 8) | readU8());
// }
//
// return word;
// }
//
// /**
// * Reads a BigEndian u16
// */
// public int readU16() throws IOException {
// int word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = word | (readU8() << (8 * i));
// }
//
// return word;
// }
//
// /**
// * Reads a LittleEndian u16
// */
// public int readLU16() throws IOException {
// int word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = (word << 8) | readU8();
// }
//
// return word;
// }
//
// /**
// * Reads a BigEndian s32 (signed int)
// */
// public int readS32() throws IOException {
// int dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = dword | (readU8() << (8 * i));
// }
//
// return dword;
// }
//
// /**
// * Reads a LittleEndian s32 (unsigned int)
// */
// public int readLS32() throws IOException {
// int dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = (dword << 8) | readU8();
// }
//
// return dword;
// }
//
// /**
// * Reads a BigEndian u32 (unsigned int)
// */
// public long readU32() throws IOException {
// long dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = dword | (readU8() << (8 * i));
// }
//
// return dword;
// }
//
// /**
// * Reads a LittleEndian u32 (unsigned int)
// */
// public long readLU32() throws IOException {
// long dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = (dword << 8) | readU8();
// }
//
// return dword;
// }
//
// /**
// * Reads a BigEndian s64 (signed int)
// */
// public long readS64() throws IOException {
// long qword = 0;
//
// for (int i = 0; i < 8; i++) {
// qword = qword | (readU8() << (8 * i));
// }
//
// return qword;
// }
//
// /**
// * Reads a LittleEndian s64 (signed int)
// */
// public long readLS64() throws IOException {
// long qword = 0;
//
// for (int i = 0; i < 8; i++) {
// qword = (qword << 8) | readU8();
// }
//
// return qword;
// }
// }
//
// Path: src/main/java/me/hugmanrique/pokedata/utils/Pair.java
// @AllArgsConstructor
// @Data
// public class Pair<T, U> {
// private T first;
// private U second;
//
// public Pair() {
// this(null, null);
// }
//
// public boolean allSet() {
// return first != null && second != null;
// }
// }
// Path: src/main/java/me/hugmanrique/pokedata/compression/huff/HuffTreeNode.java
import lombok.Setter;
import me.hugmanrique.pokedata.compression.HexInputStream;
import me.hugmanrique.pokedata.utils.Pair;
import java.io.IOException;
package me.hugmanrique.pokedata.compression.huff;
/**
* @author Hugmanrique
* @since 29/05/2017
*/
public class HuffTreeNode {
@Setter
private static int maxInPos = 0;
HuffTreeNode node0, node1;
int data = -1; // [-1, 0xFF]
| public Pair<Boolean, Integer> getValue(LinkedListNode<Integer> code) throws Exception { |
hugmanrique/PokeData | src/main/java/me/hugmanrique/pokedata/compression/huff/HuffTreeNode.java | // Path: src/main/java/me/hugmanrique/pokedata/compression/HexInputStream.java
// public class HexInputStream {
// private volatile InputStream stream;
// private Stack<Long> positionStack;
//
// @Getter
// private volatile long pos;
//
// public HexInputStream(InputStream baseStream) {
// this.stream = baseStream;
// this.pos = 0;
// this.positionStack = new Stack<>();
// }
//
// public void skip(long n) throws IOException {
// pos += stream.skip(n);
// }
//
// public void setPosition(long newPos) throws IOException {
// skip(newPos - pos);
// }
//
// /**
// * Returns an estimate of the number of bytes left to read until the EOF
// * @see InputStream#available()
// */
// public int available() throws IOException {
// return stream.available();
// }
//
// /**
// * Reads a byte
// */
// public int readU8() throws IOException {
// int b = stream.read();
// pos++;
//
// return b;
// }
//
// /**
// * Reads a BigEndian s16
// */
// public short readS16() throws IOException {
// short word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = (short) (word | (readU8() << (8 * i)));
// }
//
// return word;
// }
//
// /**
// * Reads a LittleEndian s16
// */
// public short readLS16() throws IOException {
// short word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = (short) ((word << 8) | readU8());
// }
//
// return word;
// }
//
// /**
// * Reads a BigEndian u16
// */
// public int readU16() throws IOException {
// int word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = word | (readU8() << (8 * i));
// }
//
// return word;
// }
//
// /**
// * Reads a LittleEndian u16
// */
// public int readLU16() throws IOException {
// int word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = (word << 8) | readU8();
// }
//
// return word;
// }
//
// /**
// * Reads a BigEndian s32 (signed int)
// */
// public int readS32() throws IOException {
// int dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = dword | (readU8() << (8 * i));
// }
//
// return dword;
// }
//
// /**
// * Reads a LittleEndian s32 (unsigned int)
// */
// public int readLS32() throws IOException {
// int dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = (dword << 8) | readU8();
// }
//
// return dword;
// }
//
// /**
// * Reads a BigEndian u32 (unsigned int)
// */
// public long readU32() throws IOException {
// long dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = dword | (readU8() << (8 * i));
// }
//
// return dword;
// }
//
// /**
// * Reads a LittleEndian u32 (unsigned int)
// */
// public long readLU32() throws IOException {
// long dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = (dword << 8) | readU8();
// }
//
// return dword;
// }
//
// /**
// * Reads a BigEndian s64 (signed int)
// */
// public long readS64() throws IOException {
// long qword = 0;
//
// for (int i = 0; i < 8; i++) {
// qword = qword | (readU8() << (8 * i));
// }
//
// return qword;
// }
//
// /**
// * Reads a LittleEndian s64 (signed int)
// */
// public long readLS64() throws IOException {
// long qword = 0;
//
// for (int i = 0; i < 8; i++) {
// qword = (qword << 8) | readU8();
// }
//
// return qword;
// }
// }
//
// Path: src/main/java/me/hugmanrique/pokedata/utils/Pair.java
// @AllArgsConstructor
// @Data
// public class Pair<T, U> {
// private T first;
// private U second;
//
// public Pair() {
// this(null, null);
// }
//
// public boolean allSet() {
// return first != null && second != null;
// }
// }
| import lombok.Setter;
import me.hugmanrique.pokedata.compression.HexInputStream;
import me.hugmanrique.pokedata.utils.Pair;
import java.io.IOException; | package me.hugmanrique.pokedata.compression.huff;
/**
* @author Hugmanrique
* @since 29/05/2017
*/
public class HuffTreeNode {
@Setter
private static int maxInPos = 0;
HuffTreeNode node0, node1;
int data = -1; // [-1, 0xFF]
public Pair<Boolean, Integer> getValue(LinkedListNode<Integer> code) throws Exception {
Pair<Boolean, Integer> out = new Pair<>();
out.setSecond(data);
if (code == null) {
out.setFirst(node0 == null && node1 == null && data >= 0);
return out;
}
if (code.getValue() > 1) {
throw new Exception("List should be a list of bytes ( < 2 ). Got " + code.getValue() + " instead");
}
int c = code.getValue();
HuffTreeNode node = (c == 0 ? node0 : node1);
if (node == null) {
out.setFirst(false);
}
// TODO Check if we need to throw this NPE
return node.getValue(code.getPrevious());
}
| // Path: src/main/java/me/hugmanrique/pokedata/compression/HexInputStream.java
// public class HexInputStream {
// private volatile InputStream stream;
// private Stack<Long> positionStack;
//
// @Getter
// private volatile long pos;
//
// public HexInputStream(InputStream baseStream) {
// this.stream = baseStream;
// this.pos = 0;
// this.positionStack = new Stack<>();
// }
//
// public void skip(long n) throws IOException {
// pos += stream.skip(n);
// }
//
// public void setPosition(long newPos) throws IOException {
// skip(newPos - pos);
// }
//
// /**
// * Returns an estimate of the number of bytes left to read until the EOF
// * @see InputStream#available()
// */
// public int available() throws IOException {
// return stream.available();
// }
//
// /**
// * Reads a byte
// */
// public int readU8() throws IOException {
// int b = stream.read();
// pos++;
//
// return b;
// }
//
// /**
// * Reads a BigEndian s16
// */
// public short readS16() throws IOException {
// short word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = (short) (word | (readU8() << (8 * i)));
// }
//
// return word;
// }
//
// /**
// * Reads a LittleEndian s16
// */
// public short readLS16() throws IOException {
// short word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = (short) ((word << 8) | readU8());
// }
//
// return word;
// }
//
// /**
// * Reads a BigEndian u16
// */
// public int readU16() throws IOException {
// int word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = word | (readU8() << (8 * i));
// }
//
// return word;
// }
//
// /**
// * Reads a LittleEndian u16
// */
// public int readLU16() throws IOException {
// int word = 0;
//
// for (int i = 0; i < 2; i++) {
// word = (word << 8) | readU8();
// }
//
// return word;
// }
//
// /**
// * Reads a BigEndian s32 (signed int)
// */
// public int readS32() throws IOException {
// int dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = dword | (readU8() << (8 * i));
// }
//
// return dword;
// }
//
// /**
// * Reads a LittleEndian s32 (unsigned int)
// */
// public int readLS32() throws IOException {
// int dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = (dword << 8) | readU8();
// }
//
// return dword;
// }
//
// /**
// * Reads a BigEndian u32 (unsigned int)
// */
// public long readU32() throws IOException {
// long dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = dword | (readU8() << (8 * i));
// }
//
// return dword;
// }
//
// /**
// * Reads a LittleEndian u32 (unsigned int)
// */
// public long readLU32() throws IOException {
// long dword = 0;
//
// for (int i = 0; i < 4; i++) {
// dword = (dword << 8) | readU8();
// }
//
// return dword;
// }
//
// /**
// * Reads a BigEndian s64 (signed int)
// */
// public long readS64() throws IOException {
// long qword = 0;
//
// for (int i = 0; i < 8; i++) {
// qword = qword | (readU8() << (8 * i));
// }
//
// return qword;
// }
//
// /**
// * Reads a LittleEndian s64 (signed int)
// */
// public long readLS64() throws IOException {
// long qword = 0;
//
// for (int i = 0; i < 8; i++) {
// qword = (qword << 8) | readU8();
// }
//
// return qword;
// }
// }
//
// Path: src/main/java/me/hugmanrique/pokedata/utils/Pair.java
// @AllArgsConstructor
// @Data
// public class Pair<T, U> {
// private T first;
// private U second;
//
// public Pair() {
// this(null, null);
// }
//
// public boolean allSet() {
// return first != null && second != null;
// }
// }
// Path: src/main/java/me/hugmanrique/pokedata/compression/huff/HuffTreeNode.java
import lombok.Setter;
import me.hugmanrique.pokedata.compression.HexInputStream;
import me.hugmanrique.pokedata.utils.Pair;
import java.io.IOException;
package me.hugmanrique.pokedata.compression.huff;
/**
* @author Hugmanrique
* @since 29/05/2017
*/
public class HuffTreeNode {
@Setter
private static int maxInPos = 0;
HuffTreeNode node0, node1;
int data = -1; // [-1, 0xFF]
public Pair<Boolean, Integer> getValue(LinkedListNode<Integer> code) throws Exception {
Pair<Boolean, Integer> out = new Pair<>();
out.setSecond(data);
if (code == null) {
out.setFirst(node0 == null && node1 == null && data >= 0);
return out;
}
if (code.getValue() > 1) {
throw new Exception("List should be a list of bytes ( < 2 ). Got " + code.getValue() + " instead");
}
int c = code.getValue();
HuffTreeNode node = (c == 0 ? node0 : node1);
if (node == null) {
out.setFirst(false);
}
// TODO Check if we need to throw this NPE
return node.getValue(code.getPrevious());
}
| public void parseData(HexInputStream stream) throws IOException { |
hugmanrique/PokeData | src/main/java/me/hugmanrique/pokedata/pokedex/ev/EvolutionParam.java | // Path: src/main/java/me/hugmanrique/pokedata/loaders/InvalidDataException.java
// public class InvalidDataException extends IllegalArgumentException {
// public InvalidDataException(String s) {
// super(s);
// }
//
// public InvalidDataException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public InvalidDataException(Throwable cause) {
// super(cause);
// }
// }
| import lombok.AllArgsConstructor;
import lombok.Getter;
import me.hugmanrique.pokedata.loaders.InvalidDataException; | package me.hugmanrique.pokedata.pokedex.ev;
/**
* @author Hugmanrique
* @since 27/05/2017
*/
@AllArgsConstructor
@Getter
public enum EvolutionParam {
NONE("none"),
EVOLVES_NO_PARAMS("evolvesbutnoparms"),
LEVEL("level"),
ITEM("item"),
EVOLVES_BASEDONVALUE("evolvesbasedonvalue");
private String config;
public static EvolutionParam byConfig(String value) {
for (EvolutionParam type : values()) {
if (type.getConfig().equals(value)) {
return type;
}
}
| // Path: src/main/java/me/hugmanrique/pokedata/loaders/InvalidDataException.java
// public class InvalidDataException extends IllegalArgumentException {
// public InvalidDataException(String s) {
// super(s);
// }
//
// public InvalidDataException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public InvalidDataException(Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/me/hugmanrique/pokedata/pokedex/ev/EvolutionParam.java
import lombok.AllArgsConstructor;
import lombok.Getter;
import me.hugmanrique.pokedata.loaders.InvalidDataException;
package me.hugmanrique.pokedata.pokedex.ev;
/**
* @author Hugmanrique
* @since 27/05/2017
*/
@AllArgsConstructor
@Getter
public enum EvolutionParam {
NONE("none"),
EVOLVES_NO_PARAMS("evolvesbutnoparms"),
LEVEL("level"),
ITEM("item"),
EVOLVES_BASEDONVALUE("evolvesbasedonvalue");
private String config;
public static EvolutionParam byConfig(String value) {
for (EvolutionParam type : values()) {
if (type.getConfig().equals(value)) {
return type;
}
}
| throw new InvalidDataException("Config type '" + value + "' isn't a valid EvolutionType value"); |
gabrielsr/bomberman-libgdx | core/src/main/java/br/unb/unbomber/systems/AudioSystem.java | // Path: core/src/main/java/br/unb/unbomber/core/event/ChangeAudioThemeEvent.java
// public class ChangeAudioThemeEvent extends Event{
//
// private String newThemeName;
//
// public String getNewThemeName() {
// return newThemeName;
// }
//
// public void setNewThemeName(String newThemeName) {
// this.newThemeName = newThemeName;
// }
//
// }
| import java.util.List;
import br.unb.unbomber.core.BaseSystem;
import br.unb.unbomber.core.EntityManager;
import br.unb.unbomber.core.Event;
import br.unb.unbomber.core.event.ChangeAudioThemeEvent;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music; | package br.unb.unbomber.systems;
/**
* Controls the audio of a Match.
*
* This system should start the music when the game begin and
* play sounds when choose events occur.
*
* @author grodrigues
*
*/
public class AudioSystem extends BaseSystem {
public static final String AUDIO_BASE = "audio/music/";
public static final String OPEN_THEME = AUDIO_BASE + "DST-1990.mp3";
public Music openTheme;
public AudioSystem(EntityManager entityManager) {
super(entityManager);
}
@Override
public void start() {
load();
}
@Override
public void stop() {
openTheme.pause();
// TODO Auto-generated method stub
}
@Override
public void update() {
List<Event> destroyedEvents = getEntityManager().getEvents( | // Path: core/src/main/java/br/unb/unbomber/core/event/ChangeAudioThemeEvent.java
// public class ChangeAudioThemeEvent extends Event{
//
// private String newThemeName;
//
// public String getNewThemeName() {
// return newThemeName;
// }
//
// public void setNewThemeName(String newThemeName) {
// this.newThemeName = newThemeName;
// }
//
// }
// Path: core/src/main/java/br/unb/unbomber/systems/AudioSystem.java
import java.util.List;
import br.unb.unbomber.core.BaseSystem;
import br.unb.unbomber.core.EntityManager;
import br.unb.unbomber.core.Event;
import br.unb.unbomber.core.event.ChangeAudioThemeEvent;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
package br.unb.unbomber.systems;
/**
* Controls the audio of a Match.
*
* This system should start the music when the game begin and
* play sounds when choose events occur.
*
* @author grodrigues
*
*/
public class AudioSystem extends BaseSystem {
public static final String AUDIO_BASE = "audio/music/";
public static final String OPEN_THEME = AUDIO_BASE + "DST-1990.mp3";
public Music openTheme;
public AudioSystem(EntityManager entityManager) {
super(entityManager);
}
@Override
public void start() {
load();
}
@Override
public void stop() {
openTheme.pause();
// TODO Auto-generated method stub
}
@Override
public void update() {
List<Event> destroyedEvents = getEntityManager().getEvents( | ChangeAudioThemeEvent.class); |
gabrielsr/bomberman-libgdx | core/src/main/java/br/unb/bomberman/ui/screens/SettingsScreen.java | // Path: core/src/main/java/br/unb/unbomber/GDXGame.java
// public class GDXGame extends Game {
//
// public final String FIRST_STAGE_LEVEL_ID = "stage";
// public final String TEST_STAGE_EXPLOSION = "test/explosion";
// public final String TEST_RENDERIZATION = "test/renderization";
// public SpriteBatch batch;
//
// public MainMenuScreen mainMenuScreen;
//
// /**
// * Load the assets and
// */
// @Override
// public void create () {
// batch = new SpriteBatch();
//
// Settings.load();
// Assets.load();
//
// mainMenuScreen = new MainMenuScreen(this);
// this.setScreen(mainMenuScreen);
// }
//
// public void render() {
// super.render(); //important!
// }
//
// public void dispose() {
// batch.dispose();
// }
// }
//
// Path: core/src/main/java/br/unb/unbomber/Settings.java
// public class Settings {
// public static boolean musicEnabled = true;
// public static boolean soundEnabled = true;
// public static float soundVolume = 0.5f;
// public final static int[] highscores = new int[] {100, 80, 50, 30, 10};
// public final static String file = ".superjumper";
//
// public static boolean scoresReseted = false;
//
// private final static String SCORES_FILE = "../core/assets/scores.json";
//
// public static void load () {
// try {
// FileHandle filehandle = Gdx.files.external(file);
//
// String[] strings = filehandle.readString().split("\n");
//
// musicEnabled = Boolean.parseBoolean(strings[0]);
// for (int i = 0; i < 5; i++) {
// highscores[i] = Integer.parseInt(strings[i+1]);
// }
// } catch (Throwable e) {
// // :( It's ok we have defaults
// }
// }
//
// public static void save () {
// try {
// FileHandle filehandle = Gdx.files.external(file);
//
// filehandle.writeString(Boolean.toString(musicEnabled)+"\n", false);
// for (int i = 0; i < 5; i++) {
// filehandle.writeString(Integer.toString(highscores[i])+"\n", true);
// }
// } catch (Throwable e) {
// }
// }
//
// // public static void addScore (int score) {
// // for (int i = 0; i < 5; i++) {
// // if (highscores[i] < score) {
// // for (int j = 4; j > i; j--)
// // highscores[j] = highscores[j - 1];
// // highscores[i] = score;
// // break;
// // }
// // }
// // }
//
// public static void addScore (String name, int score) {
// Json json = new Json();
// FileHandle scoresFile = Gdx.files.local(SCORES_FILE);
// List<Player> players = getScores();
// PlayerSpec playersSpec = new PlayerSpec();
// Player newPlayer = new Player();
// newPlayer.setPlayerName(name);
// newPlayer.setScore(score);
// players.add(newPlayer);
// playersSpec.setPlayers(players);
// json.setOutputType(OutputType.json);
// scoresFile.writeString(json.prettyPrint(json.toJson(playersSpec)), false, null);
// scoresReseted = false;
// }
//
// public static List<Player> getScores() {
// Json json = new Json();
// List<Player> players;
// FileHandle scoresFile = Gdx.files.local(SCORES_FILE);
// PlayerSpec playersSpec = json.fromJson(PlayerSpec.class, scoresFile.reader());
// if (playersSpec != null) {
// players = playersSpec.getPlayers();
// } else {
// players = new ArrayList<PlayerSpec.Player>();
// }
// return players;
// }
//
// public static void resetScores() {
// FileHandle scoresFile = Gdx.files.local(SCORES_FILE);
// FileHandle scoresBkp = Gdx.files.local(SCORES_FILE + ".bkp");
// scoresFile.moveTo(scoresBkp);
// scoresFile.write(false);
// scoresReseted = true;
// }
//
// public static void enableMusic() {
// musicEnabled = true;
// Assets.music.setLooping(true);
// Assets.music.setVolume(soundVolume);
// Assets.music.play();
// }
//
// public static void disableMusic() {
// musicEnabled = false;
// Assets.music.stop();
// }
// }
| import br.unb.unbomber.GDXGame;
import br.unb.unbomber.Settings;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; |
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
game.batch.setProjectionMatrix(camera.combined);
game.batch.begin();
game.batch.draw(background, -28, -122, 864, 720);
game.batch.flush();
Gdx.input.setInputProcessor(stage);
stage.act();
stage.draw();
game.batch.end();
}
@Override
public void resize(int width, int height) {
}
@Override
public void show() {
background = new Texture(Gdx.files.local("background.png"));
camera = new OrthographicCamera();
camera.setToOrtho(false, 800, 480);
buttonFactory = new MenuButtonFactory();
stage = new Stage();
stage.clear(); | // Path: core/src/main/java/br/unb/unbomber/GDXGame.java
// public class GDXGame extends Game {
//
// public final String FIRST_STAGE_LEVEL_ID = "stage";
// public final String TEST_STAGE_EXPLOSION = "test/explosion";
// public final String TEST_RENDERIZATION = "test/renderization";
// public SpriteBatch batch;
//
// public MainMenuScreen mainMenuScreen;
//
// /**
// * Load the assets and
// */
// @Override
// public void create () {
// batch = new SpriteBatch();
//
// Settings.load();
// Assets.load();
//
// mainMenuScreen = new MainMenuScreen(this);
// this.setScreen(mainMenuScreen);
// }
//
// public void render() {
// super.render(); //important!
// }
//
// public void dispose() {
// batch.dispose();
// }
// }
//
// Path: core/src/main/java/br/unb/unbomber/Settings.java
// public class Settings {
// public static boolean musicEnabled = true;
// public static boolean soundEnabled = true;
// public static float soundVolume = 0.5f;
// public final static int[] highscores = new int[] {100, 80, 50, 30, 10};
// public final static String file = ".superjumper";
//
// public static boolean scoresReseted = false;
//
// private final static String SCORES_FILE = "../core/assets/scores.json";
//
// public static void load () {
// try {
// FileHandle filehandle = Gdx.files.external(file);
//
// String[] strings = filehandle.readString().split("\n");
//
// musicEnabled = Boolean.parseBoolean(strings[0]);
// for (int i = 0; i < 5; i++) {
// highscores[i] = Integer.parseInt(strings[i+1]);
// }
// } catch (Throwable e) {
// // :( It's ok we have defaults
// }
// }
//
// public static void save () {
// try {
// FileHandle filehandle = Gdx.files.external(file);
//
// filehandle.writeString(Boolean.toString(musicEnabled)+"\n", false);
// for (int i = 0; i < 5; i++) {
// filehandle.writeString(Integer.toString(highscores[i])+"\n", true);
// }
// } catch (Throwable e) {
// }
// }
//
// // public static void addScore (int score) {
// // for (int i = 0; i < 5; i++) {
// // if (highscores[i] < score) {
// // for (int j = 4; j > i; j--)
// // highscores[j] = highscores[j - 1];
// // highscores[i] = score;
// // break;
// // }
// // }
// // }
//
// public static void addScore (String name, int score) {
// Json json = new Json();
// FileHandle scoresFile = Gdx.files.local(SCORES_FILE);
// List<Player> players = getScores();
// PlayerSpec playersSpec = new PlayerSpec();
// Player newPlayer = new Player();
// newPlayer.setPlayerName(name);
// newPlayer.setScore(score);
// players.add(newPlayer);
// playersSpec.setPlayers(players);
// json.setOutputType(OutputType.json);
// scoresFile.writeString(json.prettyPrint(json.toJson(playersSpec)), false, null);
// scoresReseted = false;
// }
//
// public static List<Player> getScores() {
// Json json = new Json();
// List<Player> players;
// FileHandle scoresFile = Gdx.files.local(SCORES_FILE);
// PlayerSpec playersSpec = json.fromJson(PlayerSpec.class, scoresFile.reader());
// if (playersSpec != null) {
// players = playersSpec.getPlayers();
// } else {
// players = new ArrayList<PlayerSpec.Player>();
// }
// return players;
// }
//
// public static void resetScores() {
// FileHandle scoresFile = Gdx.files.local(SCORES_FILE);
// FileHandle scoresBkp = Gdx.files.local(SCORES_FILE + ".bkp");
// scoresFile.moveTo(scoresBkp);
// scoresFile.write(false);
// scoresReseted = true;
// }
//
// public static void enableMusic() {
// musicEnabled = true;
// Assets.music.setLooping(true);
// Assets.music.setVolume(soundVolume);
// Assets.music.play();
// }
//
// public static void disableMusic() {
// musicEnabled = false;
// Assets.music.stop();
// }
// }
// Path: core/src/main/java/br/unb/bomberman/ui/screens/SettingsScreen.java
import br.unb.unbomber.GDXGame;
import br.unb.unbomber.Settings;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
game.batch.setProjectionMatrix(camera.combined);
game.batch.begin();
game.batch.draw(background, -28, -122, 864, 720);
game.batch.flush();
Gdx.input.setInputProcessor(stage);
stage.act();
stage.draw();
game.batch.end();
}
@Override
public void resize(int width, int height) {
}
@Override
public void show() {
background = new Texture(Gdx.files.local("background.png"));
camera = new OrthographicCamera();
camera.setToOrtho(false, 800, 480);
buttonFactory = new MenuButtonFactory();
stage = new Stage();
stage.clear(); | if (Settings.musicEnabled) { |
gabrielsr/bomberman-libgdx | desktop/src/br/unb/bomberman/ui/desktop/DesktopLauncher.java | // Path: core/src/main/java/br/unb/unbomber/GDXGame.java
// public class GDXGame extends Game {
//
// public final String FIRST_STAGE_LEVEL_ID = "stage";
// public final String TEST_STAGE_EXPLOSION = "test/explosion";
// public final String TEST_RENDERIZATION = "test/renderization";
// public SpriteBatch batch;
//
// public MainMenuScreen mainMenuScreen;
//
// /**
// * Load the assets and
// */
// @Override
// public void create () {
// batch = new SpriteBatch();
//
// Settings.load();
// Assets.load();
//
// mainMenuScreen = new MainMenuScreen(this);
// this.setScreen(mainMenuScreen);
// }
//
// public void render() {
// super.render(); //important!
// }
//
// public void dispose() {
// batch.dispose();
// }
// }
| import br.unb.unbomber.GDXGame;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; | package br.unb.bomberman.ui.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | // Path: core/src/main/java/br/unb/unbomber/GDXGame.java
// public class GDXGame extends Game {
//
// public final String FIRST_STAGE_LEVEL_ID = "stage";
// public final String TEST_STAGE_EXPLOSION = "test/explosion";
// public final String TEST_RENDERIZATION = "test/renderization";
// public SpriteBatch batch;
//
// public MainMenuScreen mainMenuScreen;
//
// /**
// * Load the assets and
// */
// @Override
// public void create () {
// batch = new SpriteBatch();
//
// Settings.load();
// Assets.load();
//
// mainMenuScreen = new MainMenuScreen(this);
// this.setScreen(mainMenuScreen);
// }
//
// public void render() {
// super.render(); //important!
// }
//
// public void dispose() {
// batch.dispose();
// }
// }
// Path: desktop/src/br/unb/bomberman/ui/desktop/DesktopLauncher.java
import br.unb.unbomber.GDXGame;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
package br.unb.bomberman.ui.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | new LwjglApplication(new GDXGame(), config); |
redfin/fuzzy | fuzzy-core/src/main/java/com/redfin/fuzzy/pairwise/Pairwise.java | // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/FuzzyPreconditions.java
// public class FuzzyPreconditions {
//
// public static <T> T checkNotNull(T t) {
// if(t == null) throw new NullPointerException();
// return t;
// }
//
// public static <T> T checkNotNull(String message, T t) {
// if(t == null) throw new NullPointerException(message);
// return t;
// }
//
// public static <T> T[] checkNotNullAndContainsNoNulls(T[] array) {
// checkNotNull(array);
// for(T t : array) {
// if(t == null) throw new IllegalArgumentException("Array contains a null value.");
// }
// return array;
// }
//
// public static <T, C extends Collection<T>> C checkNotNullAndContainsNoNulls(C c) {
// checkNotNull(c);
// for(T t : c) {
// if(t == null) throw new IllegalArgumentException("Collection contains a null value.");
// }
// return c;
// }
//
// public static <T> T[] checkNotEmpty(T[] array) {
// checkNotNull(array);
// if(array.length == 0) throw new IllegalArgumentException("Array does not contain any values.");
// return array;
// }
//
// }
| import com.redfin.fuzzy.FuzzyPreconditions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack; | package com.redfin.fuzzy.pairwise;
public class Pairwise<S extends Collection> {
private final List<Param> params;
public Pairwise(List<S> parameters) { | // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/FuzzyPreconditions.java
// public class FuzzyPreconditions {
//
// public static <T> T checkNotNull(T t) {
// if(t == null) throw new NullPointerException();
// return t;
// }
//
// public static <T> T checkNotNull(String message, T t) {
// if(t == null) throw new NullPointerException(message);
// return t;
// }
//
// public static <T> T[] checkNotNullAndContainsNoNulls(T[] array) {
// checkNotNull(array);
// for(T t : array) {
// if(t == null) throw new IllegalArgumentException("Array contains a null value.");
// }
// return array;
// }
//
// public static <T, C extends Collection<T>> C checkNotNullAndContainsNoNulls(C c) {
// checkNotNull(c);
// for(T t : c) {
// if(t == null) throw new IllegalArgumentException("Collection contains a null value.");
// }
// return c;
// }
//
// public static <T> T[] checkNotEmpty(T[] array) {
// checkNotNull(array);
// if(array.length == 0) throw new IllegalArgumentException("Array does not contain any values.");
// return array;
// }
//
// }
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/pairwise/Pairwise.java
import com.redfin.fuzzy.FuzzyPreconditions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
package com.redfin.fuzzy.pairwise;
public class Pairwise<S extends Collection> {
private final List<Param> params;
public Pairwise(List<S> parameters) { | FuzzyPreconditions.checkNotNull(parameters); |
redfin/fuzzy | fuzzy-core/src/main/java/com/redfin/fuzzy/cases/UnionCase.java | // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Case.java
// public interface Case<T>
// {
//
// /**
// * Returns the specific set of subcases that describe all equivalency classes for this case.
// *
// * <p>Cases are expected to return <em>at least one</em> subcase. When the fuzzy engine is determining how many test
// * cases to execute, it does so in terms of subcases, not cases. Thus, when using the pairwise permutation
// * algorithm, the fuzzy library works to ensure that each possible combination of two subcases are executed.</p>
// *
// * <p><strong>Note to implementors:</strong> cases should generally <em>not</em> include {@code null} values as
// * possible outputs. Instead, consumers are expected to use the {@link #orNull()} method (or, equivalently,
// * {@link Any#nullableOf}) to declare that their cases should also generate null values.</p>
// */
// Set<Subcase<T>> getSubcases();
//
// /**
// * Returns a new case that combines the subcases of this case and the provided {@code other} case. This method can
// * be used to combine different cases for a value into a single {@linkplain Generator generator}.
// */
// default Case<T> or(Case<T> other) { return Any.of(this, other); }
//
// /**
// * Returns a new case that combines the subcases of this case and a subcase specifically generating the value
// * {@code null}.
// */
// default Case<T> orNull() { return Any.nullableOf(this); }
//
// /**
// * Constrains the
// */
// default Case<T> excluding(T value) { return excluding(Collections.singleton(value)); }
// default Case<T> excluding(T... values) { return excluding(values == null ? null : Arrays.asList(values)); }
// default Case<T> excluding(Iterable<T> values) { return new ExcludingCase<>(this, values); }
//
// /**
// * Arbitrarily selects and returns the value of one of this case's subcases.
// */
// default T generateAnyOnce() { return generateAnyOnce(new Random()); }
//
// /**
// * Arbitrarily selects and returns the value of one of this case's subcases.
// *
// * @param random the random number generator that will be used to create the returned value.
// */
// default T generateAnyOnce(Random random) {
// FuzzyPreconditions.checkNotNull(random);
//
// Set<Subcase<T>> subcases = getSubcases();
//
// if(subcases == null || subcases.isEmpty())
// throw new IllegalStateException(String.format("Case of type %s generated zero suppliers.", getClass()));
//
// return subcases.stream().findAny().orElse(null).generate(random);
// }
//
// /**
// * Requests each of this case's subcases to generate and return a value.
// */
// default Set<T> generateAllOnce() { return generateAllOnce(new Random()); }
//
// /**
// * Requests each of this case's subcases to generate and return a value.
// *
// * @param random the random number generator that will be used to create the returned values.
// */
// default Set<T> generateAllOnce(Random random) {
// FuzzyPreconditions.checkNotNull(random);
//
// Set<Subcase<T>> subcases = getSubcases();
//
// if(subcases == null || subcases.isEmpty())
// throw new IllegalStateException(String.format("Case of type %s generated zero suppliers.", getClass()));
//
// return subcases.stream().map(s -> s.generate(random)).collect(Collectors.toSet());
// }
//
// }
//
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Subcase.java
// public interface Subcase<T> {
//
// /**
// * Instructs the subcase to generate and return a new value.
// *
// * <p>Subcases are not required to return exactly the same value for subsequent calls to {@code generate}; they may
// * randomly adjust their output on a per-call basis. However, subcases should adhere to the expectation that they
// * represent an <em>equivalency class</em> of output: although individual return values may differ, each value they
// * produce is effectively the same from a testing perspective.
// * </p>
// * <p>If the subcase does chose to produce randomized values, it should do so deterministically: two calls provided
// * with a random number generator with the same seed should produce exactly the same output. In general, this
// * condition should be satisfied if the test uses the provided {@linkplain Random random number generator} as its
// * only source of randomness.</p>
// */
// T generate(Random random);
//
// /**
// * Describes a given output produced by this subcase, for use in test failure reports.
// *
// * <p>The default implementation of this method attempts to provide helpful descriptions of {@code null}, common
// * primitives, strings, arrays, and collections. It defers to {@link Object#toString()} for all other descriptions.
// * </p>
// *
// * @param sink the string builder to which the description of the value should be appended.
// * @param value the value (as returned by this subcase's {@link #generate(Random) generate} method) that should be
// * described.
// */
// default void describeTo(StringBuilder sink, T value) {
// FuzzyPreconditions.checkNotNull(sink);
// FuzzyUtil.inspectTo(sink, value);
// }
//
// }
| import com.redfin.fuzzy.Case;
import com.redfin.fuzzy.Subcase;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set; | package com.redfin.fuzzy.cases;
public class UnionCase<T> implements Case<T> {
private final Set<Case<T>> _subcases;
@SafeVarargs
public UnionCase(Case<T>... subcases) {
_subcases = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(subcases)));
}
@Override | // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Case.java
// public interface Case<T>
// {
//
// /**
// * Returns the specific set of subcases that describe all equivalency classes for this case.
// *
// * <p>Cases are expected to return <em>at least one</em> subcase. When the fuzzy engine is determining how many test
// * cases to execute, it does so in terms of subcases, not cases. Thus, when using the pairwise permutation
// * algorithm, the fuzzy library works to ensure that each possible combination of two subcases are executed.</p>
// *
// * <p><strong>Note to implementors:</strong> cases should generally <em>not</em> include {@code null} values as
// * possible outputs. Instead, consumers are expected to use the {@link #orNull()} method (or, equivalently,
// * {@link Any#nullableOf}) to declare that their cases should also generate null values.</p>
// */
// Set<Subcase<T>> getSubcases();
//
// /**
// * Returns a new case that combines the subcases of this case and the provided {@code other} case. This method can
// * be used to combine different cases for a value into a single {@linkplain Generator generator}.
// */
// default Case<T> or(Case<T> other) { return Any.of(this, other); }
//
// /**
// * Returns a new case that combines the subcases of this case and a subcase specifically generating the value
// * {@code null}.
// */
// default Case<T> orNull() { return Any.nullableOf(this); }
//
// /**
// * Constrains the
// */
// default Case<T> excluding(T value) { return excluding(Collections.singleton(value)); }
// default Case<T> excluding(T... values) { return excluding(values == null ? null : Arrays.asList(values)); }
// default Case<T> excluding(Iterable<T> values) { return new ExcludingCase<>(this, values); }
//
// /**
// * Arbitrarily selects and returns the value of one of this case's subcases.
// */
// default T generateAnyOnce() { return generateAnyOnce(new Random()); }
//
// /**
// * Arbitrarily selects and returns the value of one of this case's subcases.
// *
// * @param random the random number generator that will be used to create the returned value.
// */
// default T generateAnyOnce(Random random) {
// FuzzyPreconditions.checkNotNull(random);
//
// Set<Subcase<T>> subcases = getSubcases();
//
// if(subcases == null || subcases.isEmpty())
// throw new IllegalStateException(String.format("Case of type %s generated zero suppliers.", getClass()));
//
// return subcases.stream().findAny().orElse(null).generate(random);
// }
//
// /**
// * Requests each of this case's subcases to generate and return a value.
// */
// default Set<T> generateAllOnce() { return generateAllOnce(new Random()); }
//
// /**
// * Requests each of this case's subcases to generate and return a value.
// *
// * @param random the random number generator that will be used to create the returned values.
// */
// default Set<T> generateAllOnce(Random random) {
// FuzzyPreconditions.checkNotNull(random);
//
// Set<Subcase<T>> subcases = getSubcases();
//
// if(subcases == null || subcases.isEmpty())
// throw new IllegalStateException(String.format("Case of type %s generated zero suppliers.", getClass()));
//
// return subcases.stream().map(s -> s.generate(random)).collect(Collectors.toSet());
// }
//
// }
//
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Subcase.java
// public interface Subcase<T> {
//
// /**
// * Instructs the subcase to generate and return a new value.
// *
// * <p>Subcases are not required to return exactly the same value for subsequent calls to {@code generate}; they may
// * randomly adjust their output on a per-call basis. However, subcases should adhere to the expectation that they
// * represent an <em>equivalency class</em> of output: although individual return values may differ, each value they
// * produce is effectively the same from a testing perspective.
// * </p>
// * <p>If the subcase does chose to produce randomized values, it should do so deterministically: two calls provided
// * with a random number generator with the same seed should produce exactly the same output. In general, this
// * condition should be satisfied if the test uses the provided {@linkplain Random random number generator} as its
// * only source of randomness.</p>
// */
// T generate(Random random);
//
// /**
// * Describes a given output produced by this subcase, for use in test failure reports.
// *
// * <p>The default implementation of this method attempts to provide helpful descriptions of {@code null}, common
// * primitives, strings, arrays, and collections. It defers to {@link Object#toString()} for all other descriptions.
// * </p>
// *
// * @param sink the string builder to which the description of the value should be appended.
// * @param value the value (as returned by this subcase's {@link #generate(Random) generate} method) that should be
// * described.
// */
// default void describeTo(StringBuilder sink, T value) {
// FuzzyPreconditions.checkNotNull(sink);
// FuzzyUtil.inspectTo(sink, value);
// }
//
// }
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/cases/UnionCase.java
import com.redfin.fuzzy.Case;
import com.redfin.fuzzy.Subcase;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
package com.redfin.fuzzy.cases;
public class UnionCase<T> implements Case<T> {
private final Set<Case<T>> _subcases;
@SafeVarargs
public UnionCase(Case<T>... subcases) {
_subcases = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(subcases)));
}
@Override | public Set<Subcase<T>> getSubcases() { |
redfin/fuzzy | fuzzy-core/src/main/java/com/redfin/fuzzy/Subcases.java | // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/pairwise/Pairwise.java
// public class Pairwise<S extends Collection> {
//
// private final List<Param> params;
//
// public Pairwise(List<S> parameters) {
// FuzzyPreconditions.checkNotNull(parameters);
//
// List<Param> params = new ArrayList<>();
// int i = 0;
// for(Collection<?> parameter : parameters) {
// FuzzyPreconditions.checkNotNullAndContainsNoNulls(parameter);
// params.add(new Param(i++, new ArrayList<>(parameter)));
// }
//
// this.params = Collections.unmodifiableList(params);
// }
//
// /*package*/ PairSet generatePairs() {
// PairSet pairs = new PairSet();
//
// for(int i = 0; i < params.size() - 1; i++) {
// for(ParamValue p1 : params.get(i).values) {
// for(int j = i + 1; j < params.size(); j++) {
// for(ParamValue p2 : params.get(j).values) {
// pairs.register(new Pair(p1, p2));
// }
// }
// }
// }
//
// return pairs;
// }
//
// public Stack<List<Object>> generate() {
// // Special case: if there's only one parameter, then there are obviously no pairs. Just return all the parameter
// // values.
// if(params.size() == 1) {
// Stack<List<Object>> ret = new Stack<>();
// for(ParamValue value : params.get(0).values) {
// ret.push(Collections.singletonList(value.value));
// }
// return ret;
// }
//
// // Step 1: build some round-robin selectors for all of the parameters.
// Map<Param, Selector> selectors = new HashMap<>(params.size());
// for(Param p : params) selectors.put(p, new Selector(p));
//
// // Step 2: compute all of the expected pairs in our input set.
// PairSet pairs = generatePairs();
//
// // Step 3: start consuming pairs one at a time until each pair has been used.
// Stack<List<Object>> testCases = new Stack<>();
// while(!pairs.isEmpty()) {
// // Step a: perform an exhaustive search of any pairs we can add to this iteration.
// Map<Param, Object> chosenValues = new HashMap<>(params.size());
// for(int i = 0; i < params.size() - 1; i++) {
// for(int j = i + 1; j < params.size(); j++) {
// Param p1 = params.get(i);
// Param p2 = params.get(j);
//
// if(!chosenValues.containsKey(p1) && !chosenValues.containsKey(p2)) {
// Pair p = pairs.consume(p1, p2);
// if(p != null) {
// chosenValues.put(p.p1.param, p.p1.value);
// chosenValues.put(p.p2.param, p.p2.value);
// }
// }
// }
// }
//
// // Step 2: convert our map to a list of output values, filling in any missing parameters from our selectors
// List<Object> values = new ArrayList<>(params.size());
// for(Param p : params) {
// if(chosenValues.containsKey(p)) {
// values.add(chosenValues.get(p));
// }
// else {
// values.add(selectors.get(p).next());
// }
// }
//
// testCases.add(values);
// }
//
// return testCases;
// }
//
// private static class Selector {
// private final Param p;
// private int i;
//
// Selector(Param p) {
// this.p = p;
// }
//
// Object next() {
// if(i >= p.values.size()) i = 0;
// return p.values.get(i++).value;
// }
// }
//
// }
| import com.redfin.fuzzy.pairwise.Pairwise;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors; | public static <INPUT, OUTPUT> Set<Subcase<OUTPUT>> mapOutput(
Set<Subcase<INPUT>> subcases,
Function<INPUT, OUTPUT> mapping
) {
FuzzyPreconditions.checkNotNull(subcases);
FuzzyPreconditions.checkNotNull(mapping);
Function<Subcase<INPUT>, Subcase<OUTPUT>> mapper =
s -> (r -> mapping.apply(s.generate(r)));
return subcases.stream().map(mapper).collect(Collectors.toSet());
}
public interface BiPermutedSupplierFunction<T, U, R> {
R generate(Random r, T t, U u);
}
public static <T, U, R> Set<Subcase<R>> pairwisePermutations(
Set<Subcase<T>> tSubcases,
Set<Subcase<U>> uSubcases,
BiPermutedSupplierFunction<T, U, R> func
) {
FuzzyPreconditions.checkNotNull(func);
FuzzyPreconditions.checkNotNull(tSubcases);
FuzzyPreconditions.checkNotNull(uSubcases);
List<Set> options = new ArrayList<>();
options.add(tSubcases);
options.add(uSubcases);
| // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/pairwise/Pairwise.java
// public class Pairwise<S extends Collection> {
//
// private final List<Param> params;
//
// public Pairwise(List<S> parameters) {
// FuzzyPreconditions.checkNotNull(parameters);
//
// List<Param> params = new ArrayList<>();
// int i = 0;
// for(Collection<?> parameter : parameters) {
// FuzzyPreconditions.checkNotNullAndContainsNoNulls(parameter);
// params.add(new Param(i++, new ArrayList<>(parameter)));
// }
//
// this.params = Collections.unmodifiableList(params);
// }
//
// /*package*/ PairSet generatePairs() {
// PairSet pairs = new PairSet();
//
// for(int i = 0; i < params.size() - 1; i++) {
// for(ParamValue p1 : params.get(i).values) {
// for(int j = i + 1; j < params.size(); j++) {
// for(ParamValue p2 : params.get(j).values) {
// pairs.register(new Pair(p1, p2));
// }
// }
// }
// }
//
// return pairs;
// }
//
// public Stack<List<Object>> generate() {
// // Special case: if there's only one parameter, then there are obviously no pairs. Just return all the parameter
// // values.
// if(params.size() == 1) {
// Stack<List<Object>> ret = new Stack<>();
// for(ParamValue value : params.get(0).values) {
// ret.push(Collections.singletonList(value.value));
// }
// return ret;
// }
//
// // Step 1: build some round-robin selectors for all of the parameters.
// Map<Param, Selector> selectors = new HashMap<>(params.size());
// for(Param p : params) selectors.put(p, new Selector(p));
//
// // Step 2: compute all of the expected pairs in our input set.
// PairSet pairs = generatePairs();
//
// // Step 3: start consuming pairs one at a time until each pair has been used.
// Stack<List<Object>> testCases = new Stack<>();
// while(!pairs.isEmpty()) {
// // Step a: perform an exhaustive search of any pairs we can add to this iteration.
// Map<Param, Object> chosenValues = new HashMap<>(params.size());
// for(int i = 0; i < params.size() - 1; i++) {
// for(int j = i + 1; j < params.size(); j++) {
// Param p1 = params.get(i);
// Param p2 = params.get(j);
//
// if(!chosenValues.containsKey(p1) && !chosenValues.containsKey(p2)) {
// Pair p = pairs.consume(p1, p2);
// if(p != null) {
// chosenValues.put(p.p1.param, p.p1.value);
// chosenValues.put(p.p2.param, p.p2.value);
// }
// }
// }
// }
//
// // Step 2: convert our map to a list of output values, filling in any missing parameters from our selectors
// List<Object> values = new ArrayList<>(params.size());
// for(Param p : params) {
// if(chosenValues.containsKey(p)) {
// values.add(chosenValues.get(p));
// }
// else {
// values.add(selectors.get(p).next());
// }
// }
//
// testCases.add(values);
// }
//
// return testCases;
// }
//
// private static class Selector {
// private final Param p;
// private int i;
//
// Selector(Param p) {
// this.p = p;
// }
//
// Object next() {
// if(i >= p.values.size()) i = 0;
// return p.values.get(i++).value;
// }
// }
//
// }
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Subcases.java
import com.redfin.fuzzy.pairwise.Pairwise;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
public static <INPUT, OUTPUT> Set<Subcase<OUTPUT>> mapOutput(
Set<Subcase<INPUT>> subcases,
Function<INPUT, OUTPUT> mapping
) {
FuzzyPreconditions.checkNotNull(subcases);
FuzzyPreconditions.checkNotNull(mapping);
Function<Subcase<INPUT>, Subcase<OUTPUT>> mapper =
s -> (r -> mapping.apply(s.generate(r)));
return subcases.stream().map(mapper).collect(Collectors.toSet());
}
public interface BiPermutedSupplierFunction<T, U, R> {
R generate(Random r, T t, U u);
}
public static <T, U, R> Set<Subcase<R>> pairwisePermutations(
Set<Subcase<T>> tSubcases,
Set<Subcase<U>> uSubcases,
BiPermutedSupplierFunction<T, U, R> func
) {
FuzzyPreconditions.checkNotNull(func);
FuzzyPreconditions.checkNotNull(tSubcases);
FuzzyPreconditions.checkNotNull(uSubcases);
List<Set> options = new ArrayList<>();
options.add(tSubcases);
options.add(uSubcases);
| List<List<Object>> permutations = (new Pairwise(options)).generate(); |
redfin/fuzzy | fuzzy-core/src/main/java/com/redfin/fuzzy/cases/LiteralCase.java | // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Case.java
// public interface Case<T>
// {
//
// /**
// * Returns the specific set of subcases that describe all equivalency classes for this case.
// *
// * <p>Cases are expected to return <em>at least one</em> subcase. When the fuzzy engine is determining how many test
// * cases to execute, it does so in terms of subcases, not cases. Thus, when using the pairwise permutation
// * algorithm, the fuzzy library works to ensure that each possible combination of two subcases are executed.</p>
// *
// * <p><strong>Note to implementors:</strong> cases should generally <em>not</em> include {@code null} values as
// * possible outputs. Instead, consumers are expected to use the {@link #orNull()} method (or, equivalently,
// * {@link Any#nullableOf}) to declare that their cases should also generate null values.</p>
// */
// Set<Subcase<T>> getSubcases();
//
// /**
// * Returns a new case that combines the subcases of this case and the provided {@code other} case. This method can
// * be used to combine different cases for a value into a single {@linkplain Generator generator}.
// */
// default Case<T> or(Case<T> other) { return Any.of(this, other); }
//
// /**
// * Returns a new case that combines the subcases of this case and a subcase specifically generating the value
// * {@code null}.
// */
// default Case<T> orNull() { return Any.nullableOf(this); }
//
// /**
// * Constrains the
// */
// default Case<T> excluding(T value) { return excluding(Collections.singleton(value)); }
// default Case<T> excluding(T... values) { return excluding(values == null ? null : Arrays.asList(values)); }
// default Case<T> excluding(Iterable<T> values) { return new ExcludingCase<>(this, values); }
//
// /**
// * Arbitrarily selects and returns the value of one of this case's subcases.
// */
// default T generateAnyOnce() { return generateAnyOnce(new Random()); }
//
// /**
// * Arbitrarily selects and returns the value of one of this case's subcases.
// *
// * @param random the random number generator that will be used to create the returned value.
// */
// default T generateAnyOnce(Random random) {
// FuzzyPreconditions.checkNotNull(random);
//
// Set<Subcase<T>> subcases = getSubcases();
//
// if(subcases == null || subcases.isEmpty())
// throw new IllegalStateException(String.format("Case of type %s generated zero suppliers.", getClass()));
//
// return subcases.stream().findAny().orElse(null).generate(random);
// }
//
// /**
// * Requests each of this case's subcases to generate and return a value.
// */
// default Set<T> generateAllOnce() { return generateAllOnce(new Random()); }
//
// /**
// * Requests each of this case's subcases to generate and return a value.
// *
// * @param random the random number generator that will be used to create the returned values.
// */
// default Set<T> generateAllOnce(Random random) {
// FuzzyPreconditions.checkNotNull(random);
//
// Set<Subcase<T>> subcases = getSubcases();
//
// if(subcases == null || subcases.isEmpty())
// throw new IllegalStateException(String.format("Case of type %s generated zero suppliers.", getClass()));
//
// return subcases.stream().map(s -> s.generate(random)).collect(Collectors.toSet());
// }
//
// }
//
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Subcase.java
// public interface Subcase<T> {
//
// /**
// * Instructs the subcase to generate and return a new value.
// *
// * <p>Subcases are not required to return exactly the same value for subsequent calls to {@code generate}; they may
// * randomly adjust their output on a per-call basis. However, subcases should adhere to the expectation that they
// * represent an <em>equivalency class</em> of output: although individual return values may differ, each value they
// * produce is effectively the same from a testing perspective.
// * </p>
// * <p>If the subcase does chose to produce randomized values, it should do so deterministically: two calls provided
// * with a random number generator with the same seed should produce exactly the same output. In general, this
// * condition should be satisfied if the test uses the provided {@linkplain Random random number generator} as its
// * only source of randomness.</p>
// */
// T generate(Random random);
//
// /**
// * Describes a given output produced by this subcase, for use in test failure reports.
// *
// * <p>The default implementation of this method attempts to provide helpful descriptions of {@code null}, common
// * primitives, strings, arrays, and collections. It defers to {@link Object#toString()} for all other descriptions.
// * </p>
// *
// * @param sink the string builder to which the description of the value should be appended.
// * @param value the value (as returned by this subcase's {@link #generate(Random) generate} method) that should be
// * described.
// */
// default void describeTo(StringBuilder sink, T value) {
// FuzzyPreconditions.checkNotNull(sink);
// FuzzyUtil.inspectTo(sink, value);
// }
//
// }
| import com.redfin.fuzzy.Case;
import com.redfin.fuzzy.Subcase;
import java.util.Collections;
import java.util.Random;
import java.util.Set; | package com.redfin.fuzzy.cases;
public class LiteralCase<T> implements Case<T> {
private final T literal;
@SuppressWarnings("unchecked")
public LiteralCase(T literal) {
this.literal = literal;
}
private T get(Random ignored) { return literal; }
@Override | // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Case.java
// public interface Case<T>
// {
//
// /**
// * Returns the specific set of subcases that describe all equivalency classes for this case.
// *
// * <p>Cases are expected to return <em>at least one</em> subcase. When the fuzzy engine is determining how many test
// * cases to execute, it does so in terms of subcases, not cases. Thus, when using the pairwise permutation
// * algorithm, the fuzzy library works to ensure that each possible combination of two subcases are executed.</p>
// *
// * <p><strong>Note to implementors:</strong> cases should generally <em>not</em> include {@code null} values as
// * possible outputs. Instead, consumers are expected to use the {@link #orNull()} method (or, equivalently,
// * {@link Any#nullableOf}) to declare that their cases should also generate null values.</p>
// */
// Set<Subcase<T>> getSubcases();
//
// /**
// * Returns a new case that combines the subcases of this case and the provided {@code other} case. This method can
// * be used to combine different cases for a value into a single {@linkplain Generator generator}.
// */
// default Case<T> or(Case<T> other) { return Any.of(this, other); }
//
// /**
// * Returns a new case that combines the subcases of this case and a subcase specifically generating the value
// * {@code null}.
// */
// default Case<T> orNull() { return Any.nullableOf(this); }
//
// /**
// * Constrains the
// */
// default Case<T> excluding(T value) { return excluding(Collections.singleton(value)); }
// default Case<T> excluding(T... values) { return excluding(values == null ? null : Arrays.asList(values)); }
// default Case<T> excluding(Iterable<T> values) { return new ExcludingCase<>(this, values); }
//
// /**
// * Arbitrarily selects and returns the value of one of this case's subcases.
// */
// default T generateAnyOnce() { return generateAnyOnce(new Random()); }
//
// /**
// * Arbitrarily selects and returns the value of one of this case's subcases.
// *
// * @param random the random number generator that will be used to create the returned value.
// */
// default T generateAnyOnce(Random random) {
// FuzzyPreconditions.checkNotNull(random);
//
// Set<Subcase<T>> subcases = getSubcases();
//
// if(subcases == null || subcases.isEmpty())
// throw new IllegalStateException(String.format("Case of type %s generated zero suppliers.", getClass()));
//
// return subcases.stream().findAny().orElse(null).generate(random);
// }
//
// /**
// * Requests each of this case's subcases to generate and return a value.
// */
// default Set<T> generateAllOnce() { return generateAllOnce(new Random()); }
//
// /**
// * Requests each of this case's subcases to generate and return a value.
// *
// * @param random the random number generator that will be used to create the returned values.
// */
// default Set<T> generateAllOnce(Random random) {
// FuzzyPreconditions.checkNotNull(random);
//
// Set<Subcase<T>> subcases = getSubcases();
//
// if(subcases == null || subcases.isEmpty())
// throw new IllegalStateException(String.format("Case of type %s generated zero suppliers.", getClass()));
//
// return subcases.stream().map(s -> s.generate(random)).collect(Collectors.toSet());
// }
//
// }
//
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Subcase.java
// public interface Subcase<T> {
//
// /**
// * Instructs the subcase to generate and return a new value.
// *
// * <p>Subcases are not required to return exactly the same value for subsequent calls to {@code generate}; they may
// * randomly adjust their output on a per-call basis. However, subcases should adhere to the expectation that they
// * represent an <em>equivalency class</em> of output: although individual return values may differ, each value they
// * produce is effectively the same from a testing perspective.
// * </p>
// * <p>If the subcase does chose to produce randomized values, it should do so deterministically: two calls provided
// * with a random number generator with the same seed should produce exactly the same output. In general, this
// * condition should be satisfied if the test uses the provided {@linkplain Random random number generator} as its
// * only source of randomness.</p>
// */
// T generate(Random random);
//
// /**
// * Describes a given output produced by this subcase, for use in test failure reports.
// *
// * <p>The default implementation of this method attempts to provide helpful descriptions of {@code null}, common
// * primitives, strings, arrays, and collections. It defers to {@link Object#toString()} for all other descriptions.
// * </p>
// *
// * @param sink the string builder to which the description of the value should be appended.
// * @param value the value (as returned by this subcase's {@link #generate(Random) generate} method) that should be
// * described.
// */
// default void describeTo(StringBuilder sink, T value) {
// FuzzyPreconditions.checkNotNull(sink);
// FuzzyUtil.inspectTo(sink, value);
// }
//
// }
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/cases/LiteralCase.java
import com.redfin.fuzzy.Case;
import com.redfin.fuzzy.Subcase;
import java.util.Collections;
import java.util.Random;
import java.util.Set;
package com.redfin.fuzzy.cases;
public class LiteralCase<T> implements Case<T> {
private final T literal;
@SuppressWarnings("unchecked")
public LiteralCase(T literal) {
this.literal = literal;
}
private T get(Random ignored) { return literal; }
@Override | public Set<Subcase<T>> getSubcases() { |
redfin/fuzzy | fuzzy-core/src/main/java/com/redfin/fuzzy/cases/DoubleNumericCase.java | // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Case.java
// public interface Case<T>
// {
//
// /**
// * Returns the specific set of subcases that describe all equivalency classes for this case.
// *
// * <p>Cases are expected to return <em>at least one</em> subcase. When the fuzzy engine is determining how many test
// * cases to execute, it does so in terms of subcases, not cases. Thus, when using the pairwise permutation
// * algorithm, the fuzzy library works to ensure that each possible combination of two subcases are executed.</p>
// *
// * <p><strong>Note to implementors:</strong> cases should generally <em>not</em> include {@code null} values as
// * possible outputs. Instead, consumers are expected to use the {@link #orNull()} method (or, equivalently,
// * {@link Any#nullableOf}) to declare that their cases should also generate null values.</p>
// */
// Set<Subcase<T>> getSubcases();
//
// /**
// * Returns a new case that combines the subcases of this case and the provided {@code other} case. This method can
// * be used to combine different cases for a value into a single {@linkplain Generator generator}.
// */
// default Case<T> or(Case<T> other) { return Any.of(this, other); }
//
// /**
// * Returns a new case that combines the subcases of this case and a subcase specifically generating the value
// * {@code null}.
// */
// default Case<T> orNull() { return Any.nullableOf(this); }
//
// /**
// * Constrains the
// */
// default Case<T> excluding(T value) { return excluding(Collections.singleton(value)); }
// default Case<T> excluding(T... values) { return excluding(values == null ? null : Arrays.asList(values)); }
// default Case<T> excluding(Iterable<T> values) { return new ExcludingCase<>(this, values); }
//
// /**
// * Arbitrarily selects and returns the value of one of this case's subcases.
// */
// default T generateAnyOnce() { return generateAnyOnce(new Random()); }
//
// /**
// * Arbitrarily selects and returns the value of one of this case's subcases.
// *
// * @param random the random number generator that will be used to create the returned value.
// */
// default T generateAnyOnce(Random random) {
// FuzzyPreconditions.checkNotNull(random);
//
// Set<Subcase<T>> subcases = getSubcases();
//
// if(subcases == null || subcases.isEmpty())
// throw new IllegalStateException(String.format("Case of type %s generated zero suppliers.", getClass()));
//
// return subcases.stream().findAny().orElse(null).generate(random);
// }
//
// /**
// * Requests each of this case's subcases to generate and return a value.
// */
// default Set<T> generateAllOnce() { return generateAllOnce(new Random()); }
//
// /**
// * Requests each of this case's subcases to generate and return a value.
// *
// * @param random the random number generator that will be used to create the returned values.
// */
// default Set<T> generateAllOnce(Random random) {
// FuzzyPreconditions.checkNotNull(random);
//
// Set<Subcase<T>> subcases = getSubcases();
//
// if(subcases == null || subcases.isEmpty())
// throw new IllegalStateException(String.format("Case of type %s generated zero suppliers.", getClass()));
//
// return subcases.stream().map(s -> s.generate(random)).collect(Collectors.toSet());
// }
//
// }
//
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Subcase.java
// public interface Subcase<T> {
//
// /**
// * Instructs the subcase to generate and return a new value.
// *
// * <p>Subcases are not required to return exactly the same value for subsequent calls to {@code generate}; they may
// * randomly adjust their output on a per-call basis. However, subcases should adhere to the expectation that they
// * represent an <em>equivalency class</em> of output: although individual return values may differ, each value they
// * produce is effectively the same from a testing perspective.
// * </p>
// * <p>If the subcase does chose to produce randomized values, it should do so deterministically: two calls provided
// * with a random number generator with the same seed should produce exactly the same output. In general, this
// * condition should be satisfied if the test uses the provided {@linkplain Random random number generator} as its
// * only source of randomness.</p>
// */
// T generate(Random random);
//
// /**
// * Describes a given output produced by this subcase, for use in test failure reports.
// *
// * <p>The default implementation of this method attempts to provide helpful descriptions of {@code null}, common
// * primitives, strings, arrays, and collections. It defers to {@link Object#toString()} for all other descriptions.
// * </p>
// *
// * @param sink the string builder to which the description of the value should be appended.
// * @param value the value (as returned by this subcase's {@link #generate(Random) generate} method) that should be
// * described.
// */
// default void describeTo(StringBuilder sink, T value) {
// FuzzyPreconditions.checkNotNull(sink);
// FuzzyUtil.inspectTo(sink, value);
// }
//
// }
| import com.redfin.fuzzy.Case;
import com.redfin.fuzzy.Subcase;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors; | min = null;
return this;
}
public Case<Double> greaterThan(double minExclusive) {
min = minExclusive;
max = null;
excluding.add(min);
return this;
}
public Case<Double> greaterThanOrEqualTo(double minInclusive) {
max = null;
min = minInclusive;
return this;
}
@Override
public DoubleNumericCase excluding(Iterable<Double> values) {
if(values != null)
for(Double d : values)
if(d != null)
excluding.add(d);
return this;
}
| // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Case.java
// public interface Case<T>
// {
//
// /**
// * Returns the specific set of subcases that describe all equivalency classes for this case.
// *
// * <p>Cases are expected to return <em>at least one</em> subcase. When the fuzzy engine is determining how many test
// * cases to execute, it does so in terms of subcases, not cases. Thus, when using the pairwise permutation
// * algorithm, the fuzzy library works to ensure that each possible combination of two subcases are executed.</p>
// *
// * <p><strong>Note to implementors:</strong> cases should generally <em>not</em> include {@code null} values as
// * possible outputs. Instead, consumers are expected to use the {@link #orNull()} method (or, equivalently,
// * {@link Any#nullableOf}) to declare that their cases should also generate null values.</p>
// */
// Set<Subcase<T>> getSubcases();
//
// /**
// * Returns a new case that combines the subcases of this case and the provided {@code other} case. This method can
// * be used to combine different cases for a value into a single {@linkplain Generator generator}.
// */
// default Case<T> or(Case<T> other) { return Any.of(this, other); }
//
// /**
// * Returns a new case that combines the subcases of this case and a subcase specifically generating the value
// * {@code null}.
// */
// default Case<T> orNull() { return Any.nullableOf(this); }
//
// /**
// * Constrains the
// */
// default Case<T> excluding(T value) { return excluding(Collections.singleton(value)); }
// default Case<T> excluding(T... values) { return excluding(values == null ? null : Arrays.asList(values)); }
// default Case<T> excluding(Iterable<T> values) { return new ExcludingCase<>(this, values); }
//
// /**
// * Arbitrarily selects and returns the value of one of this case's subcases.
// */
// default T generateAnyOnce() { return generateAnyOnce(new Random()); }
//
// /**
// * Arbitrarily selects and returns the value of one of this case's subcases.
// *
// * @param random the random number generator that will be used to create the returned value.
// */
// default T generateAnyOnce(Random random) {
// FuzzyPreconditions.checkNotNull(random);
//
// Set<Subcase<T>> subcases = getSubcases();
//
// if(subcases == null || subcases.isEmpty())
// throw new IllegalStateException(String.format("Case of type %s generated zero suppliers.", getClass()));
//
// return subcases.stream().findAny().orElse(null).generate(random);
// }
//
// /**
// * Requests each of this case's subcases to generate and return a value.
// */
// default Set<T> generateAllOnce() { return generateAllOnce(new Random()); }
//
// /**
// * Requests each of this case's subcases to generate and return a value.
// *
// * @param random the random number generator that will be used to create the returned values.
// */
// default Set<T> generateAllOnce(Random random) {
// FuzzyPreconditions.checkNotNull(random);
//
// Set<Subcase<T>> subcases = getSubcases();
//
// if(subcases == null || subcases.isEmpty())
// throw new IllegalStateException(String.format("Case of type %s generated zero suppliers.", getClass()));
//
// return subcases.stream().map(s -> s.generate(random)).collect(Collectors.toSet());
// }
//
// }
//
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Subcase.java
// public interface Subcase<T> {
//
// /**
// * Instructs the subcase to generate and return a new value.
// *
// * <p>Subcases are not required to return exactly the same value for subsequent calls to {@code generate}; they may
// * randomly adjust their output on a per-call basis. However, subcases should adhere to the expectation that they
// * represent an <em>equivalency class</em> of output: although individual return values may differ, each value they
// * produce is effectively the same from a testing perspective.
// * </p>
// * <p>If the subcase does chose to produce randomized values, it should do so deterministically: two calls provided
// * with a random number generator with the same seed should produce exactly the same output. In general, this
// * condition should be satisfied if the test uses the provided {@linkplain Random random number generator} as its
// * only source of randomness.</p>
// */
// T generate(Random random);
//
// /**
// * Describes a given output produced by this subcase, for use in test failure reports.
// *
// * <p>The default implementation of this method attempts to provide helpful descriptions of {@code null}, common
// * primitives, strings, arrays, and collections. It defers to {@link Object#toString()} for all other descriptions.
// * </p>
// *
// * @param sink the string builder to which the description of the value should be appended.
// * @param value the value (as returned by this subcase's {@link #generate(Random) generate} method) that should be
// * described.
// */
// default void describeTo(StringBuilder sink, T value) {
// FuzzyPreconditions.checkNotNull(sink);
// FuzzyUtil.inspectTo(sink, value);
// }
//
// }
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/cases/DoubleNumericCase.java
import com.redfin.fuzzy.Case;
import com.redfin.fuzzy.Subcase;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
min = null;
return this;
}
public Case<Double> greaterThan(double minExclusive) {
min = minExclusive;
max = null;
excluding.add(min);
return this;
}
public Case<Double> greaterThanOrEqualTo(double minInclusive) {
max = null;
min = minInclusive;
return this;
}
@Override
public DoubleNumericCase excluding(Iterable<Double> values) {
if(values != null)
for(Double d : values)
if(d != null)
excluding.add(d);
return this;
}
| private Subcase<Double> exclude(Subcase<Double> subcase) { |
redfin/fuzzy | fuzzy-core/src/main/java/com/redfin/fuzzy/Context.java | // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/pairwise/Pairwise.java
// public class Pairwise<S extends Collection> {
//
// private final List<Param> params;
//
// public Pairwise(List<S> parameters) {
// FuzzyPreconditions.checkNotNull(parameters);
//
// List<Param> params = new ArrayList<>();
// int i = 0;
// for(Collection<?> parameter : parameters) {
// FuzzyPreconditions.checkNotNullAndContainsNoNulls(parameter);
// params.add(new Param(i++, new ArrayList<>(parameter)));
// }
//
// this.params = Collections.unmodifiableList(params);
// }
//
// /*package*/ PairSet generatePairs() {
// PairSet pairs = new PairSet();
//
// for(int i = 0; i < params.size() - 1; i++) {
// for(ParamValue p1 : params.get(i).values) {
// for(int j = i + 1; j < params.size(); j++) {
// for(ParamValue p2 : params.get(j).values) {
// pairs.register(new Pair(p1, p2));
// }
// }
// }
// }
//
// return pairs;
// }
//
// public Stack<List<Object>> generate() {
// // Special case: if there's only one parameter, then there are obviously no pairs. Just return all the parameter
// // values.
// if(params.size() == 1) {
// Stack<List<Object>> ret = new Stack<>();
// for(ParamValue value : params.get(0).values) {
// ret.push(Collections.singletonList(value.value));
// }
// return ret;
// }
//
// // Step 1: build some round-robin selectors for all of the parameters.
// Map<Param, Selector> selectors = new HashMap<>(params.size());
// for(Param p : params) selectors.put(p, new Selector(p));
//
// // Step 2: compute all of the expected pairs in our input set.
// PairSet pairs = generatePairs();
//
// // Step 3: start consuming pairs one at a time until each pair has been used.
// Stack<List<Object>> testCases = new Stack<>();
// while(!pairs.isEmpty()) {
// // Step a: perform an exhaustive search of any pairs we can add to this iteration.
// Map<Param, Object> chosenValues = new HashMap<>(params.size());
// for(int i = 0; i < params.size() - 1; i++) {
// for(int j = i + 1; j < params.size(); j++) {
// Param p1 = params.get(i);
// Param p2 = params.get(j);
//
// if(!chosenValues.containsKey(p1) && !chosenValues.containsKey(p2)) {
// Pair p = pairs.consume(p1, p2);
// if(p != null) {
// chosenValues.put(p.p1.param, p.p1.value);
// chosenValues.put(p.p2.param, p.p2.value);
// }
// }
// }
// }
//
// // Step 2: convert our map to a list of output values, filling in any missing parameters from our selectors
// List<Object> values = new ArrayList<>(params.size());
// for(Param p : params) {
// if(chosenValues.containsKey(p)) {
// values.add(chosenValues.get(p));
// }
// else {
// values.add(selectors.get(p).next());
// }
// }
//
// testCases.add(values);
// }
//
// return testCases;
// }
//
// private static class Selector {
// private final Param p;
// private int i;
//
// Selector(Param p) {
// this.p = p;
// }
//
// Object next() {
// if(i >= p.values.size()) i = 0;
// return p.values.get(i++).value;
// }
// }
//
// }
| import com.redfin.fuzzy.pairwise.Pairwise;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Stack; |
// Technically, nothing bad happens if this run does not define a generator that the previous run did; still
// it probably means that they're setting tests up weird so we'll still complain.
if(generators.size() != previousGenerators.size())
throw newInconsistentGeneratorsException();
}
private void generateTestCases() {
iterations = new Stack<>();
if(generators.isEmpty())
return;
List<Variable> variables = new ArrayList<>();
for(Map.Entry<Generator, Case[]> generator : generators.entrySet()) {
variables.add(new Variable(generator.getKey(), generator.getValue()));
}
if(!variables.isEmpty()) {
if (caseCompositionMode.equals(CaseCompositionMode.PAIRWISE_PERMUTATIONS_OF_SUBCASES)) {
generatePairwiseTestCases(variables);
} else if (caseCompositionMode.equals(CaseCompositionMode.EACH_SUBCASE_AT_LEAST_ONCE)) {
generateEachSubcaseAtLeastOnceCases(variables);
} else {
throw new IllegalStateException("Unexpected caseCompositionMode " + caseCompositionMode);
}
}
}
private void generatePairwiseTestCases(List<Variable> variables) { | // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/pairwise/Pairwise.java
// public class Pairwise<S extends Collection> {
//
// private final List<Param> params;
//
// public Pairwise(List<S> parameters) {
// FuzzyPreconditions.checkNotNull(parameters);
//
// List<Param> params = new ArrayList<>();
// int i = 0;
// for(Collection<?> parameter : parameters) {
// FuzzyPreconditions.checkNotNullAndContainsNoNulls(parameter);
// params.add(new Param(i++, new ArrayList<>(parameter)));
// }
//
// this.params = Collections.unmodifiableList(params);
// }
//
// /*package*/ PairSet generatePairs() {
// PairSet pairs = new PairSet();
//
// for(int i = 0; i < params.size() - 1; i++) {
// for(ParamValue p1 : params.get(i).values) {
// for(int j = i + 1; j < params.size(); j++) {
// for(ParamValue p2 : params.get(j).values) {
// pairs.register(new Pair(p1, p2));
// }
// }
// }
// }
//
// return pairs;
// }
//
// public Stack<List<Object>> generate() {
// // Special case: if there's only one parameter, then there are obviously no pairs. Just return all the parameter
// // values.
// if(params.size() == 1) {
// Stack<List<Object>> ret = new Stack<>();
// for(ParamValue value : params.get(0).values) {
// ret.push(Collections.singletonList(value.value));
// }
// return ret;
// }
//
// // Step 1: build some round-robin selectors for all of the parameters.
// Map<Param, Selector> selectors = new HashMap<>(params.size());
// for(Param p : params) selectors.put(p, new Selector(p));
//
// // Step 2: compute all of the expected pairs in our input set.
// PairSet pairs = generatePairs();
//
// // Step 3: start consuming pairs one at a time until each pair has been used.
// Stack<List<Object>> testCases = new Stack<>();
// while(!pairs.isEmpty()) {
// // Step a: perform an exhaustive search of any pairs we can add to this iteration.
// Map<Param, Object> chosenValues = new HashMap<>(params.size());
// for(int i = 0; i < params.size() - 1; i++) {
// for(int j = i + 1; j < params.size(); j++) {
// Param p1 = params.get(i);
// Param p2 = params.get(j);
//
// if(!chosenValues.containsKey(p1) && !chosenValues.containsKey(p2)) {
// Pair p = pairs.consume(p1, p2);
// if(p != null) {
// chosenValues.put(p.p1.param, p.p1.value);
// chosenValues.put(p.p2.param, p.p2.value);
// }
// }
// }
// }
//
// // Step 2: convert our map to a list of output values, filling in any missing parameters from our selectors
// List<Object> values = new ArrayList<>(params.size());
// for(Param p : params) {
// if(chosenValues.containsKey(p)) {
// values.add(chosenValues.get(p));
// }
// else {
// values.add(selectors.get(p).next());
// }
// }
//
// testCases.add(values);
// }
//
// return testCases;
// }
//
// private static class Selector {
// private final Param p;
// private int i;
//
// Selector(Param p) {
// this.p = p;
// }
//
// Object next() {
// if(i >= p.values.size()) i = 0;
// return p.values.get(i++).value;
// }
// }
//
// }
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Context.java
import com.redfin.fuzzy.pairwise.Pairwise;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Stack;
// Technically, nothing bad happens if this run does not define a generator that the previous run did; still
// it probably means that they're setting tests up weird so we'll still complain.
if(generators.size() != previousGenerators.size())
throw newInconsistentGeneratorsException();
}
private void generateTestCases() {
iterations = new Stack<>();
if(generators.isEmpty())
return;
List<Variable> variables = new ArrayList<>();
for(Map.Entry<Generator, Case[]> generator : generators.entrySet()) {
variables.add(new Variable(generator.getKey(), generator.getValue()));
}
if(!variables.isEmpty()) {
if (caseCompositionMode.equals(CaseCompositionMode.PAIRWISE_PERMUTATIONS_OF_SUBCASES)) {
generatePairwiseTestCases(variables);
} else if (caseCompositionMode.equals(CaseCompositionMode.EACH_SUBCASE_AT_LEAST_ONCE)) {
generateEachSubcaseAtLeastOnceCases(variables);
} else {
throw new IllegalStateException("Unexpected caseCompositionMode " + caseCompositionMode);
}
}
}
private void generatePairwiseTestCases(List<Variable> variables) { | Pairwise<Variable> permuter = new Pairwise<>(variables); |
redfin/fuzzy | fuzzy-core/src/main/java/com/redfin/fuzzy/Literal.java | // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/cases/LiteralCase.java
// public class LiteralCase<T> implements Case<T> {
//
// private final T literal;
//
// @SuppressWarnings("unchecked")
// public LiteralCase(T literal) {
// this.literal = literal;
// }
//
// private T get(Random ignored) { return literal; }
//
// @Override
// public Set<Subcase<T>> getSubcases() {
// return Collections.singleton(this::get);
// }
//
// }
| import com.redfin.fuzzy.cases.LiteralCase; | package com.redfin.fuzzy;
public class Literal {
public static <T> Case<T> value(T value) { | // Path: fuzzy-core/src/main/java/com/redfin/fuzzy/cases/LiteralCase.java
// public class LiteralCase<T> implements Case<T> {
//
// private final T literal;
//
// @SuppressWarnings("unchecked")
// public LiteralCase(T literal) {
// this.literal = literal;
// }
//
// private T get(Random ignored) { return literal; }
//
// @Override
// public Set<Subcase<T>> getSubcases() {
// return Collections.singleton(this::get);
// }
//
// }
// Path: fuzzy-core/src/main/java/com/redfin/fuzzy/Literal.java
import com.redfin.fuzzy.cases.LiteralCase;
package com.redfin.fuzzy;
public class Literal {
public static <T> Case<T> value(T value) { | return new LiteralCase<>(value); |
acmeair/acmeair | acmeair-services/src/main/java/com/acmeair/service/CustomerService.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
//
//
// public String getId();
//
//
// public String getCustomerid();
//
//
// public Date getLastAccessedTime();
//
//
// public Date getTimeoutTime();
//
//
// }
| import java.util.Calendar;
import java.util.Date;
import javax.inject.Inject;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.entities.Customer.MemberShipStatus;
import com.acmeair.entities.Customer.PhoneType;
import com.acmeair.entities.CustomerSession; | /*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.service;
public abstract class CustomerService {
protected static final int DAYS_TO_ALLOW_SESSION = 1;
@Inject
protected KeyGenerator keyGenerator;
| // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
//
//
// public String getId();
//
//
// public String getCustomerid();
//
//
// public Date getLastAccessedTime();
//
//
// public Date getTimeoutTime();
//
//
// }
// Path: acmeair-services/src/main/java/com/acmeair/service/CustomerService.java
import java.util.Calendar;
import java.util.Date;
import javax.inject.Inject;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.entities.Customer.MemberShipStatus;
import com.acmeair.entities.Customer.PhoneType;
import com.acmeair.entities.CustomerSession;
/*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.service;
public abstract class CustomerService {
protected static final int DAYS_TO_ALLOW_SESSION = 1;
@Inject
protected KeyGenerator keyGenerator;
| public abstract Customer createCustomer( |
acmeair/acmeair | acmeair-services/src/main/java/com/acmeair/service/CustomerService.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
//
//
// public String getId();
//
//
// public String getCustomerid();
//
//
// public Date getLastAccessedTime();
//
//
// public Date getTimeoutTime();
//
//
// }
| import java.util.Calendar;
import java.util.Date;
import javax.inject.Inject;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.entities.Customer.MemberShipStatus;
import com.acmeair.entities.Customer.PhoneType;
import com.acmeair.entities.CustomerSession; | /*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.service;
public abstract class CustomerService {
protected static final int DAYS_TO_ALLOW_SESSION = 1;
@Inject
protected KeyGenerator keyGenerator;
public abstract Customer createCustomer( | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
//
//
// public String getId();
//
//
// public String getCustomerid();
//
//
// public Date getLastAccessedTime();
//
//
// public Date getTimeoutTime();
//
//
// }
// Path: acmeair-services/src/main/java/com/acmeair/service/CustomerService.java
import java.util.Calendar;
import java.util.Date;
import javax.inject.Inject;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.entities.Customer.MemberShipStatus;
import com.acmeair.entities.Customer.PhoneType;
import com.acmeair.entities.CustomerSession;
/*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.service;
public abstract class CustomerService {
protected static final int DAYS_TO_ALLOW_SESSION = 1;
@Inject
protected KeyGenerator keyGenerator;
public abstract Customer createCustomer( | String username, String password, MemberShipStatus status, int total_miles, |
acmeair/acmeair | acmeair-services/src/main/java/com/acmeair/service/CustomerService.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
//
//
// public String getId();
//
//
// public String getCustomerid();
//
//
// public Date getLastAccessedTime();
//
//
// public Date getTimeoutTime();
//
//
// }
| import java.util.Calendar;
import java.util.Date;
import javax.inject.Inject;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.entities.Customer.MemberShipStatus;
import com.acmeair.entities.Customer.PhoneType;
import com.acmeair.entities.CustomerSession; | /*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.service;
public abstract class CustomerService {
protected static final int DAYS_TO_ALLOW_SESSION = 1;
@Inject
protected KeyGenerator keyGenerator;
public abstract Customer createCustomer(
String username, String password, MemberShipStatus status, int total_miles, | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
//
//
// public String getId();
//
//
// public String getCustomerid();
//
//
// public Date getLastAccessedTime();
//
//
// public Date getTimeoutTime();
//
//
// }
// Path: acmeair-services/src/main/java/com/acmeair/service/CustomerService.java
import java.util.Calendar;
import java.util.Date;
import javax.inject.Inject;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.entities.Customer.MemberShipStatus;
import com.acmeair.entities.Customer.PhoneType;
import com.acmeair.entities.CustomerSession;
/*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.service;
public abstract class CustomerService {
protected static final int DAYS_TO_ALLOW_SESSION = 1;
@Inject
protected KeyGenerator keyGenerator;
public abstract Customer createCustomer(
String username, String password, MemberShipStatus status, int total_miles, | int miles_ytd, String phoneNumber, PhoneType phoneNumberType, CustomerAddress address); |
acmeair/acmeair | acmeair-services/src/main/java/com/acmeair/service/CustomerService.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
//
//
// public String getId();
//
//
// public String getCustomerid();
//
//
// public Date getLastAccessedTime();
//
//
// public Date getTimeoutTime();
//
//
// }
| import java.util.Calendar;
import java.util.Date;
import javax.inject.Inject;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.entities.Customer.MemberShipStatus;
import com.acmeair.entities.Customer.PhoneType;
import com.acmeair.entities.CustomerSession; | /*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.service;
public abstract class CustomerService {
protected static final int DAYS_TO_ALLOW_SESSION = 1;
@Inject
protected KeyGenerator keyGenerator;
public abstract Customer createCustomer(
String username, String password, MemberShipStatus status, int total_miles, | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
//
//
// public String getId();
//
//
// public String getCustomerid();
//
//
// public Date getLastAccessedTime();
//
//
// public Date getTimeoutTime();
//
//
// }
// Path: acmeair-services/src/main/java/com/acmeair/service/CustomerService.java
import java.util.Calendar;
import java.util.Date;
import javax.inject.Inject;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.entities.Customer.MemberShipStatus;
import com.acmeair.entities.Customer.PhoneType;
import com.acmeair.entities.CustomerSession;
/*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.service;
public abstract class CustomerService {
protected static final int DAYS_TO_ALLOW_SESSION = 1;
@Inject
protected KeyGenerator keyGenerator;
public abstract Customer createCustomer(
String username, String password, MemberShipStatus status, int total_miles, | int miles_ytd, String phoneNumber, PhoneType phoneNumberType, CustomerAddress address); |
acmeair/acmeair | acmeair-services/src/main/java/com/acmeair/service/CustomerService.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
//
//
// public String getId();
//
//
// public String getCustomerid();
//
//
// public Date getLastAccessedTime();
//
//
// public Date getTimeoutTime();
//
//
// }
| import java.util.Calendar;
import java.util.Date;
import javax.inject.Inject;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.entities.Customer.MemberShipStatus;
import com.acmeair.entities.Customer.PhoneType;
import com.acmeair.entities.CustomerSession; |
protected abstract Customer getCustomer(String username);
public Customer getCustomerByUsername(String username) {
Customer c = getCustomer(username);
if (c != null) {
c.setPassword(null);
}
return c;
}
public boolean validateCustomer(String username, String password) {
boolean validatedCustomer = false;
Customer customerToValidate = getCustomer(username);
if (customerToValidate != null) {
validatedCustomer = password.equals(customerToValidate.getPassword());
}
return validatedCustomer;
}
public Customer getCustomerByUsernameAndPassword(String username,
String password) {
Customer c = getCustomer(username);
if (!c.getPassword().equals(password)) {
return null;
}
// Should we also set the password to null?
return c;
}
| // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
//
//
// public String getId();
//
//
// public String getCustomerid();
//
//
// public Date getLastAccessedTime();
//
//
// public Date getTimeoutTime();
//
//
// }
// Path: acmeair-services/src/main/java/com/acmeair/service/CustomerService.java
import java.util.Calendar;
import java.util.Date;
import javax.inject.Inject;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.entities.Customer.MemberShipStatus;
import com.acmeair.entities.Customer.PhoneType;
import com.acmeair.entities.CustomerSession;
protected abstract Customer getCustomer(String username);
public Customer getCustomerByUsername(String username) {
Customer c = getCustomer(username);
if (c != null) {
c.setPassword(null);
}
return c;
}
public boolean validateCustomer(String username, String password) {
boolean validatedCustomer = false;
Customer customerToValidate = getCustomer(username);
if (customerToValidate != null) {
validatedCustomer = password.equals(customerToValidate.getPassword());
}
return validatedCustomer;
}
public Customer getCustomerByUsernameAndPassword(String username,
String password) {
Customer c = getCustomer(username);
if (!c.getPassword().equals(password)) {
return null;
}
// Should we also set the password to null?
return c;
}
| public CustomerSession validateSession(String sessionid) { |
acmeair/acmeair | acmeair-services-wxs/src/main/java/com/acmeair/wxs/entities/BookingImpl.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Booking.java
// public interface Booking {
//
//
// public String getBookingId();
//
//
// public String getFlightId();
//
//
// public String getCustomerId();
//
//
// public Date getDateOfBooking();
//
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
| import java.io.Serializable;
import java.util.*;
import com.acmeair.entities.Booking;
import com.acmeair.entities.Customer;
import com.acmeair.entities.Flight; | /*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.wxs.entities;
public class BookingImpl implements Booking, Serializable{
private static final long serialVersionUID = 1L;
private BookingPKImpl pkey;
private FlightPKImpl flightKey;
private Date dateOfBooking; | // Path: acmeair-common/src/main/java/com/acmeair/entities/Booking.java
// public interface Booking {
//
//
// public String getBookingId();
//
//
// public String getFlightId();
//
//
// public String getCustomerId();
//
//
// public Date getDateOfBooking();
//
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
// Path: acmeair-services-wxs/src/main/java/com/acmeair/wxs/entities/BookingImpl.java
import java.io.Serializable;
import java.util.*;
import com.acmeair.entities.Booking;
import com.acmeair.entities.Customer;
import com.acmeair.entities.Flight;
/*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.wxs.entities;
public class BookingImpl implements Booking, Serializable{
private static final long serialVersionUID = 1L;
private BookingPKImpl pkey;
private FlightPKImpl flightKey;
private Date dateOfBooking; | private Customer customer; |
acmeair/acmeair | acmeair-services-morphia/src/main/java/com/acmeair/morphia/DatastoreFactory.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Booking.java
// public interface Booking {
//
//
// public String getBookingId();
//
//
// public String getFlightId();
//
//
// public String getCustomerId();
//
//
// public Date getDateOfBooking();
//
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/FlightSegment.java
// public interface FlightSegment {
//
// public String getFlightName();
//
// public String getOriginPort();
//
// public String getDestPort();
//
// public int getMiles();
//
// }
| import java.util.Properties;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import com.acmeair.entities.Booking;
import com.acmeair.entities.Flight;
import com.acmeair.entities.FlightSegment;
import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.Morphia;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoClientURI;
import com.mongodb.WriteConcern; | {
try{
Properties prop = new Properties();
prop.load(DatastoreFactory.class.getResource("/acmeair-mongo.properties").openStream());
boolean fsync = new Boolean(prop.getProperty("mongo.fsync"));
int w = new Integer(prop.getProperty("mongo.w"));
int connectionsPerHost = new Integer(prop.getProperty("mongo.connectionsPerHost"));
int threadsAllowedToBlockForConnectionMultiplier = new Integer(prop.getProperty("mongo.threadsAllowedToBlockForConnectionMultiplier"));
// To match the local options
MongoClientOptions.Builder builder = new MongoClientOptions.Builder()
.writeConcern(new WriteConcern(w, 0, fsync))
.connectionsPerHost(connectionsPerHost)
.threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier);
MongoClientURI mongoURI = new MongoClientURI(mongourl, builder);
MongoClient mongo = new MongoClient(mongoURI);
Morphia morphia = new Morphia();
result = morphia.createDatastore( mongo ,mongoURI.getDatabase());
System.out.println("create mongo datastore with options:"+result.getMongo().getMongoClientOptions());
}catch (Exception e)
{
e.printStackTrace();
}
}
// The converter is added for handing JDK 7 issue
// result.getMapper().getConverters().addConverter(new BigDecimalConverter());
// result.getMapper().getConverters().addConverter(new BigIntegerConverter());
// Enable index | // Path: acmeair-common/src/main/java/com/acmeair/entities/Booking.java
// public interface Booking {
//
//
// public String getBookingId();
//
//
// public String getFlightId();
//
//
// public String getCustomerId();
//
//
// public Date getDateOfBooking();
//
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/FlightSegment.java
// public interface FlightSegment {
//
// public String getFlightName();
//
// public String getOriginPort();
//
// public String getDestPort();
//
// public int getMiles();
//
// }
// Path: acmeair-services-morphia/src/main/java/com/acmeair/morphia/DatastoreFactory.java
import java.util.Properties;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import com.acmeair.entities.Booking;
import com.acmeair.entities.Flight;
import com.acmeair.entities.FlightSegment;
import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.Morphia;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoClientURI;
import com.mongodb.WriteConcern;
{
try{
Properties prop = new Properties();
prop.load(DatastoreFactory.class.getResource("/acmeair-mongo.properties").openStream());
boolean fsync = new Boolean(prop.getProperty("mongo.fsync"));
int w = new Integer(prop.getProperty("mongo.w"));
int connectionsPerHost = new Integer(prop.getProperty("mongo.connectionsPerHost"));
int threadsAllowedToBlockForConnectionMultiplier = new Integer(prop.getProperty("mongo.threadsAllowedToBlockForConnectionMultiplier"));
// To match the local options
MongoClientOptions.Builder builder = new MongoClientOptions.Builder()
.writeConcern(new WriteConcern(w, 0, fsync))
.connectionsPerHost(connectionsPerHost)
.threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier);
MongoClientURI mongoURI = new MongoClientURI(mongourl, builder);
MongoClient mongo = new MongoClient(mongoURI);
Morphia morphia = new Morphia();
result = morphia.createDatastore( mongo ,mongoURI.getDatabase());
System.out.println("create mongo datastore with options:"+result.getMongo().getMongoClientOptions());
}catch (Exception e)
{
e.printStackTrace();
}
}
// The converter is added for handing JDK 7 issue
// result.getMapper().getConverters().addConverter(new BigDecimalConverter());
// result.getMapper().getConverters().addConverter(new BigIntegerConverter());
// Enable index | result.ensureIndex(Booking.class, "pkey.customerId"); |
acmeair/acmeair | acmeair-services-morphia/src/main/java/com/acmeair/morphia/DatastoreFactory.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Booking.java
// public interface Booking {
//
//
// public String getBookingId();
//
//
// public String getFlightId();
//
//
// public String getCustomerId();
//
//
// public Date getDateOfBooking();
//
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/FlightSegment.java
// public interface FlightSegment {
//
// public String getFlightName();
//
// public String getOriginPort();
//
// public String getDestPort();
//
// public int getMiles();
//
// }
| import java.util.Properties;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import com.acmeair.entities.Booking;
import com.acmeair.entities.Flight;
import com.acmeair.entities.FlightSegment;
import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.Morphia;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoClientURI;
import com.mongodb.WriteConcern; | Properties prop = new Properties();
prop.load(DatastoreFactory.class.getResource("/acmeair-mongo.properties").openStream());
boolean fsync = new Boolean(prop.getProperty("mongo.fsync"));
int w = new Integer(prop.getProperty("mongo.w"));
int connectionsPerHost = new Integer(prop.getProperty("mongo.connectionsPerHost"));
int threadsAllowedToBlockForConnectionMultiplier = new Integer(prop.getProperty("mongo.threadsAllowedToBlockForConnectionMultiplier"));
// To match the local options
MongoClientOptions.Builder builder = new MongoClientOptions.Builder()
.writeConcern(new WriteConcern(w, 0, fsync))
.connectionsPerHost(connectionsPerHost)
.threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier);
MongoClientURI mongoURI = new MongoClientURI(mongourl, builder);
MongoClient mongo = new MongoClient(mongoURI);
Morphia morphia = new Morphia();
result = morphia.createDatastore( mongo ,mongoURI.getDatabase());
System.out.println("create mongo datastore with options:"+result.getMongo().getMongoClientOptions());
}catch (Exception e)
{
e.printStackTrace();
}
}
// The converter is added for handing JDK 7 issue
// result.getMapper().getConverters().addConverter(new BigDecimalConverter());
// result.getMapper().getConverters().addConverter(new BigIntegerConverter());
// Enable index
result.ensureIndex(Booking.class, "pkey.customerId");
result.ensureIndex(Flight.class, "pkey.flightSegmentId,scheduledDepartureTime"); | // Path: acmeair-common/src/main/java/com/acmeair/entities/Booking.java
// public interface Booking {
//
//
// public String getBookingId();
//
//
// public String getFlightId();
//
//
// public String getCustomerId();
//
//
// public Date getDateOfBooking();
//
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/FlightSegment.java
// public interface FlightSegment {
//
// public String getFlightName();
//
// public String getOriginPort();
//
// public String getDestPort();
//
// public int getMiles();
//
// }
// Path: acmeair-services-morphia/src/main/java/com/acmeair/morphia/DatastoreFactory.java
import java.util.Properties;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import com.acmeair.entities.Booking;
import com.acmeair.entities.Flight;
import com.acmeair.entities.FlightSegment;
import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.Morphia;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoClientURI;
import com.mongodb.WriteConcern;
Properties prop = new Properties();
prop.load(DatastoreFactory.class.getResource("/acmeair-mongo.properties").openStream());
boolean fsync = new Boolean(prop.getProperty("mongo.fsync"));
int w = new Integer(prop.getProperty("mongo.w"));
int connectionsPerHost = new Integer(prop.getProperty("mongo.connectionsPerHost"));
int threadsAllowedToBlockForConnectionMultiplier = new Integer(prop.getProperty("mongo.threadsAllowedToBlockForConnectionMultiplier"));
// To match the local options
MongoClientOptions.Builder builder = new MongoClientOptions.Builder()
.writeConcern(new WriteConcern(w, 0, fsync))
.connectionsPerHost(connectionsPerHost)
.threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier);
MongoClientURI mongoURI = new MongoClientURI(mongourl, builder);
MongoClient mongo = new MongoClient(mongoURI);
Morphia morphia = new Morphia();
result = morphia.createDatastore( mongo ,mongoURI.getDatabase());
System.out.println("create mongo datastore with options:"+result.getMongo().getMongoClientOptions());
}catch (Exception e)
{
e.printStackTrace();
}
}
// The converter is added for handing JDK 7 issue
// result.getMapper().getConverters().addConverter(new BigDecimalConverter());
// result.getMapper().getConverters().addConverter(new BigIntegerConverter());
// Enable index
result.ensureIndex(Booking.class, "pkey.customerId");
result.ensureIndex(Flight.class, "pkey.flightSegmentId,scheduledDepartureTime"); | result.ensureIndex(FlightSegment.class, "originPort,destPort"); |
acmeair/acmeair | acmeair-webapp/src/main/java/com/acmeair/web/LoginREST.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
//
//
// public String getId();
//
//
// public String getCustomerid();
//
//
// public Date getLastAccessedTime();
//
//
// public Date getTimeoutTime();
//
//
// }
| import javax.ws.rs.*;
import javax.ws.rs.core.*;
import com.acmeair.entities.CustomerSession;
import com.acmeair.service.*; | /*******************************************************************************
* Copyright (c) 2013 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.web;
@Path("/login")
public class LoginREST {
public static String SESSIONID_COOKIE_NAME = "sessionid";
private CustomerService customerService = ServiceLocator.instance().getService(CustomerService.class);
@POST
@Consumes({"application/x-www-form-urlencoded"})
@Produces("text/plain")
public Response login(@FormParam("login") String login, @FormParam("password") String password) {
try {
boolean validCustomer = customerService.validateCustomer(login, password);
if (!validCustomer) {
return Response.status(Response.Status.FORBIDDEN).build();
}
| // Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
//
//
// public String getId();
//
//
// public String getCustomerid();
//
//
// public Date getLastAccessedTime();
//
//
// public Date getTimeoutTime();
//
//
// }
// Path: acmeair-webapp/src/main/java/com/acmeair/web/LoginREST.java
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import com.acmeair.entities.CustomerSession;
import com.acmeair.service.*;
/*******************************************************************************
* Copyright (c) 2013 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.web;
@Path("/login")
public class LoginREST {
public static String SESSIONID_COOKIE_NAME = "sessionid";
private CustomerService customerService = ServiceLocator.instance().getService(CustomerService.class);
@POST
@Consumes({"application/x-www-form-urlencoded"})
@Produces("text/plain")
public Response login(@FormParam("login") String login, @FormParam("password") String password) {
try {
boolean validCustomer = customerService.validateCustomer(login, password);
if (!validCustomer) {
return Response.status(Response.Status.FORBIDDEN).build();
}
| CustomerSession session = customerService.createSession(login); |
acmeair/acmeair | acmeair-services-wxs/src/main/java/com/acmeair/wxs/entities/CustomerImpl.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
| import java.io.Serializable;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress; | /*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.wxs.entities;
public class CustomerImpl implements Customer, Serializable{
private static final long serialVersionUID = 1L;
private String _id;
private String password;
private MemberShipStatus status;
private int total_miles;
private int miles_ytd;
| // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
// Path: acmeair-services-wxs/src/main/java/com/acmeair/wxs/entities/CustomerImpl.java
import java.io.Serializable;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
/*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.wxs.entities;
public class CustomerImpl implements Customer, Serializable{
private static final long serialVersionUID = 1L;
private String _id;
private String password;
private MemberShipStatus status;
private int total_miles;
private int miles_ytd;
| private CustomerAddress address; |
acmeair/acmeair | acmeair-services-wxs/src/main/java/com/acmeair/wxs/entities/CustomerAddressImpl.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
| import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import com.acmeair.entities.CustomerAddress; | /*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.wxs.entities;
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
@XmlRootElement | // Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
// Path: acmeair-services-wxs/src/main/java/com/acmeair/wxs/entities/CustomerAddressImpl.java
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import com.acmeair.entities.CustomerAddress;
/*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.wxs.entities;
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
@XmlRootElement | public class CustomerAddressImpl implements CustomerAddress, Serializable{ |
acmeair/acmeair | acmeair-services-morphia/src/main/java/com/acmeair/morphia/entities/FlightImpl.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/FlightSegment.java
// public interface FlightSegment {
//
// public String getFlightName();
//
// public String getOriginPort();
//
// public String getDestPort();
//
// public int getMiles();
//
// }
| import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import com.acmeair.entities.Flight;
import com.acmeair.entities.FlightSegment; | /*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.morphia.entities;
@Entity(value="flight")
public class FlightImpl implements Flight, Serializable{
private static final long serialVersionUID = 1L;
@Id
private String _id;
private String flightSegmentId;
private Date scheduledDepartureTime;
private Date scheduledArrivalTime;
private BigDecimal firstClassBaseCost;
private BigDecimal economyClassBaseCost;
private int numFirstClassSeats;
private int numEconomyClassSeats;
private String airplaneTypeId;
| // Path: acmeair-common/src/main/java/com/acmeair/entities/FlightSegment.java
// public interface FlightSegment {
//
// public String getFlightName();
//
// public String getOriginPort();
//
// public String getDestPort();
//
// public int getMiles();
//
// }
// Path: acmeair-services-morphia/src/main/java/com/acmeair/morphia/entities/FlightImpl.java
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import com.acmeair.entities.Flight;
import com.acmeair.entities.FlightSegment;
/*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.morphia.entities;
@Entity(value="flight")
public class FlightImpl implements Flight, Serializable{
private static final long serialVersionUID = 1L;
@Id
private String _id;
private String flightSegmentId;
private Date scheduledDepartureTime;
private Date scheduledArrivalTime;
private BigDecimal firstClassBaseCost;
private BigDecimal economyClassBaseCost;
private int numFirstClassSeats;
private int numEconomyClassSeats;
private String airplaneTypeId;
| private FlightSegment flightSegment; |
acmeair/acmeair | acmeair-services-morphia/src/main/java/com/acmeair/morphia/entities/CustomerAddressImpl.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
| import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import com.acmeair.entities.CustomerAddress; | /*******************************************************************************
* Copyright (c) 2013 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.morphia.entities;
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
@XmlRootElement | // Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
// Path: acmeair-services-morphia/src/main/java/com/acmeair/morphia/entities/CustomerAddressImpl.java
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import com.acmeair.entities.CustomerAddress;
/*******************************************************************************
* Copyright (c) 2013 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.morphia.entities;
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
@XmlRootElement | public class CustomerAddressImpl implements CustomerAddress, Serializable{ |
acmeair/acmeair | acmeair-services-morphia/src/main/java/com/acmeair/morphia/entities/BookingImpl.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Booking.java
// public interface Booking {
//
//
// public String getBookingId();
//
//
// public String getFlightId();
//
//
// public String getCustomerId();
//
//
// public Date getDateOfBooking();
//
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
| import java.io.Serializable;
import java.util.Date;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import com.acmeair.entities.Booking;
import com.acmeair.entities.Customer;
import com.acmeair.entities.Flight; | /*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.morphia.entities;
@Entity(value="booking")
public class BookingImpl implements Booking, Serializable{
private static final long serialVersionUID = 1L;
@Id
private String _id;
private String flightId;
private String customerId;
private Date dateOfBooking;
public BookingImpl() {
}
public BookingImpl(String bookingId, Date dateOfFlight, String customerId, String flightId) {
this._id = bookingId;
this.flightId = flightId;
this.customerId = customerId;
this.dateOfBooking = dateOfFlight;
}
| // Path: acmeair-common/src/main/java/com/acmeair/entities/Booking.java
// public interface Booking {
//
//
// public String getBookingId();
//
//
// public String getFlightId();
//
//
// public String getCustomerId();
//
//
// public Date getDateOfBooking();
//
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
// Path: acmeair-services-morphia/src/main/java/com/acmeair/morphia/entities/BookingImpl.java
import java.io.Serializable;
import java.util.Date;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import com.acmeair.entities.Booking;
import com.acmeair.entities.Customer;
import com.acmeair.entities.Flight;
/*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.morphia.entities;
@Entity(value="booking")
public class BookingImpl implements Booking, Serializable{
private static final long serialVersionUID = 1L;
@Id
private String _id;
private String flightId;
private String customerId;
private Date dateOfBooking;
public BookingImpl() {
}
public BookingImpl(String bookingId, Date dateOfFlight, String customerId, String flightId) {
this._id = bookingId;
this.flightId = flightId;
this.customerId = customerId;
this.dateOfBooking = dateOfFlight;
}
| public BookingImpl(String bookingId, Date dateOfFlight, Customer customer, Flight flight) { |
acmeair/acmeair | acmeair-webapp/src/main/java/com/acmeair/web/dto/FlightSegmentInfo.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/FlightSegment.java
// public interface FlightSegment {
//
// public String getFlightName();
//
// public String getOriginPort();
//
// public String getDestPort();
//
// public int getMiles();
//
// }
| import com.acmeair.entities.FlightSegment; | package com.acmeair.web.dto;
public class FlightSegmentInfo {
private String _id;
private String originPort;
private String destPort;
private int miles;
public FlightSegmentInfo() {
} | // Path: acmeair-common/src/main/java/com/acmeair/entities/FlightSegment.java
// public interface FlightSegment {
//
// public String getFlightName();
//
// public String getOriginPort();
//
// public String getDestPort();
//
// public int getMiles();
//
// }
// Path: acmeair-webapp/src/main/java/com/acmeair/web/dto/FlightSegmentInfo.java
import com.acmeair.entities.FlightSegment;
package com.acmeair.web.dto;
public class FlightSegmentInfo {
private String _id;
private String originPort;
private String destPort;
private int miles;
public FlightSegmentInfo() {
} | public FlightSegmentInfo(FlightSegment flightSegment) { |
acmeair/acmeair | acmeair-services-morphia/src/main/java/com/acmeair/morphia/services/util/MongoConnectionManager.java | // Path: acmeair-services-morphia/src/main/java/com/acmeair/morphia/BigDecimalConverter.java
// public class BigDecimalConverter extends TypeConverter implements SimpleValueConverter{
//
// public BigDecimalConverter() {
// super(BigDecimal.class);
// }
//
// @Override
// public Object encode(Object value, MappedField optionalExtraInfo) {
// return value.toString();
// }
//
// @Override
// public Object decode(Class targetClass, Object fromDBObject, MappedField optionalExtraInfo) throws MappingException {
// if (fromDBObject == null) return null;
// return new BigDecimal(fromDBObject.toString());
// }
// }
//
// Path: acmeair-services-morphia/src/main/java/com/acmeair/morphia/MorphiaConstants.java
// public interface MorphiaConstants extends AcmeAirConstants {
//
// public static final String JNDI_NAME = "mongo/acmeairMongodb";
// public static final String KEY = "morphia";
// public static final String KEY_DESCRIPTION = "mongoDB with morphia implementation";
//
// public static final String HOSTNAME = "mongohostname";
// public static final String PORT = "mongoport";
// public static final String DATABASE = "mongodatabase";
//
//
// }
| import java.io.IOException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.acmeair.morphia.BigDecimalConverter;
import com.acmeair.morphia.MorphiaConstants;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.Morphia;
import com.mongodb.DB;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoClientURI;
import com.mongodb.ServerAddress;
import com.mongodb.WriteConcern; | .socketKeepAlive(socketKeepAlive)
.maxWaitTime(maxWaitTime)
.threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier);
try {
//Check if VCAP_SERVICES exist, and if it does, look up the url from the credentials.
String vcapJSONString = System.getenv("VCAP_SERVICES");
if (vcapJSONString != null) {
logger.info("Reading VCAP_SERVICES");
Object jsonObject = JSONValue.parse(vcapJSONString);
JSONObject vcapServices = (JSONObject)jsonObject;
JSONArray mongoServiceArray =null;
for (Object key : vcapServices.keySet()){
if (key.toString().startsWith("mongo")){
mongoServiceArray = (JSONArray) vcapServices.get(key);
break;
}
}
if (mongoServiceArray == null) {
logger.severe("VCAP_SERVICES existed, but a mongo service was not definied.");
} else {
JSONObject mongoService = (JSONObject)mongoServiceArray.get(0);
JSONObject credentials = (JSONObject)mongoService.get("credentials");
String url = (String) credentials.get("url");
logger.fine("service url = " + url);
MongoClientURI mongoURI = new MongoClientURI(url, builder);
MongoClient mongo = new MongoClient(mongoURI);
| // Path: acmeair-services-morphia/src/main/java/com/acmeair/morphia/BigDecimalConverter.java
// public class BigDecimalConverter extends TypeConverter implements SimpleValueConverter{
//
// public BigDecimalConverter() {
// super(BigDecimal.class);
// }
//
// @Override
// public Object encode(Object value, MappedField optionalExtraInfo) {
// return value.toString();
// }
//
// @Override
// public Object decode(Class targetClass, Object fromDBObject, MappedField optionalExtraInfo) throws MappingException {
// if (fromDBObject == null) return null;
// return new BigDecimal(fromDBObject.toString());
// }
// }
//
// Path: acmeair-services-morphia/src/main/java/com/acmeair/morphia/MorphiaConstants.java
// public interface MorphiaConstants extends AcmeAirConstants {
//
// public static final String JNDI_NAME = "mongo/acmeairMongodb";
// public static final String KEY = "morphia";
// public static final String KEY_DESCRIPTION = "mongoDB with morphia implementation";
//
// public static final String HOSTNAME = "mongohostname";
// public static final String PORT = "mongoport";
// public static final String DATABASE = "mongodatabase";
//
//
// }
// Path: acmeair-services-morphia/src/main/java/com/acmeair/morphia/services/util/MongoConnectionManager.java
import java.io.IOException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.acmeair.morphia.BigDecimalConverter;
import com.acmeair.morphia.MorphiaConstants;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.Morphia;
import com.mongodb.DB;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoClientURI;
import com.mongodb.ServerAddress;
import com.mongodb.WriteConcern;
.socketKeepAlive(socketKeepAlive)
.maxWaitTime(maxWaitTime)
.threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier);
try {
//Check if VCAP_SERVICES exist, and if it does, look up the url from the credentials.
String vcapJSONString = System.getenv("VCAP_SERVICES");
if (vcapJSONString != null) {
logger.info("Reading VCAP_SERVICES");
Object jsonObject = JSONValue.parse(vcapJSONString);
JSONObject vcapServices = (JSONObject)jsonObject;
JSONArray mongoServiceArray =null;
for (Object key : vcapServices.keySet()){
if (key.toString().startsWith("mongo")){
mongoServiceArray = (JSONArray) vcapServices.get(key);
break;
}
}
if (mongoServiceArray == null) {
logger.severe("VCAP_SERVICES existed, but a mongo service was not definied.");
} else {
JSONObject mongoService = (JSONObject)mongoServiceArray.get(0);
JSONObject credentials = (JSONObject)mongoService.get("credentials");
String url = (String) credentials.get("url");
logger.fine("service url = " + url);
MongoClientURI mongoURI = new MongoClientURI(url, builder);
MongoClient mongo = new MongoClient(mongoURI);
| morphia.getMapper().getConverters().addConverter(new BigDecimalConverter()); |
acmeair/acmeair | acmeair-services-morphia/src/main/java/com/acmeair/morphia/entities/CustomerImpl.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
| import java.io.Serializable;
import org.mongodb.morphia.annotations.Entity;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress; | /*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.morphia.entities;
@Entity(value="customer")
public class CustomerImpl implements Customer, Serializable{
private static final long serialVersionUID = 1L;
private String _id;
private String password;
private MemberShipStatus status;
private int total_miles;
private int miles_ytd;
| // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
// Path: acmeair-services-morphia/src/main/java/com/acmeair/morphia/entities/CustomerImpl.java
import java.io.Serializable;
import org.mongodb.morphia.annotations.Entity;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
/*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.morphia.entities;
@Entity(value="customer")
public class CustomerImpl implements Customer, Serializable{
private static final long serialVersionUID = 1L;
private String _id;
private String password;
private MemberShipStatus status;
private int total_miles;
private int miles_ytd;
| private CustomerAddress address; |
acmeair/acmeair | acmeair-services-wxs/src/main/java/com/acmeair/wxs/entities/FlightImpl.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/FlightSegment.java
// public interface FlightSegment {
//
// public String getFlightName();
//
// public String getOriginPort();
//
// public String getDestPort();
//
// public int getMiles();
//
// }
| import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.acmeair.entities.Flight;
import com.acmeair.entities.FlightSegment; | /*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.wxs.entities;
public class FlightImpl implements Flight, Serializable{
private static final long serialVersionUID = 1L;
private FlightPKImpl pkey;
private Date scheduledDepartureTime;
private Date scheduledArrivalTime;
private BigDecimal firstClassBaseCost;
private BigDecimal economyClassBaseCost;
private int numFirstClassSeats;
private int numEconomyClassSeats;
private String airplaneTypeId;
| // Path: acmeair-common/src/main/java/com/acmeair/entities/FlightSegment.java
// public interface FlightSegment {
//
// public String getFlightName();
//
// public String getOriginPort();
//
// public String getDestPort();
//
// public int getMiles();
//
// }
// Path: acmeair-services-wxs/src/main/java/com/acmeair/wxs/entities/FlightImpl.java
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.acmeair.entities.Flight;
import com.acmeair.entities.FlightSegment;
/*******************************************************************************
* Copyright (c) 2013-2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.wxs.entities;
public class FlightImpl implements Flight, Serializable{
private static final long serialVersionUID = 1L;
private FlightPKImpl pkey;
private Date scheduledDepartureTime;
private Date scheduledArrivalTime;
private BigDecimal firstClassBaseCost;
private BigDecimal economyClassBaseCost;
private int numFirstClassSeats;
private int numEconomyClassSeats;
private String airplaneTypeId;
| private FlightSegment flightSegment; |
acmeair/acmeair | acmeair-webapp/src/main/java/com/acmeair/web/CustomerREST.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
| import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.service.*;
import com.acmeair.web.dto.*;
import javax.ws.rs.core.Context; | /*******************************************************************************
* Copyright (c) 2013 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.web;
@Path("/customer")
public class CustomerREST {
private CustomerService customerService = ServiceLocator.instance().getService(CustomerService.class);
@Context
private HttpServletRequest request;
private boolean validate(String customerid) {
String loginUser = (String) request.getAttribute(RESTCookieSessionFilter.LOGIN_USER);
return customerid.equals(loginUser);
}
@GET
@Path("/byid/{custid}")
@Produces("application/json")
public Response getCustomer(@CookieParam("sessionid") String sessionid, @PathParam("custid") String customerid) {
try {
// make sure the user isn't trying to update a customer other than the one currently logged in
if (!validate(customerid)) {
return Response.status(Response.Status.FORBIDDEN).build();
} | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
// Path: acmeair-webapp/src/main/java/com/acmeair/web/CustomerREST.java
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.service.*;
import com.acmeair.web.dto.*;
import javax.ws.rs.core.Context;
/*******************************************************************************
* Copyright (c) 2013 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.acmeair.web;
@Path("/customer")
public class CustomerREST {
private CustomerService customerService = ServiceLocator.instance().getService(CustomerService.class);
@Context
private HttpServletRequest request;
private boolean validate(String customerid) {
String loginUser = (String) request.getAttribute(RESTCookieSessionFilter.LOGIN_USER);
return customerid.equals(loginUser);
}
@GET
@Path("/byid/{custid}")
@Produces("application/json")
public Response getCustomer(@CookieParam("sessionid") String sessionid, @PathParam("custid") String customerid) {
try {
// make sure the user isn't trying to update a customer other than the one currently logged in
if (!validate(customerid)) {
return Response.status(Response.Status.FORBIDDEN).build();
} | Customer customer = customerService.getCustomerByUsername(customerid); |
acmeair/acmeair | acmeair-webapp/src/main/java/com/acmeair/web/CustomerREST.java | // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
| import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.service.*;
import com.acmeair.web.dto.*;
import javax.ws.rs.core.Context; | try {
// make sure the user isn't trying to update a customer other than the one currently logged in
if (!validate(customerid)) {
return Response.status(Response.Status.FORBIDDEN).build();
}
Customer customer = customerService.getCustomerByUsername(customerid);
CustomerInfo customerDTO = new CustomerInfo(customer);
return Response.ok(customerDTO).build();
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
@POST
@Path("/byid/{custid}")
@Produces("application/json")
public /* Customer */ Response putCustomer(@CookieParam("sessionid") String sessionid, CustomerInfo customer) {
if (!validate(customer.getUsername())) {
return Response.status(Response.Status.FORBIDDEN).build();
}
Customer customerFromDB = customerService.getCustomerByUsernameAndPassword(customer.getUsername(), customer.getPassword());
if (customerFromDB == null) {
// either the customer doesn't exist or the password is wrong
return Response.status(Response.Status.FORBIDDEN).build();
}
| // Path: acmeair-common/src/main/java/com/acmeair/entities/Customer.java
// public interface Customer {
//
// public enum MemberShipStatus { NONE, SILVER, GOLD, PLATINUM, EXEC_PLATINUM, GRAPHITE };
// public enum PhoneType { UNKNOWN, HOME, BUSINESS, MOBILE };
//
//
// public String getCustomerId();
//
// public String getUsername();
//
// public void setUsername(String username);
//
// public String getPassword();
//
// public void setPassword(String password);
//
// public MemberShipStatus getStatus();
//
// public void setStatus(MemberShipStatus status);
//
// public int getTotal_miles();
//
// public int getMiles_ytd();
//
// public String getPhoneNumber();
//
// public void setPhoneNumber(String phoneNumber);
//
// public PhoneType getPhoneNumberType();
//
// public void setPhoneNumberType(PhoneType phoneNumberType);
//
// public CustomerAddress getAddress();
//
// public void setAddress(CustomerAddress address);
//
// }
//
// Path: acmeair-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
//
//
// public String getStreetAddress1();
// public void setStreetAddress1(String streetAddress1);
// public String getStreetAddress2();
// public void setStreetAddress2(String streetAddress2);
// public String getCity();
// public void setCity(String city);
// public String getStateProvince();
// public void setStateProvince(String stateProvince);
// public String getCountry();
// public void setCountry(String country);
// public String getPostalCode();
// public void setPostalCode(String postalCode);
//
// }
// Path: acmeair-webapp/src/main/java/com/acmeair/web/CustomerREST.java
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.service.*;
import com.acmeair.web.dto.*;
import javax.ws.rs.core.Context;
try {
// make sure the user isn't trying to update a customer other than the one currently logged in
if (!validate(customerid)) {
return Response.status(Response.Status.FORBIDDEN).build();
}
Customer customer = customerService.getCustomerByUsername(customerid);
CustomerInfo customerDTO = new CustomerInfo(customer);
return Response.ok(customerDTO).build();
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
@POST
@Path("/byid/{custid}")
@Produces("application/json")
public /* Customer */ Response putCustomer(@CookieParam("sessionid") String sessionid, CustomerInfo customer) {
if (!validate(customer.getUsername())) {
return Response.status(Response.Status.FORBIDDEN).build();
}
Customer customerFromDB = customerService.getCustomerByUsernameAndPassword(customer.getUsername(), customer.getPassword());
if (customerFromDB == null) {
// either the customer doesn't exist or the password is wrong
return Response.status(Response.Status.FORBIDDEN).build();
}
| CustomerAddress addressFromDB = customerFromDB.getAddress(); |
ernieyu/pfcviewer | src/pfc/view/AboutDialog.java | // Path: src/pfc/images/ImageConstants.java
// public abstract class ImageConstants {
//
// /** Protected constructor prevents unintended instantiation. */
// protected ImageConstants() {
// }
//
// /** Blank icon. */
// public static final String ICON_BLANK = "Blank16.gif";
// /** Copy icon. */
// public static final String ICON_COPY = "Copy16.gif";
// /** Open icon. */
// public static final String ICON_OPEN = "Open16.gif";
// /** Preferences icon. */
// public static final String ICON_PREFERENCES = "Preferences16.gif";
// /** Program logo. */
// public static final String PROGRAM_LOGO = "Logo48.png";
//
// /** Returns the image object for the specified image path relative to the
// * package containing this class. If the image cannot be found, then a
// * null value is returned.
// * @param imagePath String
// * @return Image
// */
// public static Image createImage(String imagePath) {
// URL imageUrl = ImageConstants.class.getResource(imagePath);
// if (imageUrl != null) {
// return Toolkit.getDefaultToolkit().createImage(imageUrl);
// } else {
// return null;
// }
// }
//
// /** Returns the icon object for the specified icon path relative to the
// * package containing this class. If the icon cannot be found, then a
// * blank icon is returned.
// * @param iconPath String
// * @return Icon
// */
// public static Icon createImageIcon(String iconPath) {
// URL iconUrl = ImageConstants.class.getResource(iconPath);
// if (iconUrl != null) {
// return new ImageIcon(iconUrl);
// } else {
// return new ImageIcon(ImageConstants.class.getResource(ICON_BLANK));
// }
// }
// }
| import pfc.images.ImageConstants; | /*
* Copyright (c) 2002 Ernest Yu. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
package pfc.view;
/**
* About dialog box to display version number and data.
* @author Ernie Yu
*/
public class AboutDialog extends javax.swing.JDialog {
private static final String PEOPLE = "Contributors:\n"
+ "\tErnie Yu\n"
+ "\tZhan Shi\n";
/** Creates new form AboutDialog */
public AboutDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jPanelInfo = new javax.swing.JPanel();
jLabelLogo = new javax.swing.JLabel();
jLabelName = new javax.swing.JLabel();
jLabelVersion = new javax.swing.JLabel();
jLabelDate = new javax.swing.JLabel();
jLabelCopyright = new javax.swing.JLabel();
jScrollPanePeople = new javax.swing.JScrollPane();
jTextPanePeople = new javax.swing.JTextPane();
jPanelButton = new javax.swing.JPanel();
jButtonOk = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("About PFC Viewer");
setModal(true);
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
jPanelInfo.setBorder(javax.swing.BorderFactory.createEmptyBorder(6, 6, 6, 6));
jPanelInfo.setLayout(new java.awt.GridBagLayout());
| // Path: src/pfc/images/ImageConstants.java
// public abstract class ImageConstants {
//
// /** Protected constructor prevents unintended instantiation. */
// protected ImageConstants() {
// }
//
// /** Blank icon. */
// public static final String ICON_BLANK = "Blank16.gif";
// /** Copy icon. */
// public static final String ICON_COPY = "Copy16.gif";
// /** Open icon. */
// public static final String ICON_OPEN = "Open16.gif";
// /** Preferences icon. */
// public static final String ICON_PREFERENCES = "Preferences16.gif";
// /** Program logo. */
// public static final String PROGRAM_LOGO = "Logo48.png";
//
// /** Returns the image object for the specified image path relative to the
// * package containing this class. If the image cannot be found, then a
// * null value is returned.
// * @param imagePath String
// * @return Image
// */
// public static Image createImage(String imagePath) {
// URL imageUrl = ImageConstants.class.getResource(imagePath);
// if (imageUrl != null) {
// return Toolkit.getDefaultToolkit().createImage(imageUrl);
// } else {
// return null;
// }
// }
//
// /** Returns the icon object for the specified icon path relative to the
// * package containing this class. If the icon cannot be found, then a
// * blank icon is returned.
// * @param iconPath String
// * @return Icon
// */
// public static Icon createImageIcon(String iconPath) {
// URL iconUrl = ImageConstants.class.getResource(iconPath);
// if (iconUrl != null) {
// return new ImageIcon(iconUrl);
// } else {
// return new ImageIcon(ImageConstants.class.getResource(ICON_BLANK));
// }
// }
// }
// Path: src/pfc/view/AboutDialog.java
import pfc.images.ImageConstants;
/*
* Copyright (c) 2002 Ernest Yu. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
package pfc.view;
/**
* About dialog box to display version number and data.
* @author Ernie Yu
*/
public class AboutDialog extends javax.swing.JDialog {
private static final String PEOPLE = "Contributors:\n"
+ "\tErnie Yu\n"
+ "\tZhan Shi\n";
/** Creates new form AboutDialog */
public AboutDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jPanelInfo = new javax.swing.JPanel();
jLabelLogo = new javax.swing.JLabel();
jLabelName = new javax.swing.JLabel();
jLabelVersion = new javax.swing.JLabel();
jLabelDate = new javax.swing.JLabel();
jLabelCopyright = new javax.swing.JLabel();
jScrollPanePeople = new javax.swing.JScrollPane();
jTextPanePeople = new javax.swing.JTextPane();
jPanelButton = new javax.swing.JPanel();
jButtonOk = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("About PFC Viewer");
setModal(true);
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
jPanelInfo.setBorder(javax.swing.BorderFactory.createEmptyBorder(6, 6, 6, 6));
jPanelInfo.setLayout(new java.awt.GridBagLayout());
| jLabelLogo.setIcon(ImageConstants.createImageIcon(ImageConstants.PROGRAM_LOGO)); |
hanuor/pearl | pearl/src/main/java/com/hanuor/pearl/toolbox/AndroidAuthenticator.java | // Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/AuthFailureError.java
// @SuppressWarnings("serial")
// public class AuthFailureError extends VolleyError {
// /** An intent that can be used to resolve this exception. (Brings up the password dialog.) */
// private Intent mResolutionIntent;
//
// public AuthFailureError() { }
//
// public AuthFailureError(Intent intent) {
// mResolutionIntent = intent;
// }
//
// public AuthFailureError(NetworkResponse response) {
// super(response);
// }
//
// public AuthFailureError(String message) {
// super(message);
// }
//
// public AuthFailureError(String message, Exception reason) {
// super(message, reason);
// }
//
// public Intent getResolutionIntent() {
// return mResolutionIntent;
// }
//
// @Override
// public String getMessage() {
// if (mResolutionIntent != null) {
// return "User needs to (re)enter credentials.";
// }
// return super.getMessage();
// }
// }
| import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AccountManagerFuture;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.hanuor.pearl.volleysingleton.AuthFailureError; | /*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hanuor.pearl.toolbox;
/**
* An Authenticator that uses {@link AccountManager} to get auth
* tokens of a specified type for a specified account.
*/
public class AndroidAuthenticator implements Authenticator {
private final AccountManager mAccountManager;
private final Account mAccount;
private final String mAuthTokenType;
private final boolean mNotifyAuthFailure;
/**
* Creates a new authenticator.
* @param context Context for accessing AccountManager
* @param account Account to authenticate as
* @param authTokenType Auth token type passed to AccountManager
*/
public AndroidAuthenticator(Context context, Account account, String authTokenType) {
this(context, account, authTokenType, false);
}
/**
* Creates a new authenticator.
* @param context Context for accessing AccountManager
* @param account Account to authenticate as
* @param authTokenType Auth token type passed to AccountManager
* @param notifyAuthFailure Whether to raise a notification upon auth failure
*/
public AndroidAuthenticator(Context context, Account account, String authTokenType,
boolean notifyAuthFailure) {
this(AccountManager.get(context), account, authTokenType, notifyAuthFailure);
}
// Visible for testing. Allows injection of a mock AccountManager.
AndroidAuthenticator(AccountManager accountManager, Account account,
String authTokenType, boolean notifyAuthFailure) {
mAccountManager = accountManager;
mAccount = account;
mAuthTokenType = authTokenType;
mNotifyAuthFailure = notifyAuthFailure;
}
/**
* Returns the Account being used by this authenticator.
*/
public Account getAccount() {
return mAccount;
}
/**
* Returns the Auth Token Type used by this authenticator.
*/
public String getAuthTokenType() {
return mAuthTokenType;
}
// TODO: Figure out what to do about notifyAuthFailure
@SuppressWarnings("deprecation")
@Override | // Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/AuthFailureError.java
// @SuppressWarnings("serial")
// public class AuthFailureError extends VolleyError {
// /** An intent that can be used to resolve this exception. (Brings up the password dialog.) */
// private Intent mResolutionIntent;
//
// public AuthFailureError() { }
//
// public AuthFailureError(Intent intent) {
// mResolutionIntent = intent;
// }
//
// public AuthFailureError(NetworkResponse response) {
// super(response);
// }
//
// public AuthFailureError(String message) {
// super(message);
// }
//
// public AuthFailureError(String message, Exception reason) {
// super(message, reason);
// }
//
// public Intent getResolutionIntent() {
// return mResolutionIntent;
// }
//
// @Override
// public String getMessage() {
// if (mResolutionIntent != null) {
// return "User needs to (re)enter credentials.";
// }
// return super.getMessage();
// }
// }
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/AndroidAuthenticator.java
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AccountManagerFuture;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.hanuor.pearl.volleysingleton.AuthFailureError;
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hanuor.pearl.toolbox;
/**
* An Authenticator that uses {@link AccountManager} to get auth
* tokens of a specified type for a specified account.
*/
public class AndroidAuthenticator implements Authenticator {
private final AccountManager mAccountManager;
private final Account mAccount;
private final String mAuthTokenType;
private final boolean mNotifyAuthFailure;
/**
* Creates a new authenticator.
* @param context Context for accessing AccountManager
* @param account Account to authenticate as
* @param authTokenType Auth token type passed to AccountManager
*/
public AndroidAuthenticator(Context context, Account account, String authTokenType) {
this(context, account, authTokenType, false);
}
/**
* Creates a new authenticator.
* @param context Context for accessing AccountManager
* @param account Account to authenticate as
* @param authTokenType Auth token type passed to AccountManager
* @param notifyAuthFailure Whether to raise a notification upon auth failure
*/
public AndroidAuthenticator(Context context, Account account, String authTokenType,
boolean notifyAuthFailure) {
this(AccountManager.get(context), account, authTokenType, notifyAuthFailure);
}
// Visible for testing. Allows injection of a mock AccountManager.
AndroidAuthenticator(AccountManager accountManager, Account account,
String authTokenType, boolean notifyAuthFailure) {
mAccountManager = accountManager;
mAccount = account;
mAuthTokenType = authTokenType;
mNotifyAuthFailure = notifyAuthFailure;
}
/**
* Returns the Account being used by this authenticator.
*/
public Account getAccount() {
return mAccount;
}
/**
* Returns the Auth Token Type used by this authenticator.
*/
public String getAuthTokenType() {
return mAuthTokenType;
}
// TODO: Figure out what to do about notifyAuthFailure
@SuppressWarnings("deprecation")
@Override | public String getAuthToken() throws AuthFailureError { |
hanuor/pearl | sapphire/src/main/java/com/hanuor/sapphire/temporarydb/HintsStoreDB.java | // Path: sapphire/src/main/java/com/hanuor/sapphire/utils/Utility.java
// public class Utility {
// public static void throwExceptionIfNullOrBlank(Object obj, String name) {
// if(obj == null) {
// throw new SapphireException(name + " parameter can not be null ");
// } else if(obj instanceof String && ((String)obj).trim().equals("")) {
// throw new SapphireException(name + " parameter can not be blank ");
// } else if(obj instanceof ArrayList && ((ArrayList)obj).size() == 0) {
// throw new SapphireException(name + " cannot be empty");
// }
// }
// public static void throwExceptionIfNull(Object obj, String name) {
// if(obj == null) {
// throw new SapphireException(name + " parameter can not be null ");
// } else if(obj instanceof ArrayList && ((ArrayList)obj).size() == 0) {
// throw new SapphireException(name + " cannot be empty");
// }
// }
// public static void throwRuntimeException(){
// throw new SapphireException("Have you initialized Sapphire SDK with the keys properly?");
// }
// public static void throwRuntimeException(String message){
// if(message!=null){
// throw new SapphireException(message);
// }
// }
// public static void throwException(Object obj, String message){
// throw new SapphireException(obj + "" + message);
// }
// }
| import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import com.hanuor.sapphire.utils.Utility;
import java.util.ArrayList; | super(context, name, factory, version);
}
public HintsStoreDB(Context context) {
super(context, DB_NAME, null, DBVERSION);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
String Table_create = "CREATE TABLE " + TABLE_NAME + "(" +
COLUMN_NAME + " STRING" + ");";
sqLiteDatabase.execSQL(Table_create);
}
public void storeDetails(ArrayList<String> details){
clearDatabase();
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
for(String element: details){
contentValues.put(COLUMN_NAME, element);
long val = db.insert(TABLE_NAME, null, contentValues);
}
db.close();
}
public void storeDetails(ArrayList<String> details, String delimiter){
clearDatabase();
StringBuffer stringBuffer = new StringBuffer();
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
if(delimiter.equals("")){ | // Path: sapphire/src/main/java/com/hanuor/sapphire/utils/Utility.java
// public class Utility {
// public static void throwExceptionIfNullOrBlank(Object obj, String name) {
// if(obj == null) {
// throw new SapphireException(name + " parameter can not be null ");
// } else if(obj instanceof String && ((String)obj).trim().equals("")) {
// throw new SapphireException(name + " parameter can not be blank ");
// } else if(obj instanceof ArrayList && ((ArrayList)obj).size() == 0) {
// throw new SapphireException(name + " cannot be empty");
// }
// }
// public static void throwExceptionIfNull(Object obj, String name) {
// if(obj == null) {
// throw new SapphireException(name + " parameter can not be null ");
// } else if(obj instanceof ArrayList && ((ArrayList)obj).size() == 0) {
// throw new SapphireException(name + " cannot be empty");
// }
// }
// public static void throwRuntimeException(){
// throw new SapphireException("Have you initialized Sapphire SDK with the keys properly?");
// }
// public static void throwRuntimeException(String message){
// if(message!=null){
// throw new SapphireException(message);
// }
// }
// public static void throwException(Object obj, String message){
// throw new SapphireException(obj + "" + message);
// }
// }
// Path: sapphire/src/main/java/com/hanuor/sapphire/temporarydb/HintsStoreDB.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import com.hanuor.sapphire.utils.Utility;
import java.util.ArrayList;
super(context, name, factory, version);
}
public HintsStoreDB(Context context) {
super(context, DB_NAME, null, DBVERSION);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
String Table_create = "CREATE TABLE " + TABLE_NAME + "(" +
COLUMN_NAME + " STRING" + ");";
sqLiteDatabase.execSQL(Table_create);
}
public void storeDetails(ArrayList<String> details){
clearDatabase();
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
for(String element: details){
contentValues.put(COLUMN_NAME, element);
long val = db.insert(TABLE_NAME, null, contentValues);
}
db.close();
}
public void storeDetails(ArrayList<String> details, String delimiter){
clearDatabase();
StringBuffer stringBuffer = new StringBuffer();
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
if(delimiter.equals("")){ | Utility.throwException(delimiter,"Cannot be null"); |
hanuor/pearl | pearl/src/main/java/com/hanuor/pearl/toolbox/JsonObjectRequest.java | // Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/NetworkResponse.java
// public class NetworkResponse {
// /**
// * Creates a new network response.
// * @param statusCode the HTTP status code
// * @param data Response body
// * @param headers Headers returned with this response, or null for none
// * @param notModified True if the server returned a 304 and the data was already in cache
// * @param networkTimeMs Round-trip network time to receive network response
// */
// public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers,
// boolean notModified, long networkTimeMs) {
// this.statusCode = statusCode;
// this.data = data;
// this.headers = headers;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers,
// boolean notModified) {
// this(statusCode, data, headers, notModified, 0);
// }
//
// public NetworkResponse(byte[] data) {
// this(HttpStatus.SC_OK, data, Collections.<String, String>emptyMap(), false, 0);
// }
//
// public NetworkResponse(byte[] data, Map<String, String> headers) {
// this(HttpStatus.SC_OK, data, headers, false, 0);
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Raw data from this response. */
// public final byte[] data;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/ParseError.java
// @SuppressWarnings("serial")
// public class ParseError extends VolleyError {
// public ParseError() { }
//
// public ParseError(NetworkResponse networkResponse) {
// super(networkResponse);
// }
//
// public ParseError(Throwable cause) {
// super(cause);
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public class Response<T> {
//
// /** Callback interface for delivering parsed responses. */
// public interface Listener<T> {
// /** Called when a response is received. */
// public void onResponse(Object tag, T response);
// }
//
// /** Callback interface for delivering error responses. */
// public interface ErrorListener {
// /**
// * Callback method that an error has been occurred with the
// * provided error code and optional user-readable message.
// */
// public void onErrorResponse(VolleyError error);
// }
//
// /** Returns a successful response containing the parsed result. */
// public static <T> Response<T> success(T result, Cache.Entry cacheEntry) {
// return new Response<T>(result, cacheEntry);
// }
//
// /**
// * Returns a failed response containing the given error code and an optional
// * localized message displayed to the user.
// */
// public static <T> Response<T> error(VolleyError error) {
// return new Response<T>(error);
// }
//
// /** Parsed response, or null in the case of error. */
// public final T result;
//
// /** Cache metadata for this response, or null in the case of error. */
// public final Cache.Entry cacheEntry;
//
// /** Detailed error information if <code>errorCode != OK</code>. */
// public final VolleyError error;
//
// /** True if this response was a soft-expired one and a second one MAY be coming. */
// public boolean intermediate = false;
//
// /**
// * Returns whether this response is considered successful.
// */
// public boolean isSuccess() {
// return error == null;
// }
//
//
// private Response(T result, Cache.Entry cacheEntry) {
// this.result = result;
// this.cacheEntry = cacheEntry;
// this.error = null;
// }
//
// private Response(VolleyError error) {
// this.result = null;
// this.cacheEntry = null;
// this.error = error;
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public interface ErrorListener {
// /**
// * Callback method that an error has been occurred with the
// * provided error code and optional user-readable message.
// */
// public void onErrorResponse(VolleyError error);
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public interface Listener<T> {
// /** Called when a response is received. */
// public void onResponse(Object tag, T response);
// }
| import com.hanuor.pearl.volleysingleton.NetworkResponse;
import com.hanuor.pearl.volleysingleton.ParseError;
import com.hanuor.pearl.volleysingleton.Response;
import org.json.JSONException;
import org.json.JSONObject;
import com.hanuor.pearl.volleysingleton.Response.ErrorListener;
import com.hanuor.pearl.volleysingleton.Response.Listener;
import java.io.UnsupportedEncodingException; | /*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hanuor.pearl.toolbox;
/**
* A request for retrieving a {@link JSONObject} response body at a given URL, allowing for an
* optional {@link JSONObject} to be passed in as part of the request body.
*/
public class JsonObjectRequest extends JsonRequest<JSONObject> {
/**
* Creates a new request.
* @param method the HTTP method to use
* @param url URL to fetch the JSON from
* @param jsonRequest A {@link JSONObject} to post with the request. Null is allowed and
* indicates no parameters will be posted along with request.
* @param listener Listener to receive the JSON response
* @param errorListener Error listener, or null to ignore errors.
*/
public JsonObjectRequest(int method, String url, JSONObject jsonRequest, | // Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/NetworkResponse.java
// public class NetworkResponse {
// /**
// * Creates a new network response.
// * @param statusCode the HTTP status code
// * @param data Response body
// * @param headers Headers returned with this response, or null for none
// * @param notModified True if the server returned a 304 and the data was already in cache
// * @param networkTimeMs Round-trip network time to receive network response
// */
// public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers,
// boolean notModified, long networkTimeMs) {
// this.statusCode = statusCode;
// this.data = data;
// this.headers = headers;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers,
// boolean notModified) {
// this(statusCode, data, headers, notModified, 0);
// }
//
// public NetworkResponse(byte[] data) {
// this(HttpStatus.SC_OK, data, Collections.<String, String>emptyMap(), false, 0);
// }
//
// public NetworkResponse(byte[] data, Map<String, String> headers) {
// this(HttpStatus.SC_OK, data, headers, false, 0);
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Raw data from this response. */
// public final byte[] data;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/ParseError.java
// @SuppressWarnings("serial")
// public class ParseError extends VolleyError {
// public ParseError() { }
//
// public ParseError(NetworkResponse networkResponse) {
// super(networkResponse);
// }
//
// public ParseError(Throwable cause) {
// super(cause);
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public class Response<T> {
//
// /** Callback interface for delivering parsed responses. */
// public interface Listener<T> {
// /** Called when a response is received. */
// public void onResponse(Object tag, T response);
// }
//
// /** Callback interface for delivering error responses. */
// public interface ErrorListener {
// /**
// * Callback method that an error has been occurred with the
// * provided error code and optional user-readable message.
// */
// public void onErrorResponse(VolleyError error);
// }
//
// /** Returns a successful response containing the parsed result. */
// public static <T> Response<T> success(T result, Cache.Entry cacheEntry) {
// return new Response<T>(result, cacheEntry);
// }
//
// /**
// * Returns a failed response containing the given error code and an optional
// * localized message displayed to the user.
// */
// public static <T> Response<T> error(VolleyError error) {
// return new Response<T>(error);
// }
//
// /** Parsed response, or null in the case of error. */
// public final T result;
//
// /** Cache metadata for this response, or null in the case of error. */
// public final Cache.Entry cacheEntry;
//
// /** Detailed error information if <code>errorCode != OK</code>. */
// public final VolleyError error;
//
// /** True if this response was a soft-expired one and a second one MAY be coming. */
// public boolean intermediate = false;
//
// /**
// * Returns whether this response is considered successful.
// */
// public boolean isSuccess() {
// return error == null;
// }
//
//
// private Response(T result, Cache.Entry cacheEntry) {
// this.result = result;
// this.cacheEntry = cacheEntry;
// this.error = null;
// }
//
// private Response(VolleyError error) {
// this.result = null;
// this.cacheEntry = null;
// this.error = error;
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public interface ErrorListener {
// /**
// * Callback method that an error has been occurred with the
// * provided error code and optional user-readable message.
// */
// public void onErrorResponse(VolleyError error);
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public interface Listener<T> {
// /** Called when a response is received. */
// public void onResponse(Object tag, T response);
// }
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/JsonObjectRequest.java
import com.hanuor.pearl.volleysingleton.NetworkResponse;
import com.hanuor.pearl.volleysingleton.ParseError;
import com.hanuor.pearl.volleysingleton.Response;
import org.json.JSONException;
import org.json.JSONObject;
import com.hanuor.pearl.volleysingleton.Response.ErrorListener;
import com.hanuor.pearl.volleysingleton.Response.Listener;
import java.io.UnsupportedEncodingException;
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hanuor.pearl.toolbox;
/**
* A request for retrieving a {@link JSONObject} response body at a given URL, allowing for an
* optional {@link JSONObject} to be passed in as part of the request body.
*/
public class JsonObjectRequest extends JsonRequest<JSONObject> {
/**
* Creates a new request.
* @param method the HTTP method to use
* @param url URL to fetch the JSON from
* @param jsonRequest A {@link JSONObject} to post with the request. Null is allowed and
* indicates no parameters will be posted along with request.
* @param listener Listener to receive the JSON response
* @param errorListener Error listener, or null to ignore errors.
*/
public JsonObjectRequest(int method, String url, JSONObject jsonRequest, | Listener<JSONObject> listener, ErrorListener errorListener) { |
hanuor/pearl | pearl/src/main/java/com/hanuor/pearl/toolbox/JsonObjectRequest.java | // Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/NetworkResponse.java
// public class NetworkResponse {
// /**
// * Creates a new network response.
// * @param statusCode the HTTP status code
// * @param data Response body
// * @param headers Headers returned with this response, or null for none
// * @param notModified True if the server returned a 304 and the data was already in cache
// * @param networkTimeMs Round-trip network time to receive network response
// */
// public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers,
// boolean notModified, long networkTimeMs) {
// this.statusCode = statusCode;
// this.data = data;
// this.headers = headers;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers,
// boolean notModified) {
// this(statusCode, data, headers, notModified, 0);
// }
//
// public NetworkResponse(byte[] data) {
// this(HttpStatus.SC_OK, data, Collections.<String, String>emptyMap(), false, 0);
// }
//
// public NetworkResponse(byte[] data, Map<String, String> headers) {
// this(HttpStatus.SC_OK, data, headers, false, 0);
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Raw data from this response. */
// public final byte[] data;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/ParseError.java
// @SuppressWarnings("serial")
// public class ParseError extends VolleyError {
// public ParseError() { }
//
// public ParseError(NetworkResponse networkResponse) {
// super(networkResponse);
// }
//
// public ParseError(Throwable cause) {
// super(cause);
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public class Response<T> {
//
// /** Callback interface for delivering parsed responses. */
// public interface Listener<T> {
// /** Called when a response is received. */
// public void onResponse(Object tag, T response);
// }
//
// /** Callback interface for delivering error responses. */
// public interface ErrorListener {
// /**
// * Callback method that an error has been occurred with the
// * provided error code and optional user-readable message.
// */
// public void onErrorResponse(VolleyError error);
// }
//
// /** Returns a successful response containing the parsed result. */
// public static <T> Response<T> success(T result, Cache.Entry cacheEntry) {
// return new Response<T>(result, cacheEntry);
// }
//
// /**
// * Returns a failed response containing the given error code and an optional
// * localized message displayed to the user.
// */
// public static <T> Response<T> error(VolleyError error) {
// return new Response<T>(error);
// }
//
// /** Parsed response, or null in the case of error. */
// public final T result;
//
// /** Cache metadata for this response, or null in the case of error. */
// public final Cache.Entry cacheEntry;
//
// /** Detailed error information if <code>errorCode != OK</code>. */
// public final VolleyError error;
//
// /** True if this response was a soft-expired one and a second one MAY be coming. */
// public boolean intermediate = false;
//
// /**
// * Returns whether this response is considered successful.
// */
// public boolean isSuccess() {
// return error == null;
// }
//
//
// private Response(T result, Cache.Entry cacheEntry) {
// this.result = result;
// this.cacheEntry = cacheEntry;
// this.error = null;
// }
//
// private Response(VolleyError error) {
// this.result = null;
// this.cacheEntry = null;
// this.error = error;
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public interface ErrorListener {
// /**
// * Callback method that an error has been occurred with the
// * provided error code and optional user-readable message.
// */
// public void onErrorResponse(VolleyError error);
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public interface Listener<T> {
// /** Called when a response is received. */
// public void onResponse(Object tag, T response);
// }
| import com.hanuor.pearl.volleysingleton.NetworkResponse;
import com.hanuor.pearl.volleysingleton.ParseError;
import com.hanuor.pearl.volleysingleton.Response;
import org.json.JSONException;
import org.json.JSONObject;
import com.hanuor.pearl.volleysingleton.Response.ErrorListener;
import com.hanuor.pearl.volleysingleton.Response.Listener;
import java.io.UnsupportedEncodingException; | /*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hanuor.pearl.toolbox;
/**
* A request for retrieving a {@link JSONObject} response body at a given URL, allowing for an
* optional {@link JSONObject} to be passed in as part of the request body.
*/
public class JsonObjectRequest extends JsonRequest<JSONObject> {
/**
* Creates a new request.
* @param method the HTTP method to use
* @param url URL to fetch the JSON from
* @param jsonRequest A {@link JSONObject} to post with the request. Null is allowed and
* indicates no parameters will be posted along with request.
* @param listener Listener to receive the JSON response
* @param errorListener Error listener, or null to ignore errors.
*/
public JsonObjectRequest(int method, String url, JSONObject jsonRequest, | // Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/NetworkResponse.java
// public class NetworkResponse {
// /**
// * Creates a new network response.
// * @param statusCode the HTTP status code
// * @param data Response body
// * @param headers Headers returned with this response, or null for none
// * @param notModified True if the server returned a 304 and the data was already in cache
// * @param networkTimeMs Round-trip network time to receive network response
// */
// public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers,
// boolean notModified, long networkTimeMs) {
// this.statusCode = statusCode;
// this.data = data;
// this.headers = headers;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers,
// boolean notModified) {
// this(statusCode, data, headers, notModified, 0);
// }
//
// public NetworkResponse(byte[] data) {
// this(HttpStatus.SC_OK, data, Collections.<String, String>emptyMap(), false, 0);
// }
//
// public NetworkResponse(byte[] data, Map<String, String> headers) {
// this(HttpStatus.SC_OK, data, headers, false, 0);
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Raw data from this response. */
// public final byte[] data;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/ParseError.java
// @SuppressWarnings("serial")
// public class ParseError extends VolleyError {
// public ParseError() { }
//
// public ParseError(NetworkResponse networkResponse) {
// super(networkResponse);
// }
//
// public ParseError(Throwable cause) {
// super(cause);
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public class Response<T> {
//
// /** Callback interface for delivering parsed responses. */
// public interface Listener<T> {
// /** Called when a response is received. */
// public void onResponse(Object tag, T response);
// }
//
// /** Callback interface for delivering error responses. */
// public interface ErrorListener {
// /**
// * Callback method that an error has been occurred with the
// * provided error code and optional user-readable message.
// */
// public void onErrorResponse(VolleyError error);
// }
//
// /** Returns a successful response containing the parsed result. */
// public static <T> Response<T> success(T result, Cache.Entry cacheEntry) {
// return new Response<T>(result, cacheEntry);
// }
//
// /**
// * Returns a failed response containing the given error code and an optional
// * localized message displayed to the user.
// */
// public static <T> Response<T> error(VolleyError error) {
// return new Response<T>(error);
// }
//
// /** Parsed response, or null in the case of error. */
// public final T result;
//
// /** Cache metadata for this response, or null in the case of error. */
// public final Cache.Entry cacheEntry;
//
// /** Detailed error information if <code>errorCode != OK</code>. */
// public final VolleyError error;
//
// /** True if this response was a soft-expired one and a second one MAY be coming. */
// public boolean intermediate = false;
//
// /**
// * Returns whether this response is considered successful.
// */
// public boolean isSuccess() {
// return error == null;
// }
//
//
// private Response(T result, Cache.Entry cacheEntry) {
// this.result = result;
// this.cacheEntry = cacheEntry;
// this.error = null;
// }
//
// private Response(VolleyError error) {
// this.result = null;
// this.cacheEntry = null;
// this.error = error;
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public interface ErrorListener {
// /**
// * Callback method that an error has been occurred with the
// * provided error code and optional user-readable message.
// */
// public void onErrorResponse(VolleyError error);
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public interface Listener<T> {
// /** Called when a response is received. */
// public void onResponse(Object tag, T response);
// }
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/JsonObjectRequest.java
import com.hanuor.pearl.volleysingleton.NetworkResponse;
import com.hanuor.pearl.volleysingleton.ParseError;
import com.hanuor.pearl.volleysingleton.Response;
import org.json.JSONException;
import org.json.JSONObject;
import com.hanuor.pearl.volleysingleton.Response.ErrorListener;
import com.hanuor.pearl.volleysingleton.Response.Listener;
import java.io.UnsupportedEncodingException;
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hanuor.pearl.toolbox;
/**
* A request for retrieving a {@link JSONObject} response body at a given URL, allowing for an
* optional {@link JSONObject} to be passed in as part of the request body.
*/
public class JsonObjectRequest extends JsonRequest<JSONObject> {
/**
* Creates a new request.
* @param method the HTTP method to use
* @param url URL to fetch the JSON from
* @param jsonRequest A {@link JSONObject} to post with the request. Null is allowed and
* indicates no parameters will be posted along with request.
* @param listener Listener to receive the JSON response
* @param errorListener Error listener, or null to ignore errors.
*/
public JsonObjectRequest(int method, String url, JSONObject jsonRequest, | Listener<JSONObject> listener, ErrorListener errorListener) { |
hanuor/pearl | pearl/src/main/java/com/hanuor/pearl/toolbox/JsonArrayRequest.java | // Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/NetworkResponse.java
// public class NetworkResponse {
// /**
// * Creates a new network response.
// * @param statusCode the HTTP status code
// * @param data Response body
// * @param headers Headers returned with this response, or null for none
// * @param notModified True if the server returned a 304 and the data was already in cache
// * @param networkTimeMs Round-trip network time to receive network response
// */
// public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers,
// boolean notModified, long networkTimeMs) {
// this.statusCode = statusCode;
// this.data = data;
// this.headers = headers;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers,
// boolean notModified) {
// this(statusCode, data, headers, notModified, 0);
// }
//
// public NetworkResponse(byte[] data) {
// this(HttpStatus.SC_OK, data, Collections.<String, String>emptyMap(), false, 0);
// }
//
// public NetworkResponse(byte[] data, Map<String, String> headers) {
// this(HttpStatus.SC_OK, data, headers, false, 0);
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Raw data from this response. */
// public final byte[] data;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/ParseError.java
// @SuppressWarnings("serial")
// public class ParseError extends VolleyError {
// public ParseError() { }
//
// public ParseError(NetworkResponse networkResponse) {
// super(networkResponse);
// }
//
// public ParseError(Throwable cause) {
// super(cause);
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public class Response<T> {
//
// /** Callback interface for delivering parsed responses. */
// public interface Listener<T> {
// /** Called when a response is received. */
// public void onResponse(Object tag, T response);
// }
//
// /** Callback interface for delivering error responses. */
// public interface ErrorListener {
// /**
// * Callback method that an error has been occurred with the
// * provided error code and optional user-readable message.
// */
// public void onErrorResponse(VolleyError error);
// }
//
// /** Returns a successful response containing the parsed result. */
// public static <T> Response<T> success(T result, Cache.Entry cacheEntry) {
// return new Response<T>(result, cacheEntry);
// }
//
// /**
// * Returns a failed response containing the given error code and an optional
// * localized message displayed to the user.
// */
// public static <T> Response<T> error(VolleyError error) {
// return new Response<T>(error);
// }
//
// /** Parsed response, or null in the case of error. */
// public final T result;
//
// /** Cache metadata for this response, or null in the case of error. */
// public final Cache.Entry cacheEntry;
//
// /** Detailed error information if <code>errorCode != OK</code>. */
// public final VolleyError error;
//
// /** True if this response was a soft-expired one and a second one MAY be coming. */
// public boolean intermediate = false;
//
// /**
// * Returns whether this response is considered successful.
// */
// public boolean isSuccess() {
// return error == null;
// }
//
//
// private Response(T result, Cache.Entry cacheEntry) {
// this.result = result;
// this.cacheEntry = cacheEntry;
// this.error = null;
// }
//
// private Response(VolleyError error) {
// this.result = null;
// this.cacheEntry = null;
// this.error = error;
// }
// }
| import com.hanuor.pearl.volleysingleton.NetworkResponse;
import com.hanuor.pearl.volleysingleton.ParseError;
import com.hanuor.pearl.volleysingleton.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException; | /*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hanuor.pearl.toolbox;
/**
* A request for retrieving a {@link JSONArray} response body at a given URL.
*/
public class JsonArrayRequest extends JsonRequest {
/**
* Creates a new request.
* @param url URL to fetch the JSON from
* @param listener Listener to receive the JSON response
* @param errorListener Error listener, or null to ignore errors.
*/
public JsonArrayRequest(String url, Response.Listener<JSONObject> listener, Response.ErrorListener errorListener) {
super(Method.GET, url, null, listener, errorListener);
}
/**
* Creates a new request.
* @param method the HTTP method to use
* @param url URL to fetch the JSON from
* @param jsonRequest A {@link JSONArray} to post with the request. Null is allowed and
* indicates no parameters will be posted along with request.
* @param listener Listener to receive the JSON response
* @param errorListener Error listener, or null to ignore errors.
*/
public JsonArrayRequest(int method, String url, JSONArray jsonRequest,
Response.Listener<JSONObject> listener, Response.ErrorListener errorListener) {
super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener,
errorListener);
}
@Override | // Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/NetworkResponse.java
// public class NetworkResponse {
// /**
// * Creates a new network response.
// * @param statusCode the HTTP status code
// * @param data Response body
// * @param headers Headers returned with this response, or null for none
// * @param notModified True if the server returned a 304 and the data was already in cache
// * @param networkTimeMs Round-trip network time to receive network response
// */
// public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers,
// boolean notModified, long networkTimeMs) {
// this.statusCode = statusCode;
// this.data = data;
// this.headers = headers;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers,
// boolean notModified) {
// this(statusCode, data, headers, notModified, 0);
// }
//
// public NetworkResponse(byte[] data) {
// this(HttpStatus.SC_OK, data, Collections.<String, String>emptyMap(), false, 0);
// }
//
// public NetworkResponse(byte[] data, Map<String, String> headers) {
// this(HttpStatus.SC_OK, data, headers, false, 0);
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Raw data from this response. */
// public final byte[] data;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/ParseError.java
// @SuppressWarnings("serial")
// public class ParseError extends VolleyError {
// public ParseError() { }
//
// public ParseError(NetworkResponse networkResponse) {
// super(networkResponse);
// }
//
// public ParseError(Throwable cause) {
// super(cause);
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Response.java
// public class Response<T> {
//
// /** Callback interface for delivering parsed responses. */
// public interface Listener<T> {
// /** Called when a response is received. */
// public void onResponse(Object tag, T response);
// }
//
// /** Callback interface for delivering error responses. */
// public interface ErrorListener {
// /**
// * Callback method that an error has been occurred with the
// * provided error code and optional user-readable message.
// */
// public void onErrorResponse(VolleyError error);
// }
//
// /** Returns a successful response containing the parsed result. */
// public static <T> Response<T> success(T result, Cache.Entry cacheEntry) {
// return new Response<T>(result, cacheEntry);
// }
//
// /**
// * Returns a failed response containing the given error code and an optional
// * localized message displayed to the user.
// */
// public static <T> Response<T> error(VolleyError error) {
// return new Response<T>(error);
// }
//
// /** Parsed response, or null in the case of error. */
// public final T result;
//
// /** Cache metadata for this response, or null in the case of error. */
// public final Cache.Entry cacheEntry;
//
// /** Detailed error information if <code>errorCode != OK</code>. */
// public final VolleyError error;
//
// /** True if this response was a soft-expired one and a second one MAY be coming. */
// public boolean intermediate = false;
//
// /**
// * Returns whether this response is considered successful.
// */
// public boolean isSuccess() {
// return error == null;
// }
//
//
// private Response(T result, Cache.Entry cacheEntry) {
// this.result = result;
// this.cacheEntry = cacheEntry;
// this.error = null;
// }
//
// private Response(VolleyError error) {
// this.result = null;
// this.cacheEntry = null;
// this.error = error;
// }
// }
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/JsonArrayRequest.java
import com.hanuor.pearl.volleysingleton.NetworkResponse;
import com.hanuor.pearl.volleysingleton.ParseError;
import com.hanuor.pearl.volleysingleton.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hanuor.pearl.toolbox;
/**
* A request for retrieving a {@link JSONArray} response body at a given URL.
*/
public class JsonArrayRequest extends JsonRequest {
/**
* Creates a new request.
* @param url URL to fetch the JSON from
* @param listener Listener to receive the JSON response
* @param errorListener Error listener, or null to ignore errors.
*/
public JsonArrayRequest(String url, Response.Listener<JSONObject> listener, Response.ErrorListener errorListener) {
super(Method.GET, url, null, listener, errorListener);
}
/**
* Creates a new request.
* @param method the HTTP method to use
* @param url URL to fetch the JSON from
* @param jsonRequest A {@link JSONArray} to post with the request. Null is allowed and
* indicates no parameters will be posted along with request.
* @param listener Listener to receive the JSON response
* @param errorListener Error listener, or null to ignore errors.
*/
public JsonArrayRequest(int method, String url, JSONArray jsonRequest,
Response.Listener<JSONObject> listener, Response.ErrorListener errorListener) {
super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener,
errorListener);
}
@Override | protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) { |
hanuor/pearl | sapphire/src/main/java/com/hanuor/sapphire/utils/DayModuloDeterminer.java | // Path: sapphire/src/main/java/com/hanuor/sapphire/temporarydb/PrivateDatabaseHelper.java
// public class PrivateDatabaseHelper extends SQLiteOpenHelper {
// private GetDayUtil getDayUtil = new GetDayUtil();
// private static final String PRIVATETREEDBNAME = "SapphirePrivateInit.db";
// private static final String GLOBALTABLENAME = "DataCollector";
// private static final String COLUMN_0 = "Sun";
// private static final String COLUMN_1 = "Mon";
// private static final String COLUMN_2 = "Tue";
// private static final String COLUMN_3 = "Wed";
// private static final String COLUMN_4 = "Thu";
// private static final String COLUMN_5 = "Fri";
// private static final String COLUMN_6 = "Sat";
// private static final int DB_Version = 1;
//
// public PrivateDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
// super(context, name, factory, version);
// }
// public PrivateDatabaseHelper(Context context) {
// super(context, PRIVATETREEDBNAME, null, DB_Version);
// }
//
//
// @Override
// public void onCreate(SQLiteDatabase sqLiteDatabase) {
// String TABLECREATE = "CREATE TABLE "+ GLOBALTABLENAME + "("+
// COLUMN_0 + " REAL," + COLUMN_1 + " REAL," +
// COLUMN_2 + " REAL," + COLUMN_3 + " REAL," +
// COLUMN_4 + " REAL," + COLUMN_5 + " REAL," +
// COLUMN_6 + " REAL" + ");";
// sqLiteDatabase.execSQL(TABLECREATE);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {}
//
// public double retrieveNodeColumnValue(int columnSET){
// //Coumn set is the passed day here.
// String GETCOLUMNNAME = null;
// SQLiteDatabase db = this.getReadableDatabase();
//
// switch (columnSET){
// case 0:
// GETCOLUMNNAME = "Sun";
// break;
// case 1:
// GETCOLUMNNAME = "Mon";
// break;
// case 2:
// GETCOLUMNNAME = "Tue";
// break;
// case 3:
// GETCOLUMNNAME = "Wed";
// break;
// case 4:
// GETCOLUMNNAME = "Thu";
// break;
// case 5:
// GETCOLUMNNAME = "Fri";
// break;
// case 6:
// GETCOLUMNNAME = "Sat";
// break;
// default:
// GETCOLUMNNAME = "Sun";
// break;
// }
// Log.d("GetColumn", ""+ GETCOLUMNNAME);
// String query_params = "SELECT " + GETCOLUMNNAME + " FROM " + GLOBALTABLENAME;
// Cursor cSor = db.rawQuery(query_params, null);
// if(cSor.moveToFirst()){
// do{
//
// Log.d("GetColumnreturnValue"," " + 1.00);
// return cSor.getDouble(cSor.getColumnIndex(GETCOLUMNNAME));
// }while(cSor.moveToNext());
//
// }else{
// Log.d("GetColumnreturnValue"," " + 0.0 + " DAY " + getDayUtil.getDay());
// return 0.0;
// }
// }
//
// public void enterColumn0Node(double value){
// //the below couple of lines should be done in JAR file
// double prevValue = retrieveNodeColumnValue(0);
// double newValue = prevValue + prevValue;
// SQLiteDatabase db = this.getWritableDatabase();
//
// }
// }
| import android.content.Context;
import com.hanuor.sapphire.temporarydb.PrivateDatabaseHelper;
import java.util.ArrayList;
import java.util.Calendar; | package com.hanuor.sapphire.utils;
/*
* Copyright (C) 2016 Hanuor Inc. by Shantanu Johri(https://hanuor.github.io/shanjohri/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public class DayModuloDeterminer {
private final Context context;
public DayModuloDeterminer(Context context) {
this.context = context;
}
public void startpvtTreelearning(ArrayList<String> _tags){
Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DAY_OF_WEEK); | // Path: sapphire/src/main/java/com/hanuor/sapphire/temporarydb/PrivateDatabaseHelper.java
// public class PrivateDatabaseHelper extends SQLiteOpenHelper {
// private GetDayUtil getDayUtil = new GetDayUtil();
// private static final String PRIVATETREEDBNAME = "SapphirePrivateInit.db";
// private static final String GLOBALTABLENAME = "DataCollector";
// private static final String COLUMN_0 = "Sun";
// private static final String COLUMN_1 = "Mon";
// private static final String COLUMN_2 = "Tue";
// private static final String COLUMN_3 = "Wed";
// private static final String COLUMN_4 = "Thu";
// private static final String COLUMN_5 = "Fri";
// private static final String COLUMN_6 = "Sat";
// private static final int DB_Version = 1;
//
// public PrivateDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
// super(context, name, factory, version);
// }
// public PrivateDatabaseHelper(Context context) {
// super(context, PRIVATETREEDBNAME, null, DB_Version);
// }
//
//
// @Override
// public void onCreate(SQLiteDatabase sqLiteDatabase) {
// String TABLECREATE = "CREATE TABLE "+ GLOBALTABLENAME + "("+
// COLUMN_0 + " REAL," + COLUMN_1 + " REAL," +
// COLUMN_2 + " REAL," + COLUMN_3 + " REAL," +
// COLUMN_4 + " REAL," + COLUMN_5 + " REAL," +
// COLUMN_6 + " REAL" + ");";
// sqLiteDatabase.execSQL(TABLECREATE);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {}
//
// public double retrieveNodeColumnValue(int columnSET){
// //Coumn set is the passed day here.
// String GETCOLUMNNAME = null;
// SQLiteDatabase db = this.getReadableDatabase();
//
// switch (columnSET){
// case 0:
// GETCOLUMNNAME = "Sun";
// break;
// case 1:
// GETCOLUMNNAME = "Mon";
// break;
// case 2:
// GETCOLUMNNAME = "Tue";
// break;
// case 3:
// GETCOLUMNNAME = "Wed";
// break;
// case 4:
// GETCOLUMNNAME = "Thu";
// break;
// case 5:
// GETCOLUMNNAME = "Fri";
// break;
// case 6:
// GETCOLUMNNAME = "Sat";
// break;
// default:
// GETCOLUMNNAME = "Sun";
// break;
// }
// Log.d("GetColumn", ""+ GETCOLUMNNAME);
// String query_params = "SELECT " + GETCOLUMNNAME + " FROM " + GLOBALTABLENAME;
// Cursor cSor = db.rawQuery(query_params, null);
// if(cSor.moveToFirst()){
// do{
//
// Log.d("GetColumnreturnValue"," " + 1.00);
// return cSor.getDouble(cSor.getColumnIndex(GETCOLUMNNAME));
// }while(cSor.moveToNext());
//
// }else{
// Log.d("GetColumnreturnValue"," " + 0.0 + " DAY " + getDayUtil.getDay());
// return 0.0;
// }
// }
//
// public void enterColumn0Node(double value){
// //the below couple of lines should be done in JAR file
// double prevValue = retrieveNodeColumnValue(0);
// double newValue = prevValue + prevValue;
// SQLiteDatabase db = this.getWritableDatabase();
//
// }
// }
// Path: sapphire/src/main/java/com/hanuor/sapphire/utils/DayModuloDeterminer.java
import android.content.Context;
import com.hanuor.sapphire.temporarydb.PrivateDatabaseHelper;
import java.util.ArrayList;
import java.util.Calendar;
package com.hanuor.sapphire.utils;
/*
* Copyright (C) 2016 Hanuor Inc. by Shantanu Johri(https://hanuor.github.io/shanjohri/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public class DayModuloDeterminer {
private final Context context;
public DayModuloDeterminer(Context context) {
this.context = context;
}
public void startpvtTreelearning(ArrayList<String> _tags){
Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DAY_OF_WEEK); | PrivateDatabaseHelper privateDatabaseHelper = new PrivateDatabaseHelper(context); |
hanuor/pearl | pearl/src/main/java/com/hanuor/pearl/toolbox/NetworkImageView.java | // Path: pearl/src/main/java/com/hanuor/pearl/toolbox/ImageLoader.java
// public class ImageContainer {
// /**
// * The most relevant bitmap for the container. If the image was in cache, the
// * Holder to use for the final bitmap (the one that pairs to the requested URL).
// */
// private Bitmap mBitmap;
//
// private final ImageListener mListener;
//
// /** The cache key that was associated with the request */
// private final String mCacheKey;
//
// /** The request URL that was specified */
// private final String mRequestUrl;
//
// /**
// * Constructs a BitmapContainer object.
// * @param bitmap The final bitmap (if it exists).
// * @param requestUrl The requested URL for this container.
// * @param cacheKey The cache key that identifies the requested URL for this container.
// */
// public ImageContainer(Bitmap bitmap, String requestUrl,
// String cacheKey, ImageListener listener) {
// mBitmap = bitmap;
// mRequestUrl = requestUrl;
// mCacheKey = cacheKey;
// mListener = listener;
// }
//
// /**
// * Releases interest in the in-flight request (and cancels it if no one else is listening).
// */
// public void cancelRequest() {
// if (mListener == null) {
// return;
// }
//
// BatchedImageRequest request = mInFlightRequests.get(mCacheKey);
// if (request != null) {
// boolean canceled = request.removeContainerAndCancelIfNecessary(this);
// if (canceled) {
// mInFlightRequests.remove(mCacheKey);
// }
// } else {
// // check to see if it is already batched for delivery.
// request = mBatchedResponses.get(mCacheKey);
// if (request != null) {
// request.removeContainerAndCancelIfNecessary(this);
// if (request.mContainers.size() == 0) {
// mBatchedResponses.remove(mCacheKey);
// }
// }
// }
// }
//
// /**
// * Returns the bitmap associated with the request URL if it has been loaded, null otherwise.
// */
// public Bitmap getBitmap() {
// return mBitmap;
// }
//
// /**
// * Returns the requested URL for this container.
// */
// public String getRequestUrl() {
// return mRequestUrl;
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/ImageLoader.java
// public interface ImageListener extends Response.ErrorListener {
// /**
// * Listens for non-error changes to the loading of the image request.
// *
// * @param response Holds all information pertaining to the request, as well
// * as the bitmap (if it is loaded).
// * @param isImmediate True if this was called during ImageLoader.get() variants.
// * This can be used to differentiate between a cached image loading and a network
// * image loading in order to, for example, run an animation to fade in network loaded
// * images.
// */
// public void onResponse(ImageContainer response, boolean isImmediate);
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/VolleyError.java
// @SuppressWarnings("serial")
// public class VolleyError extends Exception {
// public final NetworkResponse networkResponse;
// private long networkTimeMs;
//
// public VolleyError() {
// networkResponse = null;
// }
//
// public VolleyError(NetworkResponse response) {
// networkResponse = response;
// }
//
// public VolleyError(String exceptionMessage) {
// super(exceptionMessage);
// networkResponse = null;
// }
//
// public VolleyError(String exceptionMessage, Throwable reason) {
// super(exceptionMessage, reason);
// networkResponse = null;
// }
//
// public VolleyError(Throwable cause) {
// super(cause);
// networkResponse = null;
// }
//
// /* package */ void setNetworkTimeMs(long networkTimeMs) {
// this.networkTimeMs = networkTimeMs;
// }
//
// public long getNetworkTimeMs() {
// return networkTimeMs;
// }
// }
| import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import com.hanuor.pearl.toolbox.ImageLoader.ImageContainer;
import com.hanuor.pearl.toolbox.ImageLoader.ImageListener;
import com.hanuor.pearl.volleysingleton.VolleyError; | /**
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hanuor.pearl.toolbox;
/**
* Handles fetching an image from a URL as well as the life-cycle of the
* associated request.
*/
public class NetworkImageView extends ImageView {
/** The URL of the network image to load */
private String mUrl;
/**
* Resource ID of the image to be used as a placeholder until the network image is loaded.
*/
private int mDefaultImageId;
/**
* Resource ID of the image to be used if the network response fails.
*/
private int mErrorImageId;
/** Local copy of the ImageLoader. */
private ImageLoader mImageLoader;
/** Current ImageContainer. (either in-flight or finished) */ | // Path: pearl/src/main/java/com/hanuor/pearl/toolbox/ImageLoader.java
// public class ImageContainer {
// /**
// * The most relevant bitmap for the container. If the image was in cache, the
// * Holder to use for the final bitmap (the one that pairs to the requested URL).
// */
// private Bitmap mBitmap;
//
// private final ImageListener mListener;
//
// /** The cache key that was associated with the request */
// private final String mCacheKey;
//
// /** The request URL that was specified */
// private final String mRequestUrl;
//
// /**
// * Constructs a BitmapContainer object.
// * @param bitmap The final bitmap (if it exists).
// * @param requestUrl The requested URL for this container.
// * @param cacheKey The cache key that identifies the requested URL for this container.
// */
// public ImageContainer(Bitmap bitmap, String requestUrl,
// String cacheKey, ImageListener listener) {
// mBitmap = bitmap;
// mRequestUrl = requestUrl;
// mCacheKey = cacheKey;
// mListener = listener;
// }
//
// /**
// * Releases interest in the in-flight request (and cancels it if no one else is listening).
// */
// public void cancelRequest() {
// if (mListener == null) {
// return;
// }
//
// BatchedImageRequest request = mInFlightRequests.get(mCacheKey);
// if (request != null) {
// boolean canceled = request.removeContainerAndCancelIfNecessary(this);
// if (canceled) {
// mInFlightRequests.remove(mCacheKey);
// }
// } else {
// // check to see if it is already batched for delivery.
// request = mBatchedResponses.get(mCacheKey);
// if (request != null) {
// request.removeContainerAndCancelIfNecessary(this);
// if (request.mContainers.size() == 0) {
// mBatchedResponses.remove(mCacheKey);
// }
// }
// }
// }
//
// /**
// * Returns the bitmap associated with the request URL if it has been loaded, null otherwise.
// */
// public Bitmap getBitmap() {
// return mBitmap;
// }
//
// /**
// * Returns the requested URL for this container.
// */
// public String getRequestUrl() {
// return mRequestUrl;
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/ImageLoader.java
// public interface ImageListener extends Response.ErrorListener {
// /**
// * Listens for non-error changes to the loading of the image request.
// *
// * @param response Holds all information pertaining to the request, as well
// * as the bitmap (if it is loaded).
// * @param isImmediate True if this was called during ImageLoader.get() variants.
// * This can be used to differentiate between a cached image loading and a network
// * image loading in order to, for example, run an animation to fade in network loaded
// * images.
// */
// public void onResponse(ImageContainer response, boolean isImmediate);
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/VolleyError.java
// @SuppressWarnings("serial")
// public class VolleyError extends Exception {
// public final NetworkResponse networkResponse;
// private long networkTimeMs;
//
// public VolleyError() {
// networkResponse = null;
// }
//
// public VolleyError(NetworkResponse response) {
// networkResponse = response;
// }
//
// public VolleyError(String exceptionMessage) {
// super(exceptionMessage);
// networkResponse = null;
// }
//
// public VolleyError(String exceptionMessage, Throwable reason) {
// super(exceptionMessage, reason);
// networkResponse = null;
// }
//
// public VolleyError(Throwable cause) {
// super(cause);
// networkResponse = null;
// }
//
// /* package */ void setNetworkTimeMs(long networkTimeMs) {
// this.networkTimeMs = networkTimeMs;
// }
//
// public long getNetworkTimeMs() {
// return networkTimeMs;
// }
// }
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/NetworkImageView.java
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import com.hanuor.pearl.toolbox.ImageLoader.ImageContainer;
import com.hanuor.pearl.toolbox.ImageLoader.ImageListener;
import com.hanuor.pearl.volleysingleton.VolleyError;
/**
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hanuor.pearl.toolbox;
/**
* Handles fetching an image from a URL as well as the life-cycle of the
* associated request.
*/
public class NetworkImageView extends ImageView {
/** The URL of the network image to load */
private String mUrl;
/**
* Resource ID of the image to be used as a placeholder until the network image is loaded.
*/
private int mDefaultImageId;
/**
* Resource ID of the image to be used if the network response fails.
*/
private int mErrorImageId;
/** Local copy of the ImageLoader. */
private ImageLoader mImageLoader;
/** Current ImageContainer. (either in-flight or finished) */ | private ImageContainer mImageContainer; |
hanuor/pearl | pearl/src/main/java/com/hanuor/pearl/toolbox/NetworkImageView.java | // Path: pearl/src/main/java/com/hanuor/pearl/toolbox/ImageLoader.java
// public class ImageContainer {
// /**
// * The most relevant bitmap for the container. If the image was in cache, the
// * Holder to use for the final bitmap (the one that pairs to the requested URL).
// */
// private Bitmap mBitmap;
//
// private final ImageListener mListener;
//
// /** The cache key that was associated with the request */
// private final String mCacheKey;
//
// /** The request URL that was specified */
// private final String mRequestUrl;
//
// /**
// * Constructs a BitmapContainer object.
// * @param bitmap The final bitmap (if it exists).
// * @param requestUrl The requested URL for this container.
// * @param cacheKey The cache key that identifies the requested URL for this container.
// */
// public ImageContainer(Bitmap bitmap, String requestUrl,
// String cacheKey, ImageListener listener) {
// mBitmap = bitmap;
// mRequestUrl = requestUrl;
// mCacheKey = cacheKey;
// mListener = listener;
// }
//
// /**
// * Releases interest in the in-flight request (and cancels it if no one else is listening).
// */
// public void cancelRequest() {
// if (mListener == null) {
// return;
// }
//
// BatchedImageRequest request = mInFlightRequests.get(mCacheKey);
// if (request != null) {
// boolean canceled = request.removeContainerAndCancelIfNecessary(this);
// if (canceled) {
// mInFlightRequests.remove(mCacheKey);
// }
// } else {
// // check to see if it is already batched for delivery.
// request = mBatchedResponses.get(mCacheKey);
// if (request != null) {
// request.removeContainerAndCancelIfNecessary(this);
// if (request.mContainers.size() == 0) {
// mBatchedResponses.remove(mCacheKey);
// }
// }
// }
// }
//
// /**
// * Returns the bitmap associated with the request URL if it has been loaded, null otherwise.
// */
// public Bitmap getBitmap() {
// return mBitmap;
// }
//
// /**
// * Returns the requested URL for this container.
// */
// public String getRequestUrl() {
// return mRequestUrl;
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/ImageLoader.java
// public interface ImageListener extends Response.ErrorListener {
// /**
// * Listens for non-error changes to the loading of the image request.
// *
// * @param response Holds all information pertaining to the request, as well
// * as the bitmap (if it is loaded).
// * @param isImmediate True if this was called during ImageLoader.get() variants.
// * This can be used to differentiate between a cached image loading and a network
// * image loading in order to, for example, run an animation to fade in network loaded
// * images.
// */
// public void onResponse(ImageContainer response, boolean isImmediate);
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/VolleyError.java
// @SuppressWarnings("serial")
// public class VolleyError extends Exception {
// public final NetworkResponse networkResponse;
// private long networkTimeMs;
//
// public VolleyError() {
// networkResponse = null;
// }
//
// public VolleyError(NetworkResponse response) {
// networkResponse = response;
// }
//
// public VolleyError(String exceptionMessage) {
// super(exceptionMessage);
// networkResponse = null;
// }
//
// public VolleyError(String exceptionMessage, Throwable reason) {
// super(exceptionMessage, reason);
// networkResponse = null;
// }
//
// public VolleyError(Throwable cause) {
// super(cause);
// networkResponse = null;
// }
//
// /* package */ void setNetworkTimeMs(long networkTimeMs) {
// this.networkTimeMs = networkTimeMs;
// }
//
// public long getNetworkTimeMs() {
// return networkTimeMs;
// }
// }
| import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import com.hanuor.pearl.toolbox.ImageLoader.ImageContainer;
import com.hanuor.pearl.toolbox.ImageLoader.ImageListener;
import com.hanuor.pearl.volleysingleton.VolleyError; | // if the URL to be loaded in this view is empty, cancel any old requests and clear the
// currently loaded image.
if (TextUtils.isEmpty(mUrl)) {
if (mImageContainer != null) {
mImageContainer.cancelRequest();
mImageContainer = null;
}
setDefaultImageOrNull();
return;
}
// if there was an old request in this view, check if it needs to be canceled.
if (mImageContainer != null && mImageContainer.getRequestUrl() != null) {
if (mImageContainer.getRequestUrl().equals(mUrl)) {
// if the request is from the same URL, return.
return;
} else {
// if there is a pre-existing request, cancel it if it's fetching a different URL.
mImageContainer.cancelRequest();
setDefaultImageOrNull();
}
}
// Calculate the max image width / height to use while ignoring WRAP_CONTENT dimens.
int maxWidth = wrapWidth ? 0 : width;
int maxHeight = wrapHeight ? 0 : height;
// The pre-existing content of this view didn't match the current URL. Load the new image
// from the network.
ImageContainer newContainer = mImageLoader.get(mUrl, | // Path: pearl/src/main/java/com/hanuor/pearl/toolbox/ImageLoader.java
// public class ImageContainer {
// /**
// * The most relevant bitmap for the container. If the image was in cache, the
// * Holder to use for the final bitmap (the one that pairs to the requested URL).
// */
// private Bitmap mBitmap;
//
// private final ImageListener mListener;
//
// /** The cache key that was associated with the request */
// private final String mCacheKey;
//
// /** The request URL that was specified */
// private final String mRequestUrl;
//
// /**
// * Constructs a BitmapContainer object.
// * @param bitmap The final bitmap (if it exists).
// * @param requestUrl The requested URL for this container.
// * @param cacheKey The cache key that identifies the requested URL for this container.
// */
// public ImageContainer(Bitmap bitmap, String requestUrl,
// String cacheKey, ImageListener listener) {
// mBitmap = bitmap;
// mRequestUrl = requestUrl;
// mCacheKey = cacheKey;
// mListener = listener;
// }
//
// /**
// * Releases interest in the in-flight request (and cancels it if no one else is listening).
// */
// public void cancelRequest() {
// if (mListener == null) {
// return;
// }
//
// BatchedImageRequest request = mInFlightRequests.get(mCacheKey);
// if (request != null) {
// boolean canceled = request.removeContainerAndCancelIfNecessary(this);
// if (canceled) {
// mInFlightRequests.remove(mCacheKey);
// }
// } else {
// // check to see if it is already batched for delivery.
// request = mBatchedResponses.get(mCacheKey);
// if (request != null) {
// request.removeContainerAndCancelIfNecessary(this);
// if (request.mContainers.size() == 0) {
// mBatchedResponses.remove(mCacheKey);
// }
// }
// }
// }
//
// /**
// * Returns the bitmap associated with the request URL if it has been loaded, null otherwise.
// */
// public Bitmap getBitmap() {
// return mBitmap;
// }
//
// /**
// * Returns the requested URL for this container.
// */
// public String getRequestUrl() {
// return mRequestUrl;
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/ImageLoader.java
// public interface ImageListener extends Response.ErrorListener {
// /**
// * Listens for non-error changes to the loading of the image request.
// *
// * @param response Holds all information pertaining to the request, as well
// * as the bitmap (if it is loaded).
// * @param isImmediate True if this was called during ImageLoader.get() variants.
// * This can be used to differentiate between a cached image loading and a network
// * image loading in order to, for example, run an animation to fade in network loaded
// * images.
// */
// public void onResponse(ImageContainer response, boolean isImmediate);
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/VolleyError.java
// @SuppressWarnings("serial")
// public class VolleyError extends Exception {
// public final NetworkResponse networkResponse;
// private long networkTimeMs;
//
// public VolleyError() {
// networkResponse = null;
// }
//
// public VolleyError(NetworkResponse response) {
// networkResponse = response;
// }
//
// public VolleyError(String exceptionMessage) {
// super(exceptionMessage);
// networkResponse = null;
// }
//
// public VolleyError(String exceptionMessage, Throwable reason) {
// super(exceptionMessage, reason);
// networkResponse = null;
// }
//
// public VolleyError(Throwable cause) {
// super(cause);
// networkResponse = null;
// }
//
// /* package */ void setNetworkTimeMs(long networkTimeMs) {
// this.networkTimeMs = networkTimeMs;
// }
//
// public long getNetworkTimeMs() {
// return networkTimeMs;
// }
// }
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/NetworkImageView.java
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import com.hanuor.pearl.toolbox.ImageLoader.ImageContainer;
import com.hanuor.pearl.toolbox.ImageLoader.ImageListener;
import com.hanuor.pearl.volleysingleton.VolleyError;
// if the URL to be loaded in this view is empty, cancel any old requests and clear the
// currently loaded image.
if (TextUtils.isEmpty(mUrl)) {
if (mImageContainer != null) {
mImageContainer.cancelRequest();
mImageContainer = null;
}
setDefaultImageOrNull();
return;
}
// if there was an old request in this view, check if it needs to be canceled.
if (mImageContainer != null && mImageContainer.getRequestUrl() != null) {
if (mImageContainer.getRequestUrl().equals(mUrl)) {
// if the request is from the same URL, return.
return;
} else {
// if there is a pre-existing request, cancel it if it's fetching a different URL.
mImageContainer.cancelRequest();
setDefaultImageOrNull();
}
}
// Calculate the max image width / height to use while ignoring WRAP_CONTENT dimens.
int maxWidth = wrapWidth ? 0 : width;
int maxHeight = wrapHeight ? 0 : height;
// The pre-existing content of this view didn't match the current URL. Load the new image
// from the network.
ImageContainer newContainer = mImageLoader.get(mUrl, | new ImageListener() { |
hanuor/pearl | pearl/src/main/java/com/hanuor/pearl/toolbox/NetworkImageView.java | // Path: pearl/src/main/java/com/hanuor/pearl/toolbox/ImageLoader.java
// public class ImageContainer {
// /**
// * The most relevant bitmap for the container. If the image was in cache, the
// * Holder to use for the final bitmap (the one that pairs to the requested URL).
// */
// private Bitmap mBitmap;
//
// private final ImageListener mListener;
//
// /** The cache key that was associated with the request */
// private final String mCacheKey;
//
// /** The request URL that was specified */
// private final String mRequestUrl;
//
// /**
// * Constructs a BitmapContainer object.
// * @param bitmap The final bitmap (if it exists).
// * @param requestUrl The requested URL for this container.
// * @param cacheKey The cache key that identifies the requested URL for this container.
// */
// public ImageContainer(Bitmap bitmap, String requestUrl,
// String cacheKey, ImageListener listener) {
// mBitmap = bitmap;
// mRequestUrl = requestUrl;
// mCacheKey = cacheKey;
// mListener = listener;
// }
//
// /**
// * Releases interest in the in-flight request (and cancels it if no one else is listening).
// */
// public void cancelRequest() {
// if (mListener == null) {
// return;
// }
//
// BatchedImageRequest request = mInFlightRequests.get(mCacheKey);
// if (request != null) {
// boolean canceled = request.removeContainerAndCancelIfNecessary(this);
// if (canceled) {
// mInFlightRequests.remove(mCacheKey);
// }
// } else {
// // check to see if it is already batched for delivery.
// request = mBatchedResponses.get(mCacheKey);
// if (request != null) {
// request.removeContainerAndCancelIfNecessary(this);
// if (request.mContainers.size() == 0) {
// mBatchedResponses.remove(mCacheKey);
// }
// }
// }
// }
//
// /**
// * Returns the bitmap associated with the request URL if it has been loaded, null otherwise.
// */
// public Bitmap getBitmap() {
// return mBitmap;
// }
//
// /**
// * Returns the requested URL for this container.
// */
// public String getRequestUrl() {
// return mRequestUrl;
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/ImageLoader.java
// public interface ImageListener extends Response.ErrorListener {
// /**
// * Listens for non-error changes to the loading of the image request.
// *
// * @param response Holds all information pertaining to the request, as well
// * as the bitmap (if it is loaded).
// * @param isImmediate True if this was called during ImageLoader.get() variants.
// * This can be used to differentiate between a cached image loading and a network
// * image loading in order to, for example, run an animation to fade in network loaded
// * images.
// */
// public void onResponse(ImageContainer response, boolean isImmediate);
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/VolleyError.java
// @SuppressWarnings("serial")
// public class VolleyError extends Exception {
// public final NetworkResponse networkResponse;
// private long networkTimeMs;
//
// public VolleyError() {
// networkResponse = null;
// }
//
// public VolleyError(NetworkResponse response) {
// networkResponse = response;
// }
//
// public VolleyError(String exceptionMessage) {
// super(exceptionMessage);
// networkResponse = null;
// }
//
// public VolleyError(String exceptionMessage, Throwable reason) {
// super(exceptionMessage, reason);
// networkResponse = null;
// }
//
// public VolleyError(Throwable cause) {
// super(cause);
// networkResponse = null;
// }
//
// /* package */ void setNetworkTimeMs(long networkTimeMs) {
// this.networkTimeMs = networkTimeMs;
// }
//
// public long getNetworkTimeMs() {
// return networkTimeMs;
// }
// }
| import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import com.hanuor.pearl.toolbox.ImageLoader.ImageContainer;
import com.hanuor.pearl.toolbox.ImageLoader.ImageListener;
import com.hanuor.pearl.volleysingleton.VolleyError; | if (TextUtils.isEmpty(mUrl)) {
if (mImageContainer != null) {
mImageContainer.cancelRequest();
mImageContainer = null;
}
setDefaultImageOrNull();
return;
}
// if there was an old request in this view, check if it needs to be canceled.
if (mImageContainer != null && mImageContainer.getRequestUrl() != null) {
if (mImageContainer.getRequestUrl().equals(mUrl)) {
// if the request is from the same URL, return.
return;
} else {
// if there is a pre-existing request, cancel it if it's fetching a different URL.
mImageContainer.cancelRequest();
setDefaultImageOrNull();
}
}
// Calculate the max image width / height to use while ignoring WRAP_CONTENT dimens.
int maxWidth = wrapWidth ? 0 : width;
int maxHeight = wrapHeight ? 0 : height;
// The pre-existing content of this view didn't match the current URL. Load the new image
// from the network.
ImageContainer newContainer = mImageLoader.get(mUrl,
new ImageListener() {
@Override | // Path: pearl/src/main/java/com/hanuor/pearl/toolbox/ImageLoader.java
// public class ImageContainer {
// /**
// * The most relevant bitmap for the container. If the image was in cache, the
// * Holder to use for the final bitmap (the one that pairs to the requested URL).
// */
// private Bitmap mBitmap;
//
// private final ImageListener mListener;
//
// /** The cache key that was associated with the request */
// private final String mCacheKey;
//
// /** The request URL that was specified */
// private final String mRequestUrl;
//
// /**
// * Constructs a BitmapContainer object.
// * @param bitmap The final bitmap (if it exists).
// * @param requestUrl The requested URL for this container.
// * @param cacheKey The cache key that identifies the requested URL for this container.
// */
// public ImageContainer(Bitmap bitmap, String requestUrl,
// String cacheKey, ImageListener listener) {
// mBitmap = bitmap;
// mRequestUrl = requestUrl;
// mCacheKey = cacheKey;
// mListener = listener;
// }
//
// /**
// * Releases interest in the in-flight request (and cancels it if no one else is listening).
// */
// public void cancelRequest() {
// if (mListener == null) {
// return;
// }
//
// BatchedImageRequest request = mInFlightRequests.get(mCacheKey);
// if (request != null) {
// boolean canceled = request.removeContainerAndCancelIfNecessary(this);
// if (canceled) {
// mInFlightRequests.remove(mCacheKey);
// }
// } else {
// // check to see if it is already batched for delivery.
// request = mBatchedResponses.get(mCacheKey);
// if (request != null) {
// request.removeContainerAndCancelIfNecessary(this);
// if (request.mContainers.size() == 0) {
// mBatchedResponses.remove(mCacheKey);
// }
// }
// }
// }
//
// /**
// * Returns the bitmap associated with the request URL if it has been loaded, null otherwise.
// */
// public Bitmap getBitmap() {
// return mBitmap;
// }
//
// /**
// * Returns the requested URL for this container.
// */
// public String getRequestUrl() {
// return mRequestUrl;
// }
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/ImageLoader.java
// public interface ImageListener extends Response.ErrorListener {
// /**
// * Listens for non-error changes to the loading of the image request.
// *
// * @param response Holds all information pertaining to the request, as well
// * as the bitmap (if it is loaded).
// * @param isImmediate True if this was called during ImageLoader.get() variants.
// * This can be used to differentiate between a cached image loading and a network
// * image loading in order to, for example, run an animation to fade in network loaded
// * images.
// */
// public void onResponse(ImageContainer response, boolean isImmediate);
// }
//
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/VolleyError.java
// @SuppressWarnings("serial")
// public class VolleyError extends Exception {
// public final NetworkResponse networkResponse;
// private long networkTimeMs;
//
// public VolleyError() {
// networkResponse = null;
// }
//
// public VolleyError(NetworkResponse response) {
// networkResponse = response;
// }
//
// public VolleyError(String exceptionMessage) {
// super(exceptionMessage);
// networkResponse = null;
// }
//
// public VolleyError(String exceptionMessage, Throwable reason) {
// super(exceptionMessage, reason);
// networkResponse = null;
// }
//
// public VolleyError(Throwable cause) {
// super(cause);
// networkResponse = null;
// }
//
// /* package */ void setNetworkTimeMs(long networkTimeMs) {
// this.networkTimeMs = networkTimeMs;
// }
//
// public long getNetworkTimeMs() {
// return networkTimeMs;
// }
// }
// Path: pearl/src/main/java/com/hanuor/pearl/toolbox/NetworkImageView.java
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import com.hanuor.pearl.toolbox.ImageLoader.ImageContainer;
import com.hanuor.pearl.toolbox.ImageLoader.ImageListener;
import com.hanuor.pearl.volleysingleton.VolleyError;
if (TextUtils.isEmpty(mUrl)) {
if (mImageContainer != null) {
mImageContainer.cancelRequest();
mImageContainer = null;
}
setDefaultImageOrNull();
return;
}
// if there was an old request in this view, check if it needs to be canceled.
if (mImageContainer != null && mImageContainer.getRequestUrl() != null) {
if (mImageContainer.getRequestUrl().equals(mUrl)) {
// if the request is from the same URL, return.
return;
} else {
// if there is a pre-existing request, cancel it if it's fetching a different URL.
mImageContainer.cancelRequest();
setDefaultImageOrNull();
}
}
// Calculate the max image width / height to use while ignoring WRAP_CONTENT dimens.
int maxWidth = wrapWidth ? 0 : width;
int maxHeight = wrapHeight ? 0 : height;
// The pre-existing content of this view didn't match the current URL. Load the new image
// from the network.
ImageContainer newContainer = mImageLoader.get(mUrl,
new ImageListener() {
@Override | public void onErrorResponse(VolleyError error) { |
hanuor/pearl | pearl/src/main/java/com/hanuor/pearl/volleysingleton/Request.java | // Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/VolleyLog.java
// static class MarkerLog {
// public static final boolean ENABLED = VolleyLog.DEBUG;
//
// /** Minimum duration from first marker to last in an marker log to warrant logging. */
// private static final long MIN_DURATION_FOR_LOGGING_MS = 0;
//
// private static class Marker {
// public final String name;
// public final long thread;
// public final long time;
//
// public Marker(String name, long thread, long time) {
// this.name = name;
// this.thread = thread;
// this.time = time;
// }
// }
//
// private final List<Marker> mMarkers = new ArrayList<Marker>();
// private boolean mFinished = false;
//
// /** Adds a marker to this log with the specified name. */
// public synchronized void add(String name, long threadId) {
// if (mFinished) {
// throw new IllegalStateException("Marker added to finished log");
// }
//
// mMarkers.add(new Marker(name, threadId, SystemClock.elapsedRealtime()));
// }
//
// public synchronized void finish(String header) {
// mFinished = true;
//
// long duration = getTotalDuration();
// if (duration <= MIN_DURATION_FOR_LOGGING_MS) {
// return;
// }
//
// long prevTime = mMarkers.get(0).time;
// d("(%-4d ms) %s", duration, header);
// for (Marker marker : mMarkers) {
// long thisTime = marker.time;
// d("(+%-4d) [%2d] %s", (thisTime - prevTime), marker.thread, marker.name);
// prevTime = thisTime;
// }
// }
//
// @Override
// protected void finalize() throws Throwable {
// // Catch requests that have been collected (and hence end-of-lifed)
// // but had no debugging output printed for them.
// if (!mFinished) {
// finish("Request on the loose");
// e("Marker log finalized without finish() - uncaught exit point for request");
// }
// }
//
// /** Returns the time difference between the first and last events in this log. */
// private long getTotalDuration() {
// if (mMarkers.size() == 0) {
// return 0;
// }
//
// long first = mMarkers.get(0).time;
// long last = mMarkers.get(mMarkers.size() - 1).time;
// return last - first;
// }
// }
| import android.net.TrafficStats;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.hanuor.pearl.volleysingleton.VolleyLog.MarkerLog;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.Map; | /*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hanuor.pearl.volleysingleton;
/**
* Base class for all network requests.
*
* @param <T> The type of parsed response this request expects.
*/
public abstract class Request<T> implements Comparable<Request<T>> {
/**
* Default encoding for POST or PUT parameters. See {@link #getParamsEncoding()}.
*/
private static final String DEFAULT_PARAMS_ENCODING = "UTF-8";
/**
* Supported request methods.
*/
public interface Method {
int DEPRECATED_GET_OR_POST = -1;
int GET = 0;
int POST = 1;
int PUT = 2;
int DELETE = 3;
int HEAD = 4;
int OPTIONS = 5;
int TRACE = 6;
int PATCH = 7;
}
/** An event log tracing the lifetime of this request; for debugging. */ | // Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/VolleyLog.java
// static class MarkerLog {
// public static final boolean ENABLED = VolleyLog.DEBUG;
//
// /** Minimum duration from first marker to last in an marker log to warrant logging. */
// private static final long MIN_DURATION_FOR_LOGGING_MS = 0;
//
// private static class Marker {
// public final String name;
// public final long thread;
// public final long time;
//
// public Marker(String name, long thread, long time) {
// this.name = name;
// this.thread = thread;
// this.time = time;
// }
// }
//
// private final List<Marker> mMarkers = new ArrayList<Marker>();
// private boolean mFinished = false;
//
// /** Adds a marker to this log with the specified name. */
// public synchronized void add(String name, long threadId) {
// if (mFinished) {
// throw new IllegalStateException("Marker added to finished log");
// }
//
// mMarkers.add(new Marker(name, threadId, SystemClock.elapsedRealtime()));
// }
//
// public synchronized void finish(String header) {
// mFinished = true;
//
// long duration = getTotalDuration();
// if (duration <= MIN_DURATION_FOR_LOGGING_MS) {
// return;
// }
//
// long prevTime = mMarkers.get(0).time;
// d("(%-4d ms) %s", duration, header);
// for (Marker marker : mMarkers) {
// long thisTime = marker.time;
// d("(+%-4d) [%2d] %s", (thisTime - prevTime), marker.thread, marker.name);
// prevTime = thisTime;
// }
// }
//
// @Override
// protected void finalize() throws Throwable {
// // Catch requests that have been collected (and hence end-of-lifed)
// // but had no debugging output printed for them.
// if (!mFinished) {
// finish("Request on the loose");
// e("Marker log finalized without finish() - uncaught exit point for request");
// }
// }
//
// /** Returns the time difference between the first and last events in this log. */
// private long getTotalDuration() {
// if (mMarkers.size() == 0) {
// return 0;
// }
//
// long first = mMarkers.get(0).time;
// long last = mMarkers.get(mMarkers.size() - 1).time;
// return last - first;
// }
// }
// Path: pearl/src/main/java/com/hanuor/pearl/volleysingleton/Request.java
import android.net.TrafficStats;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.hanuor.pearl.volleysingleton.VolleyLog.MarkerLog;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.Map;
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hanuor.pearl.volleysingleton;
/**
* Base class for all network requests.
*
* @param <T> The type of parsed response this request expects.
*/
public abstract class Request<T> implements Comparable<Request<T>> {
/**
* Default encoding for POST or PUT parameters. See {@link #getParamsEncoding()}.
*/
private static final String DEFAULT_PARAMS_ENCODING = "UTF-8";
/**
* Supported request methods.
*/
public interface Method {
int DEPRECATED_GET_OR_POST = -1;
int GET = 0;
int POST = 1;
int PUT = 2;
int DELETE = 3;
int HEAD = 4;
int OPTIONS = 5;
int TRACE = 6;
int PATCH = 7;
}
/** An event log tracing the lifetime of this request; for debugging. */ | private final MarkerLog mEventLog = MarkerLog.ENABLED ? new MarkerLog() : null; |
hanuor/pearl | app/src/main/java/com/hanuor/pearl_demonstration/ClassicAdapter.java | // Path: pearl/src/main/java/com/hanuor/pearl/Pearl.java
// public class Pearl{
// private static Context ctx;
// private static int defaultImg = 0;
// private static ImageLoader imageLoader;
//
// public static void saveJsonObject(Context context, String jsonObject,String tag) {
// FileOutputStream fos = null;
// try {
// fos = context.openFileOutput(tag, Context.MODE_PRIVATE);
//
// ObjectOutputStream oos = new ObjectOutputStream(fos);
// oos.writeObject(jsonObject);
// oos.flush();
// oos.close();
//
// fos.close();
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// public static Object retrieveJsonObject(String tag){
//
// try {
// FileInputStream fis = ctx.openFileInput(tag);
// ObjectInputStream ois = new ObjectInputStream(fis);
// Object object = ois.readObject();
// fis.close();
// return object;
// } catch (IOException e) {
// e.printStackTrace();
// return null;
// } catch (ClassNotFoundException e) {
// e.printStackTrace();
// return null;
// }
//
// }
// public static void imageLoader(Context context, String URL, ImageView target, int defaultImage) {
// ctx = context;
// defaultImg = defaultImage;
// VolleyHelper.init(context);
// imageLoader = VolleyHelper.getImageLoader();
// Resources r = context.getResources();
// Boolean fileFound = true;
// Drawable d = null;
// try{
// d = r.getDrawable(defaultImage);
// }
// catch(Exception e){
// fileFound = false;
// }
// if(fileFound){
// imageLoader.get(URL,ImageLoader.getImageListener(target, defaultImage, defaultImage));
// }else{
// imageLoader.get(URL,ImageLoader.getImageListener(target, R.drawable.more,R.drawable.more));
// }
// }
// public static void cancelImageLoad(String urlofImage){
// imageLoader.cancelRequestfromQueue(urlofImage);
// }
//
//
// }
| import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import com.hanuor.pearl.Pearl;
import java.util.ArrayList; | }
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View grid;
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
grid = new View(mContext);
grid = inflater.inflate(R.layout.single, null);
ImageView thumb= (ImageView)grid.findViewById(R.id.grid_image);
Log.d("ferrrari","HEY");
thumb.setTag(position);
Log.d("fferhh",thumb.getTag()+"");
Log.d("fffffff",""+position);
if(position == (getCount()-1)){
Log.d("Weate","We are here");
} | // Path: pearl/src/main/java/com/hanuor/pearl/Pearl.java
// public class Pearl{
// private static Context ctx;
// private static int defaultImg = 0;
// private static ImageLoader imageLoader;
//
// public static void saveJsonObject(Context context, String jsonObject,String tag) {
// FileOutputStream fos = null;
// try {
// fos = context.openFileOutput(tag, Context.MODE_PRIVATE);
//
// ObjectOutputStream oos = new ObjectOutputStream(fos);
// oos.writeObject(jsonObject);
// oos.flush();
// oos.close();
//
// fos.close();
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// public static Object retrieveJsonObject(String tag){
//
// try {
// FileInputStream fis = ctx.openFileInput(tag);
// ObjectInputStream ois = new ObjectInputStream(fis);
// Object object = ois.readObject();
// fis.close();
// return object;
// } catch (IOException e) {
// e.printStackTrace();
// return null;
// } catch (ClassNotFoundException e) {
// e.printStackTrace();
// return null;
// }
//
// }
// public static void imageLoader(Context context, String URL, ImageView target, int defaultImage) {
// ctx = context;
// defaultImg = defaultImage;
// VolleyHelper.init(context);
// imageLoader = VolleyHelper.getImageLoader();
// Resources r = context.getResources();
// Boolean fileFound = true;
// Drawable d = null;
// try{
// d = r.getDrawable(defaultImage);
// }
// catch(Exception e){
// fileFound = false;
// }
// if(fileFound){
// imageLoader.get(URL,ImageLoader.getImageListener(target, defaultImage, defaultImage));
// }else{
// imageLoader.get(URL,ImageLoader.getImageListener(target, R.drawable.more,R.drawable.more));
// }
// }
// public static void cancelImageLoad(String urlofImage){
// imageLoader.cancelRequestfromQueue(urlofImage);
// }
//
//
// }
// Path: app/src/main/java/com/hanuor/pearl_demonstration/ClassicAdapter.java
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import com.hanuor.pearl.Pearl;
import java.util.ArrayList;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View grid;
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
grid = new View(mContext);
grid = inflater.inflate(R.layout.single, null);
ImageView thumb= (ImageView)grid.findViewById(R.id.grid_image);
Log.d("ferrrari","HEY");
thumb.setTag(position);
Log.d("fferhh",thumb.getTag()+"");
Log.d("fffffff",""+position);
if(position == (getCount()-1)){
Log.d("Weate","We are here");
} | Pearl.imageLoader(mContext,Imageid.get(position),thumb,R.drawable.more); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.