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 |
|---|---|---|---|---|---|---|
yenrab/doing_more_with_java | JSONEchoServlet.java | // Path: ApplicationController.java
// public class ApplicationController {
// private HashMap<String,Handler> handlerMap = new HashMap();
//
// public void handleRequest(String command, HashMap<String,Object> data){
// Handler aCommandHandler = handlerMap.get(command);
// if (aCommandHandler != null){
// aCommandHandler.handleIt(data);
// }
// }
//
// public void mapCommand(String aCommand, Handler acHandler){
// handlerMap.put(aCommand,acHandler);
// }
// }
//
// Path: Handler.java
// public interface Handler {
// public void handleIt(HashMap<String, Object> data);
// }
| import com.doing.more.java.appcontrol.ApplicationController;
import com.doing.more.java.appcontrol.Handler;
import ort.quickconnectfamily.json.JSONInputStream;
import ort.quickconnectfamily.json.JSONOutputStream;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap; | package com.doing.more.java;
@WebServlet(name = "JSONEchoService", urlPatterns = {"/json"})
public class JSONEchoServlet extends HttpServlet { | // Path: ApplicationController.java
// public class ApplicationController {
// private HashMap<String,Handler> handlerMap = new HashMap();
//
// public void handleRequest(String command, HashMap<String,Object> data){
// Handler aCommandHandler = handlerMap.get(command);
// if (aCommandHandler != null){
// aCommandHandler.handleIt(data);
// }
// }
//
// public void mapCommand(String aCommand, Handler acHandler){
// handlerMap.put(aCommand,acHandler);
// }
// }
//
// Path: Handler.java
// public interface Handler {
// public void handleIt(HashMap<String, Object> data);
// }
// Path: JSONEchoServlet.java
import com.doing.more.java.appcontrol.ApplicationController;
import com.doing.more.java.appcontrol.Handler;
import ort.quickconnectfamily.json.JSONInputStream;
import ort.quickconnectfamily.json.JSONOutputStream;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
package com.doing.more.java;
@WebServlet(name = "JSONEchoService", urlPatterns = {"/json"})
public class JSONEchoServlet extends HttpServlet { | private ApplicationController theAppController = new ApplicationController(); |
angelozerr/typescript.java | core/ts.core/src/ts/utils/ZipUtils.java | // Path: core/ts.core/src/ts/internal/io/tar/TarEntry.java
// public class TarEntry implements Cloneable
// {
// private String name;
// private long mode, time, size;
// private int type;
// int filepos;
// private String linkName;
//
// /**
// * Entry type for normal files.
// */
// public static final int FILE = '0';
//
// /**
// * Entry type for directories.
// */
// public static final int DIRECTORY = '5';
//
// /**
// * Entry type for links.
// */
// public static final int LINK = '1';
//
// /**
// * Entry type for symbolic link.
// */
// public static final int SYM_LINK = '2';
//
// /**
// * Create a new TarEntry for a file of the given name at the
// * given position in the file.
// *
// * @param name filename
// * @param pos position in the file in bytes
// */
// TarEntry(String name, int pos) {
// this.name = name;
// mode = 0644;
// type = FILE;
// filepos = pos;
// time = System.currentTimeMillis() / 1000;
// }
//
// /**
// * Create a new TarEntry for a file of the given name.
// *
// * @param name filename
// */
// public TarEntry(String name) {
// this(name, -1);
// }
//
// /**
// * Returns the type of this file, one of FILE, LINK, SYM_LINK,
// * CHAR_DEVICE, BLOCK_DEVICE, DIRECTORY or FIFO.
// *
// * @return file type
// */
// public int getFileType() {
// return type;
// }
//
// /**
// * Returns the mode of the file in UNIX permissions format.
// *
// * @return file mode
// */
// public long getMode() {
// return mode;
// }
//
// /**
// * Returns the name of the file.
// *
// * @return filename
// */
// public String getName() {
// return name;
// }
//
// /**
// * Returns the size of the file in bytes.
// *
// * @return filesize
// */
// public long getSize() {
// return size;
// }
//
// /**
// * Returns the modification time of the file in seconds since January
// * 1st 1970.
// *
// * @return time
// */
// public long getTime() {
// return time;
// }
//
// /**
// * Sets the type of the file, one of FILE, LINK, SYMLINK, CHAR_DEVICE,
// * BLOCK_DEVICE, or DIRECTORY.
// *
// * @param type
// */
// public void setFileType(int type) {
// this.type = type;
// }
//
// /**
// * Sets the mode of the file in UNIX permissions format.
// *
// * @param mode
// */
// public void setMode(long mode) {
// this.mode = mode;
// }
//
// /**
// * Sets the size of the file in bytes.
// *
// * @param size
// */
// public void setSize(long size) {
// this.size = size;
// }
//
// /**
// * Sets the modification time of the file in seconds since January
// * 1st 1970.
// *
// * @param time
// */
// public void setTime(long time) {
// this.time = time;
// }
//
// public boolean isDirectory() {
// return type == DIRECTORY;
// }
//
// public boolean isLink() {
// return type == LINK;
// }
//
// public boolean isSymbolicLink() {
// return type == SYM_LINK;
// }
//
// public String getLinkName() {
// return linkName;
// }
//
// public void setLinkName(String linkName) {
// this.linkName = linkName;
// }
// }
| import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.zip.GZIPInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.tukaani.xz.XZInputStream;
import ts.internal.io.tar.TarEntry;
import ts.internal.io.tar.TarException;
import ts.internal.io.tar.TarInputStream; |
/**
* Extract tar.xz file to destination folder.
*
* @param file
* zip file to extract
* @param destination
* destination folder
*/
public static void extractTarXZ(File file, File destination) throws IOException {
extractTar(file, destination, false);
}
/**
* Extract tar.gz/tar.xz file to destination folder.
*
* @param file
* zip file to extract
* @param destination
* destination folder
*/
private static void extractTar(File file, File destination, boolean tarGz) throws IOException {
TarInputStream in = null;
OutputStream out = null;
try {
// Open the ZIP file
in = new TarInputStream(tarGz ? new GZIPInputStream(new FileInputStream(file))
: new XZInputStream(new FileInputStream(file)));
// Get the first entry | // Path: core/ts.core/src/ts/internal/io/tar/TarEntry.java
// public class TarEntry implements Cloneable
// {
// private String name;
// private long mode, time, size;
// private int type;
// int filepos;
// private String linkName;
//
// /**
// * Entry type for normal files.
// */
// public static final int FILE = '0';
//
// /**
// * Entry type for directories.
// */
// public static final int DIRECTORY = '5';
//
// /**
// * Entry type for links.
// */
// public static final int LINK = '1';
//
// /**
// * Entry type for symbolic link.
// */
// public static final int SYM_LINK = '2';
//
// /**
// * Create a new TarEntry for a file of the given name at the
// * given position in the file.
// *
// * @param name filename
// * @param pos position in the file in bytes
// */
// TarEntry(String name, int pos) {
// this.name = name;
// mode = 0644;
// type = FILE;
// filepos = pos;
// time = System.currentTimeMillis() / 1000;
// }
//
// /**
// * Create a new TarEntry for a file of the given name.
// *
// * @param name filename
// */
// public TarEntry(String name) {
// this(name, -1);
// }
//
// /**
// * Returns the type of this file, one of FILE, LINK, SYM_LINK,
// * CHAR_DEVICE, BLOCK_DEVICE, DIRECTORY or FIFO.
// *
// * @return file type
// */
// public int getFileType() {
// return type;
// }
//
// /**
// * Returns the mode of the file in UNIX permissions format.
// *
// * @return file mode
// */
// public long getMode() {
// return mode;
// }
//
// /**
// * Returns the name of the file.
// *
// * @return filename
// */
// public String getName() {
// return name;
// }
//
// /**
// * Returns the size of the file in bytes.
// *
// * @return filesize
// */
// public long getSize() {
// return size;
// }
//
// /**
// * Returns the modification time of the file in seconds since January
// * 1st 1970.
// *
// * @return time
// */
// public long getTime() {
// return time;
// }
//
// /**
// * Sets the type of the file, one of FILE, LINK, SYMLINK, CHAR_DEVICE,
// * BLOCK_DEVICE, or DIRECTORY.
// *
// * @param type
// */
// public void setFileType(int type) {
// this.type = type;
// }
//
// /**
// * Sets the mode of the file in UNIX permissions format.
// *
// * @param mode
// */
// public void setMode(long mode) {
// this.mode = mode;
// }
//
// /**
// * Sets the size of the file in bytes.
// *
// * @param size
// */
// public void setSize(long size) {
// this.size = size;
// }
//
// /**
// * Sets the modification time of the file in seconds since January
// * 1st 1970.
// *
// * @param time
// */
// public void setTime(long time) {
// this.time = time;
// }
//
// public boolean isDirectory() {
// return type == DIRECTORY;
// }
//
// public boolean isLink() {
// return type == LINK;
// }
//
// public boolean isSymbolicLink() {
// return type == SYM_LINK;
// }
//
// public String getLinkName() {
// return linkName;
// }
//
// public void setLinkName(String linkName) {
// this.linkName = linkName;
// }
// }
// Path: core/ts.core/src/ts/utils/ZipUtils.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.zip.GZIPInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.tukaani.xz.XZInputStream;
import ts.internal.io.tar.TarEntry;
import ts.internal.io.tar.TarException;
import ts.internal.io.tar.TarInputStream;
/**
* Extract tar.xz file to destination folder.
*
* @param file
* zip file to extract
* @param destination
* destination folder
*/
public static void extractTarXZ(File file, File destination) throws IOException {
extractTar(file, destination, false);
}
/**
* Extract tar.gz/tar.xz file to destination folder.
*
* @param file
* zip file to extract
* @param destination
* destination folder
*/
private static void extractTar(File file, File destination, boolean tarGz) throws IOException {
TarInputStream in = null;
OutputStream out = null;
try {
// Open the ZIP file
in = new TarInputStream(tarGz ? new GZIPInputStream(new FileInputStream(file))
: new XZInputStream(new FileInputStream(file)));
// Get the first entry | TarEntry entry = null; |
angelozerr/typescript.java | core/ts.core/src/ts/internal/client/protocol/NavTreeRequest.java | // Path: core/ts.core/src/ts/client/CommandNames.java
// public enum CommandNames implements ISupportable {
//
// Open("open"),
// Close("close"),
// Change("change"),
// NavBar("navbar"),
// Completions("completions"),
// CompletionEntryDetails("completionEntryDetails"),
// Reload("reload"),
// Definition("definition"),
// SignatureHelp("signatureHelp"),
// QuickInfo("quickinfo"),
// Geterr("geterr"),
// GeterrForProject("geterrForProject"),
// Format("format"),
// References("references"),
// Occurrences("occurrences"),
// Configure("configure"),
// ProjectInfo("projectInfo"),
// Rename("rename"),
// NavTo("navto"),
//
// // 2.0.0
// SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),
// SyntacticDiagnosticsSync("syntacticDiagnosticsSync", "2.0.0"),
//
// // 2.0.5
// CompileOnSaveAffectedFileList("compileOnSaveAffectedFileList", "2.0.5"),
// CompileOnSaveEmitFile("compileOnSaveEmitFile", "2.0.5"),
//
// // 2.0.6
// NavTree("navtree", "2.0.6"),
// DocCommentTemplate("docCommentTemplate", "2.0.6"),
//
// // 2.1.0
// Implementation("implementation", "2.1.0"),
// GetSupportedCodeFixes("getSupportedCodeFixes", "2.1.0"),
// GetCodeFixes("getCodeFixes", "2.1.0"),
//
// // 2.4.0
// GetApplicableRefactors("getApplicableRefactors", "2.4.0"),
// GetEditsForRefactor("getEditsForRefactor", "2.4.0"),
//
// OpenExternalProject("openExternalProject");
//
// private final String name;
// private final String sinceVersion;
//
// private CommandNames(String name) {
// this(name, null);
// }
//
// private CommandNames(String name, String sinceVersion) {
// this.name = name;
// this.sinceVersion = sinceVersion;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Return true if the tsserver command support the given version and false
// * otherwise.
// *
// * @param version
// * @return true if the tsserver command support the given version and false
// * otherwise.
// */
// public boolean canSupport(String version) {
// return VersionHelper.canSupport(version, sinceVersion);
// }
//
// }
| import java.lang.reflect.Type;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.InstanceCreator;
import com.google.gson.JsonObject;
import ts.client.CommandNames;
import ts.client.IPositionProvider;
import ts.client.Location;
import ts.client.navbar.NavigationBarItem;
| /**
* Copyright (c) 2015-2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package ts.internal.client.protocol;
/**
* NavTree request; value of command field is "navtree". Return response giving
* the navigation tree of the requested file.
*
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*/
public class NavTreeRequest extends FileRequest<FileRequestArgs> {
// Set positionProvider to transient to ignore Gson serialization
private final transient IPositionProvider positionProvider;
public NavTreeRequest(String fileName, IPositionProvider positionProvider) {
| // Path: core/ts.core/src/ts/client/CommandNames.java
// public enum CommandNames implements ISupportable {
//
// Open("open"),
// Close("close"),
// Change("change"),
// NavBar("navbar"),
// Completions("completions"),
// CompletionEntryDetails("completionEntryDetails"),
// Reload("reload"),
// Definition("definition"),
// SignatureHelp("signatureHelp"),
// QuickInfo("quickinfo"),
// Geterr("geterr"),
// GeterrForProject("geterrForProject"),
// Format("format"),
// References("references"),
// Occurrences("occurrences"),
// Configure("configure"),
// ProjectInfo("projectInfo"),
// Rename("rename"),
// NavTo("navto"),
//
// // 2.0.0
// SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),
// SyntacticDiagnosticsSync("syntacticDiagnosticsSync", "2.0.0"),
//
// // 2.0.5
// CompileOnSaveAffectedFileList("compileOnSaveAffectedFileList", "2.0.5"),
// CompileOnSaveEmitFile("compileOnSaveEmitFile", "2.0.5"),
//
// // 2.0.6
// NavTree("navtree", "2.0.6"),
// DocCommentTemplate("docCommentTemplate", "2.0.6"),
//
// // 2.1.0
// Implementation("implementation", "2.1.0"),
// GetSupportedCodeFixes("getSupportedCodeFixes", "2.1.0"),
// GetCodeFixes("getCodeFixes", "2.1.0"),
//
// // 2.4.0
// GetApplicableRefactors("getApplicableRefactors", "2.4.0"),
// GetEditsForRefactor("getEditsForRefactor", "2.4.0"),
//
// OpenExternalProject("openExternalProject");
//
// private final String name;
// private final String sinceVersion;
//
// private CommandNames(String name) {
// this(name, null);
// }
//
// private CommandNames(String name, String sinceVersion) {
// this.name = name;
// this.sinceVersion = sinceVersion;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Return true if the tsserver command support the given version and false
// * otherwise.
// *
// * @param version
// * @return true if the tsserver command support the given version and false
// * otherwise.
// */
// public boolean canSupport(String version) {
// return VersionHelper.canSupport(version, sinceVersion);
// }
//
// }
// Path: core/ts.core/src/ts/internal/client/protocol/NavTreeRequest.java
import java.lang.reflect.Type;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.InstanceCreator;
import com.google.gson.JsonObject;
import ts.client.CommandNames;
import ts.client.IPositionProvider;
import ts.client.Location;
import ts.client.navbar.NavigationBarItem;
/**
* Copyright (c) 2015-2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package ts.internal.client.protocol;
/**
* NavTree request; value of command field is "navtree". Return response giving
* the navigation tree of the requested file.
*
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*/
public class NavTreeRequest extends FileRequest<FileRequestArgs> {
// Set positionProvider to transient to ignore Gson serialization
private final transient IPositionProvider positionProvider;
public NavTreeRequest(String fileName, IPositionProvider positionProvider) {
| super(CommandNames.NavTree.getName(), new FileRequestArgs(fileName, null));
|
angelozerr/typescript.java | core/ts.core/src/ts/internal/client/protocol/OpenExternalProjectRequestArgs.java | // Path: core/ts.core/src/ts/client/ScriptKindName.java
// public enum ScriptKindName {
//
// TS ,JS ,TSX ,JSX
// }
| import java.util.List;
import ts.client.ScriptKindName;
import ts.cmd.tsc.CompilerOptions; | package ts.internal.client.protocol;
/**
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*/
public class OpenExternalProjectRequestArgs {
public static class ExternalFile {
/**
* Name of file file
*/
String fileName;
/**
* Script kind of the file
*/ | // Path: core/ts.core/src/ts/client/ScriptKindName.java
// public enum ScriptKindName {
//
// TS ,JS ,TSX ,JSX
// }
// Path: core/ts.core/src/ts/internal/client/protocol/OpenExternalProjectRequestArgs.java
import java.util.List;
import ts.client.ScriptKindName;
import ts.cmd.tsc.CompilerOptions;
package ts.internal.client.protocol;
/**
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*/
public class OpenExternalProjectRequestArgs {
public static class ExternalFile {
/**
* Name of file file
*/
String fileName;
/**
* Script kind of the file
*/ | ScriptKindName scriptKind; |
angelozerr/typescript.java | core/ts.core/src/ts/internal/client/protocol/ConfigureRequest.java | // Path: core/ts.core/src/ts/client/CommandNames.java
// public enum CommandNames implements ISupportable {
//
// Open("open"),
// Close("close"),
// Change("change"),
// NavBar("navbar"),
// Completions("completions"),
// CompletionEntryDetails("completionEntryDetails"),
// Reload("reload"),
// Definition("definition"),
// SignatureHelp("signatureHelp"),
// QuickInfo("quickinfo"),
// Geterr("geterr"),
// GeterrForProject("geterrForProject"),
// Format("format"),
// References("references"),
// Occurrences("occurrences"),
// Configure("configure"),
// ProjectInfo("projectInfo"),
// Rename("rename"),
// NavTo("navto"),
//
// // 2.0.0
// SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),
// SyntacticDiagnosticsSync("syntacticDiagnosticsSync", "2.0.0"),
//
// // 2.0.5
// CompileOnSaveAffectedFileList("compileOnSaveAffectedFileList", "2.0.5"),
// CompileOnSaveEmitFile("compileOnSaveEmitFile", "2.0.5"),
//
// // 2.0.6
// NavTree("navtree", "2.0.6"),
// DocCommentTemplate("docCommentTemplate", "2.0.6"),
//
// // 2.1.0
// Implementation("implementation", "2.1.0"),
// GetSupportedCodeFixes("getSupportedCodeFixes", "2.1.0"),
// GetCodeFixes("getCodeFixes", "2.1.0"),
//
// // 2.4.0
// GetApplicableRefactors("getApplicableRefactors", "2.4.0"),
// GetEditsForRefactor("getEditsForRefactor", "2.4.0"),
//
// OpenExternalProject("openExternalProject");
//
// private final String name;
// private final String sinceVersion;
//
// private CommandNames(String name) {
// this(name, null);
// }
//
// private CommandNames(String name, String sinceVersion) {
// this.name = name;
// this.sinceVersion = sinceVersion;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Return true if the tsserver command support the given version and false
// * otherwise.
// *
// * @param version
// * @return true if the tsserver command support the given version and false
// * otherwise.
// */
// public boolean canSupport(String version) {
// return VersionHelper.canSupport(version, sinceVersion);
// }
//
// }
| import com.google.gson.JsonObject;
import ts.client.CommandNames;
import ts.client.configure.ConfigureRequestArguments;
| /**
* Copyright (c) 2015-2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package ts.internal.client.protocol;
/**
* Configure request; value of command field is "configure". Specifies host
* information, such as host type, tab size, and indent size.
*
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*/
public class ConfigureRequest extends Request<ConfigureRequestArguments> {
public ConfigureRequest(ConfigureRequestArguments arguments) {
| // Path: core/ts.core/src/ts/client/CommandNames.java
// public enum CommandNames implements ISupportable {
//
// Open("open"),
// Close("close"),
// Change("change"),
// NavBar("navbar"),
// Completions("completions"),
// CompletionEntryDetails("completionEntryDetails"),
// Reload("reload"),
// Definition("definition"),
// SignatureHelp("signatureHelp"),
// QuickInfo("quickinfo"),
// Geterr("geterr"),
// GeterrForProject("geterrForProject"),
// Format("format"),
// References("references"),
// Occurrences("occurrences"),
// Configure("configure"),
// ProjectInfo("projectInfo"),
// Rename("rename"),
// NavTo("navto"),
//
// // 2.0.0
// SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),
// SyntacticDiagnosticsSync("syntacticDiagnosticsSync", "2.0.0"),
//
// // 2.0.5
// CompileOnSaveAffectedFileList("compileOnSaveAffectedFileList", "2.0.5"),
// CompileOnSaveEmitFile("compileOnSaveEmitFile", "2.0.5"),
//
// // 2.0.6
// NavTree("navtree", "2.0.6"),
// DocCommentTemplate("docCommentTemplate", "2.0.6"),
//
// // 2.1.0
// Implementation("implementation", "2.1.0"),
// GetSupportedCodeFixes("getSupportedCodeFixes", "2.1.0"),
// GetCodeFixes("getCodeFixes", "2.1.0"),
//
// // 2.4.0
// GetApplicableRefactors("getApplicableRefactors", "2.4.0"),
// GetEditsForRefactor("getEditsForRefactor", "2.4.0"),
//
// OpenExternalProject("openExternalProject");
//
// private final String name;
// private final String sinceVersion;
//
// private CommandNames(String name) {
// this(name, null);
// }
//
// private CommandNames(String name, String sinceVersion) {
// this.name = name;
// this.sinceVersion = sinceVersion;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Return true if the tsserver command support the given version and false
// * otherwise.
// *
// * @param version
// * @return true if the tsserver command support the given version and false
// * otherwise.
// */
// public boolean canSupport(String version) {
// return VersionHelper.canSupport(version, sinceVersion);
// }
//
// }
// Path: core/ts.core/src/ts/internal/client/protocol/ConfigureRequest.java
import com.google.gson.JsonObject;
import ts.client.CommandNames;
import ts.client.configure.ConfigureRequestArguments;
/**
* Copyright (c) 2015-2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package ts.internal.client.protocol;
/**
* Configure request; value of command field is "configure". Specifies host
* information, such as host type, tab size, and indent size.
*
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*/
public class ConfigureRequest extends Request<ConfigureRequestArguments> {
public ConfigureRequest(ConfigureRequestArguments arguments) {
| super(CommandNames.Configure.getName(), arguments);
|
angelozerr/typescript.java | eclipse/ts.eclipse/src/ts/eclipse/jface/images/TypeScriptImagesRegistry.java | // Path: core/ts.core/src/ts/ScriptElementKind.java
// public enum ScriptElementKind {
//
// ALIAS, PRIMITIVE_TYPE, KEYWORD, CLASS, INTERFACE, MODULE, SCRIPT, DIRECTORY, PROPERTY, METHOD, CONSTRUCTOR, FUNCTION, VAR, LET, ENUM, TYPE, ELEMENT, ATTRIBUTE, COMPONENT, CONST, GETTER, SETTER, WARNING;
//
// public static ScriptElementKind getKind(String kind) {
// try {
// return ScriptElementKind.valueOf(kind.toUpperCase());
// } catch (Exception e) {
// return ScriptElementKind.WARNING;
// }
// }
// }
| import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Image;
import ts.ScriptElementKind;
import ts.ScriptElementKindModifier;
import ts.client.IKindProvider;
import ts.utils.StringUtils;
| return imageRegistry.getDescriptor(key);
}
private static void registerImageDescriptor(String key, ImageDescriptor descriptor) {
ImageRegistry imageRegistry = JFaceResources.getImageRegistry();
imageRegistry.put(key, descriptor);
}
public static Image getImage(IKindProvider entry) {
return getTypeScriptImage(entry.getKind(), entry.getKindModifiers(), null);
}
public static Image getTypeScriptImage(String kind, String kindModifiers, String containerKind) {
String imageKey = getImageKey(kind, kindModifiers, containerKind);
if (imageKey != null) {
return getImage(imageKey);
}
return null;
}
public static ImageDescriptor getTypeScriptImageDescriptor(String kind, String kindModifiers,
String containerKind) {
String imageKey = getImageKey(kind, kindModifiers, containerKind);
if (imageKey != null) {
return getImageDescriptor(imageKey);
}
return null;
}
private static String getImageKey(String kind, String kindModifiers, String containerKind) {
| // Path: core/ts.core/src/ts/ScriptElementKind.java
// public enum ScriptElementKind {
//
// ALIAS, PRIMITIVE_TYPE, KEYWORD, CLASS, INTERFACE, MODULE, SCRIPT, DIRECTORY, PROPERTY, METHOD, CONSTRUCTOR, FUNCTION, VAR, LET, ENUM, TYPE, ELEMENT, ATTRIBUTE, COMPONENT, CONST, GETTER, SETTER, WARNING;
//
// public static ScriptElementKind getKind(String kind) {
// try {
// return ScriptElementKind.valueOf(kind.toUpperCase());
// } catch (Exception e) {
// return ScriptElementKind.WARNING;
// }
// }
// }
// Path: eclipse/ts.eclipse/src/ts/eclipse/jface/images/TypeScriptImagesRegistry.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Image;
import ts.ScriptElementKind;
import ts.ScriptElementKindModifier;
import ts.client.IKindProvider;
import ts.utils.StringUtils;
return imageRegistry.getDescriptor(key);
}
private static void registerImageDescriptor(String key, ImageDescriptor descriptor) {
ImageRegistry imageRegistry = JFaceResources.getImageRegistry();
imageRegistry.put(key, descriptor);
}
public static Image getImage(IKindProvider entry) {
return getTypeScriptImage(entry.getKind(), entry.getKindModifiers(), null);
}
public static Image getTypeScriptImage(String kind, String kindModifiers, String containerKind) {
String imageKey = getImageKey(kind, kindModifiers, containerKind);
if (imageKey != null) {
return getImage(imageKey);
}
return null;
}
public static ImageDescriptor getTypeScriptImageDescriptor(String kind, String kindModifiers,
String containerKind) {
String imageKey = getImageKey(kind, kindModifiers, containerKind);
if (imageKey != null) {
return getImageDescriptor(imageKey);
}
return null;
}
private static String getImageKey(String kind, String kindModifiers, String containerKind) {
| ScriptElementKind tsKind = ScriptElementKind.getKind(kind);
|
angelozerr/typescript.java | core/ts.core/src/ts/internal/client/protocol/GeterrRequest.java | // Path: core/ts.core/src/ts/client/CommandNames.java
// public enum CommandNames implements ISupportable {
//
// Open("open"),
// Close("close"),
// Change("change"),
// NavBar("navbar"),
// Completions("completions"),
// CompletionEntryDetails("completionEntryDetails"),
// Reload("reload"),
// Definition("definition"),
// SignatureHelp("signatureHelp"),
// QuickInfo("quickinfo"),
// Geterr("geterr"),
// GeterrForProject("geterrForProject"),
// Format("format"),
// References("references"),
// Occurrences("occurrences"),
// Configure("configure"),
// ProjectInfo("projectInfo"),
// Rename("rename"),
// NavTo("navto"),
//
// // 2.0.0
// SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),
// SyntacticDiagnosticsSync("syntacticDiagnosticsSync", "2.0.0"),
//
// // 2.0.5
// CompileOnSaveAffectedFileList("compileOnSaveAffectedFileList", "2.0.5"),
// CompileOnSaveEmitFile("compileOnSaveEmitFile", "2.0.5"),
//
// // 2.0.6
// NavTree("navtree", "2.0.6"),
// DocCommentTemplate("docCommentTemplate", "2.0.6"),
//
// // 2.1.0
// Implementation("implementation", "2.1.0"),
// GetSupportedCodeFixes("getSupportedCodeFixes", "2.1.0"),
// GetCodeFixes("getCodeFixes", "2.1.0"),
//
// // 2.4.0
// GetApplicableRefactors("getApplicableRefactors", "2.4.0"),
// GetEditsForRefactor("getEditsForRefactor", "2.4.0"),
//
// OpenExternalProject("openExternalProject");
//
// private final String name;
// private final String sinceVersion;
//
// private CommandNames(String name) {
// this(name, null);
// }
//
// private CommandNames(String name, String sinceVersion) {
// this.name = name;
// this.sinceVersion = sinceVersion;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Return true if the tsserver command support the given version and false
// * otherwise.
// *
// * @param version
// * @return true if the tsserver command support the given version and false
// * otherwise.
// */
// public boolean canSupport(String version) {
// return VersionHelper.canSupport(version, sinceVersion);
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.google.gson.JsonObject;
import ts.client.CommandNames;
import ts.client.diagnostics.DiagnosticEvent;
| /**
* Copyright (c) 2015-2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package ts.internal.client.protocol;
/**
* Geterr request; value of command field is "geterr". Wait for delay
* milliseconds and then, if during the wait no change or reload messages have
* arrived for the first file in the files list, get the syntactic errors for
* the file, field requests, and then get the semantic errors for the file.
* Repeat with a smaller delay for each subsequent file on the files list. Best
* practice for an editor is to send a file list containing each file that is
* currently visible, in most-recently-used order.
*
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*/
public class GeterrRequest extends Request<GeterrRequestArgs> implements IRequestEventable<DiagnosticEvent> {
private final transient List<DiagnosticEvent> events;
public GeterrRequest(String[] files, int delay) {
| // Path: core/ts.core/src/ts/client/CommandNames.java
// public enum CommandNames implements ISupportable {
//
// Open("open"),
// Close("close"),
// Change("change"),
// NavBar("navbar"),
// Completions("completions"),
// CompletionEntryDetails("completionEntryDetails"),
// Reload("reload"),
// Definition("definition"),
// SignatureHelp("signatureHelp"),
// QuickInfo("quickinfo"),
// Geterr("geterr"),
// GeterrForProject("geterrForProject"),
// Format("format"),
// References("references"),
// Occurrences("occurrences"),
// Configure("configure"),
// ProjectInfo("projectInfo"),
// Rename("rename"),
// NavTo("navto"),
//
// // 2.0.0
// SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),
// SyntacticDiagnosticsSync("syntacticDiagnosticsSync", "2.0.0"),
//
// // 2.0.5
// CompileOnSaveAffectedFileList("compileOnSaveAffectedFileList", "2.0.5"),
// CompileOnSaveEmitFile("compileOnSaveEmitFile", "2.0.5"),
//
// // 2.0.6
// NavTree("navtree", "2.0.6"),
// DocCommentTemplate("docCommentTemplate", "2.0.6"),
//
// // 2.1.0
// Implementation("implementation", "2.1.0"),
// GetSupportedCodeFixes("getSupportedCodeFixes", "2.1.0"),
// GetCodeFixes("getCodeFixes", "2.1.0"),
//
// // 2.4.0
// GetApplicableRefactors("getApplicableRefactors", "2.4.0"),
// GetEditsForRefactor("getEditsForRefactor", "2.4.0"),
//
// OpenExternalProject("openExternalProject");
//
// private final String name;
// private final String sinceVersion;
//
// private CommandNames(String name) {
// this(name, null);
// }
//
// private CommandNames(String name, String sinceVersion) {
// this.name = name;
// this.sinceVersion = sinceVersion;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Return true if the tsserver command support the given version and false
// * otherwise.
// *
// * @param version
// * @return true if the tsserver command support the given version and false
// * otherwise.
// */
// public boolean canSupport(String version) {
// return VersionHelper.canSupport(version, sinceVersion);
// }
//
// }
// Path: core/ts.core/src/ts/internal/client/protocol/GeterrRequest.java
import java.util.ArrayList;
import java.util.List;
import com.google.gson.JsonObject;
import ts.client.CommandNames;
import ts.client.diagnostics.DiagnosticEvent;
/**
* Copyright (c) 2015-2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package ts.internal.client.protocol;
/**
* Geterr request; value of command field is "geterr". Wait for delay
* milliseconds and then, if during the wait no change or reload messages have
* arrived for the first file in the files list, get the syntactic errors for
* the file, field requests, and then get the semantic errors for the file.
* Repeat with a smaller delay for each subsequent file on the files list. Best
* practice for an editor is to send a file list containing each file that is
* currently visible, in most-recently-used order.
*
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*/
public class GeterrRequest extends Request<GeterrRequestArgs> implements IRequestEventable<DiagnosticEvent> {
private final transient List<DiagnosticEvent> events;
public GeterrRequest(String[] files, int delay) {
| super(CommandNames.Geterr.getName(), new GeterrRequestArgs(files, delay));
|
angelozerr/typescript.java | core/ts.core/src/ts/internal/client/protocol/OpenExternalProjectRequest.java | // Path: core/ts.core/src/ts/client/CommandNames.java
// public enum CommandNames implements ISupportable {
//
// Open("open"),
// Close("close"),
// Change("change"),
// NavBar("navbar"),
// Completions("completions"),
// CompletionEntryDetails("completionEntryDetails"),
// Reload("reload"),
// Definition("definition"),
// SignatureHelp("signatureHelp"),
// QuickInfo("quickinfo"),
// Geterr("geterr"),
// GeterrForProject("geterrForProject"),
// Format("format"),
// References("references"),
// Occurrences("occurrences"),
// Configure("configure"),
// ProjectInfo("projectInfo"),
// Rename("rename"),
// NavTo("navto"),
//
// // 2.0.0
// SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),
// SyntacticDiagnosticsSync("syntacticDiagnosticsSync", "2.0.0"),
//
// // 2.0.5
// CompileOnSaveAffectedFileList("compileOnSaveAffectedFileList", "2.0.5"),
// CompileOnSaveEmitFile("compileOnSaveEmitFile", "2.0.5"),
//
// // 2.0.6
// NavTree("navtree", "2.0.6"),
// DocCommentTemplate("docCommentTemplate", "2.0.6"),
//
// // 2.1.0
// Implementation("implementation", "2.1.0"),
// GetSupportedCodeFixes("getSupportedCodeFixes", "2.1.0"),
// GetCodeFixes("getCodeFixes", "2.1.0"),
//
// // 2.4.0
// GetApplicableRefactors("getApplicableRefactors", "2.4.0"),
// GetEditsForRefactor("getEditsForRefactor", "2.4.0"),
//
// OpenExternalProject("openExternalProject");
//
// private final String name;
// private final String sinceVersion;
//
// private CommandNames(String name) {
// this(name, null);
// }
//
// private CommandNames(String name, String sinceVersion) {
// this.name = name;
// this.sinceVersion = sinceVersion;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Return true if the tsserver command support the given version and false
// * otherwise.
// *
// * @param version
// * @return true if the tsserver command support the given version and false
// * otherwise.
// */
// public boolean canSupport(String version) {
// return VersionHelper.canSupport(version, sinceVersion);
// }
//
// }
//
// Path: core/ts.core/src/ts/internal/client/protocol/OpenExternalProjectRequestArgs.java
// public static class ExternalFile {
// /**
// * Name of file file
// */
// String fileName;
// /**
// * Script kind of the file
// */
// ScriptKindName scriptKind;
// /**
// * Whether file has mixed content (i.e. .cshtml file that combines html markup
// * with C#/JavaScript)
// */
// Boolean hasMixedContent;
// /**
// * Content of the file
// */
// String content;
//
// public ExternalFile(String fileName, ScriptKindName scriptKind, Boolean hasMixedContent, String content) {
// this.fileName = fileName;
// this.scriptKind = scriptKind;
// this.hasMixedContent = hasMixedContent;
// this.content = content;
// }
//
// }
| import java.util.List;
import com.google.gson.JsonObject;
import ts.client.CommandNames;
import ts.cmd.tsc.CompilerOptions;
import ts.internal.client.protocol.OpenExternalProjectRequestArgs.ExternalFile; | package ts.internal.client.protocol;
/**
* Request to open or update external project.
*
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*
*/
public class OpenExternalProjectRequest extends Request<OpenExternalProjectRequestArgs> {
public OpenExternalProjectRequest(String projectFileName, List<ExternalFile> rootFiles, CompilerOptions options) { | // Path: core/ts.core/src/ts/client/CommandNames.java
// public enum CommandNames implements ISupportable {
//
// Open("open"),
// Close("close"),
// Change("change"),
// NavBar("navbar"),
// Completions("completions"),
// CompletionEntryDetails("completionEntryDetails"),
// Reload("reload"),
// Definition("definition"),
// SignatureHelp("signatureHelp"),
// QuickInfo("quickinfo"),
// Geterr("geterr"),
// GeterrForProject("geterrForProject"),
// Format("format"),
// References("references"),
// Occurrences("occurrences"),
// Configure("configure"),
// ProjectInfo("projectInfo"),
// Rename("rename"),
// NavTo("navto"),
//
// // 2.0.0
// SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),
// SyntacticDiagnosticsSync("syntacticDiagnosticsSync", "2.0.0"),
//
// // 2.0.5
// CompileOnSaveAffectedFileList("compileOnSaveAffectedFileList", "2.0.5"),
// CompileOnSaveEmitFile("compileOnSaveEmitFile", "2.0.5"),
//
// // 2.0.6
// NavTree("navtree", "2.0.6"),
// DocCommentTemplate("docCommentTemplate", "2.0.6"),
//
// // 2.1.0
// Implementation("implementation", "2.1.0"),
// GetSupportedCodeFixes("getSupportedCodeFixes", "2.1.0"),
// GetCodeFixes("getCodeFixes", "2.1.0"),
//
// // 2.4.0
// GetApplicableRefactors("getApplicableRefactors", "2.4.0"),
// GetEditsForRefactor("getEditsForRefactor", "2.4.0"),
//
// OpenExternalProject("openExternalProject");
//
// private final String name;
// private final String sinceVersion;
//
// private CommandNames(String name) {
// this(name, null);
// }
//
// private CommandNames(String name, String sinceVersion) {
// this.name = name;
// this.sinceVersion = sinceVersion;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Return true if the tsserver command support the given version and false
// * otherwise.
// *
// * @param version
// * @return true if the tsserver command support the given version and false
// * otherwise.
// */
// public boolean canSupport(String version) {
// return VersionHelper.canSupport(version, sinceVersion);
// }
//
// }
//
// Path: core/ts.core/src/ts/internal/client/protocol/OpenExternalProjectRequestArgs.java
// public static class ExternalFile {
// /**
// * Name of file file
// */
// String fileName;
// /**
// * Script kind of the file
// */
// ScriptKindName scriptKind;
// /**
// * Whether file has mixed content (i.e. .cshtml file that combines html markup
// * with C#/JavaScript)
// */
// Boolean hasMixedContent;
// /**
// * Content of the file
// */
// String content;
//
// public ExternalFile(String fileName, ScriptKindName scriptKind, Boolean hasMixedContent, String content) {
// this.fileName = fileName;
// this.scriptKind = scriptKind;
// this.hasMixedContent = hasMixedContent;
// this.content = content;
// }
//
// }
// Path: core/ts.core/src/ts/internal/client/protocol/OpenExternalProjectRequest.java
import java.util.List;
import com.google.gson.JsonObject;
import ts.client.CommandNames;
import ts.cmd.tsc.CompilerOptions;
import ts.internal.client.protocol.OpenExternalProjectRequestArgs.ExternalFile;
package ts.internal.client.protocol;
/**
* Request to open or update external project.
*
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*
*/
public class OpenExternalProjectRequest extends Request<OpenExternalProjectRequestArgs> {
public OpenExternalProjectRequest(String projectFileName, List<ExternalFile> rootFiles, CompilerOptions options) { | super(CommandNames.OpenExternalProject.getName(), |
angelozerr/typescript.java | core/ts.core/src/ts/internal/client/protocol/DefinitionRequest.java | // Path: core/ts.core/src/ts/client/CommandNames.java
// public enum CommandNames implements ISupportable {
//
// Open("open"),
// Close("close"),
// Change("change"),
// NavBar("navbar"),
// Completions("completions"),
// CompletionEntryDetails("completionEntryDetails"),
// Reload("reload"),
// Definition("definition"),
// SignatureHelp("signatureHelp"),
// QuickInfo("quickinfo"),
// Geterr("geterr"),
// GeterrForProject("geterrForProject"),
// Format("format"),
// References("references"),
// Occurrences("occurrences"),
// Configure("configure"),
// ProjectInfo("projectInfo"),
// Rename("rename"),
// NavTo("navto"),
//
// // 2.0.0
// SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),
// SyntacticDiagnosticsSync("syntacticDiagnosticsSync", "2.0.0"),
//
// // 2.0.5
// CompileOnSaveAffectedFileList("compileOnSaveAffectedFileList", "2.0.5"),
// CompileOnSaveEmitFile("compileOnSaveEmitFile", "2.0.5"),
//
// // 2.0.6
// NavTree("navtree", "2.0.6"),
// DocCommentTemplate("docCommentTemplate", "2.0.6"),
//
// // 2.1.0
// Implementation("implementation", "2.1.0"),
// GetSupportedCodeFixes("getSupportedCodeFixes", "2.1.0"),
// GetCodeFixes("getCodeFixes", "2.1.0"),
//
// // 2.4.0
// GetApplicableRefactors("getApplicableRefactors", "2.4.0"),
// GetEditsForRefactor("getEditsForRefactor", "2.4.0"),
//
// OpenExternalProject("openExternalProject");
//
// private final String name;
// private final String sinceVersion;
//
// private CommandNames(String name) {
// this(name, null);
// }
//
// private CommandNames(String name, String sinceVersion) {
// this.name = name;
// this.sinceVersion = sinceVersion;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Return true if the tsserver command support the given version and false
// * otherwise.
// *
// * @param version
// * @return true if the tsserver command support the given version and false
// * otherwise.
// */
// public boolean canSupport(String version) {
// return VersionHelper.canSupport(version, sinceVersion);
// }
//
// }
| import ts.client.CommandNames;
import ts.client.FileSpan;
import java.util.List;
import com.google.gson.JsonObject;
| /**
* Copyright (c) 2015-2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package ts.internal.client.protocol;
/**
* Go to definition request; value of command field is "definition". Return
* response giving the file locations that define the symbol found in file at
* location line, col.
*
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*/
public class DefinitionRequest extends FileLocationRequest<FileLocationRequestArgs> {
public DefinitionRequest(String file, int line, int offset) {
| // Path: core/ts.core/src/ts/client/CommandNames.java
// public enum CommandNames implements ISupportable {
//
// Open("open"),
// Close("close"),
// Change("change"),
// NavBar("navbar"),
// Completions("completions"),
// CompletionEntryDetails("completionEntryDetails"),
// Reload("reload"),
// Definition("definition"),
// SignatureHelp("signatureHelp"),
// QuickInfo("quickinfo"),
// Geterr("geterr"),
// GeterrForProject("geterrForProject"),
// Format("format"),
// References("references"),
// Occurrences("occurrences"),
// Configure("configure"),
// ProjectInfo("projectInfo"),
// Rename("rename"),
// NavTo("navto"),
//
// // 2.0.0
// SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),
// SyntacticDiagnosticsSync("syntacticDiagnosticsSync", "2.0.0"),
//
// // 2.0.5
// CompileOnSaveAffectedFileList("compileOnSaveAffectedFileList", "2.0.5"),
// CompileOnSaveEmitFile("compileOnSaveEmitFile", "2.0.5"),
//
// // 2.0.6
// NavTree("navtree", "2.0.6"),
// DocCommentTemplate("docCommentTemplate", "2.0.6"),
//
// // 2.1.0
// Implementation("implementation", "2.1.0"),
// GetSupportedCodeFixes("getSupportedCodeFixes", "2.1.0"),
// GetCodeFixes("getCodeFixes", "2.1.0"),
//
// // 2.4.0
// GetApplicableRefactors("getApplicableRefactors", "2.4.0"),
// GetEditsForRefactor("getEditsForRefactor", "2.4.0"),
//
// OpenExternalProject("openExternalProject");
//
// private final String name;
// private final String sinceVersion;
//
// private CommandNames(String name) {
// this(name, null);
// }
//
// private CommandNames(String name, String sinceVersion) {
// this.name = name;
// this.sinceVersion = sinceVersion;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Return true if the tsserver command support the given version and false
// * otherwise.
// *
// * @param version
// * @return true if the tsserver command support the given version and false
// * otherwise.
// */
// public boolean canSupport(String version) {
// return VersionHelper.canSupport(version, sinceVersion);
// }
//
// }
// Path: core/ts.core/src/ts/internal/client/protocol/DefinitionRequest.java
import ts.client.CommandNames;
import ts.client.FileSpan;
import java.util.List;
import com.google.gson.JsonObject;
/**
* Copyright (c) 2015-2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package ts.internal.client.protocol;
/**
* Go to definition request; value of command field is "definition". Return
* response giving the file locations that define the symbol found in file at
* location line, col.
*
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*/
public class DefinitionRequest extends FileLocationRequest<FileLocationRequestArgs> {
public DefinitionRequest(String file, int line, int offset) {
| super(CommandNames.Definition.getName(), new FileLocationRequestArgs(file, line, offset));
|
angelozerr/typescript.java | core/ts.core/src/ts/internal/client/protocol/OpenRequest.java | // Path: core/ts.core/src/ts/client/CommandNames.java
// public enum CommandNames implements ISupportable {
//
// Open("open"),
// Close("close"),
// Change("change"),
// NavBar("navbar"),
// Completions("completions"),
// CompletionEntryDetails("completionEntryDetails"),
// Reload("reload"),
// Definition("definition"),
// SignatureHelp("signatureHelp"),
// QuickInfo("quickinfo"),
// Geterr("geterr"),
// GeterrForProject("geterrForProject"),
// Format("format"),
// References("references"),
// Occurrences("occurrences"),
// Configure("configure"),
// ProjectInfo("projectInfo"),
// Rename("rename"),
// NavTo("navto"),
//
// // 2.0.0
// SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),
// SyntacticDiagnosticsSync("syntacticDiagnosticsSync", "2.0.0"),
//
// // 2.0.5
// CompileOnSaveAffectedFileList("compileOnSaveAffectedFileList", "2.0.5"),
// CompileOnSaveEmitFile("compileOnSaveEmitFile", "2.0.5"),
//
// // 2.0.6
// NavTree("navtree", "2.0.6"),
// DocCommentTemplate("docCommentTemplate", "2.0.6"),
//
// // 2.1.0
// Implementation("implementation", "2.1.0"),
// GetSupportedCodeFixes("getSupportedCodeFixes", "2.1.0"),
// GetCodeFixes("getCodeFixes", "2.1.0"),
//
// // 2.4.0
// GetApplicableRefactors("getApplicableRefactors", "2.4.0"),
// GetEditsForRefactor("getEditsForRefactor", "2.4.0"),
//
// OpenExternalProject("openExternalProject");
//
// private final String name;
// private final String sinceVersion;
//
// private CommandNames(String name) {
// this(name, null);
// }
//
// private CommandNames(String name, String sinceVersion) {
// this.name = name;
// this.sinceVersion = sinceVersion;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Return true if the tsserver command support the given version and false
// * otherwise.
// *
// * @param version
// * @return true if the tsserver command support the given version and false
// * otherwise.
// */
// public boolean canSupport(String version) {
// return VersionHelper.canSupport(version, sinceVersion);
// }
//
// }
//
// Path: core/ts.core/src/ts/client/ScriptKindName.java
// public enum ScriptKindName {
//
// TS ,JS ,TSX ,JSX
// }
| import com.google.gson.JsonObject;
import ts.client.CommandNames;
import ts.client.ScriptKindName;
| /**
* Copyright (c) 2015-2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package ts.internal.client.protocol;
/**
* Open request; value of command field is "open". Notify the server that the
* client has file open. The server will not monitor the filesystem for changes
* in this file and will assume that the client is updating the server (using
* the change and/or reload messages) when the file changes. Server does not
* currently send a response to an open request.
*
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*
*/
public class OpenRequest extends Request<OpenRequestArgs> {
public OpenRequest(String file, String projectName, String fileContent, ScriptKindName scriptKindName) {
| // Path: core/ts.core/src/ts/client/CommandNames.java
// public enum CommandNames implements ISupportable {
//
// Open("open"),
// Close("close"),
// Change("change"),
// NavBar("navbar"),
// Completions("completions"),
// CompletionEntryDetails("completionEntryDetails"),
// Reload("reload"),
// Definition("definition"),
// SignatureHelp("signatureHelp"),
// QuickInfo("quickinfo"),
// Geterr("geterr"),
// GeterrForProject("geterrForProject"),
// Format("format"),
// References("references"),
// Occurrences("occurrences"),
// Configure("configure"),
// ProjectInfo("projectInfo"),
// Rename("rename"),
// NavTo("navto"),
//
// // 2.0.0
// SemanticDiagnosticsSync("semanticDiagnosticsSync", "2.0.0"),
// SyntacticDiagnosticsSync("syntacticDiagnosticsSync", "2.0.0"),
//
// // 2.0.5
// CompileOnSaveAffectedFileList("compileOnSaveAffectedFileList", "2.0.5"),
// CompileOnSaveEmitFile("compileOnSaveEmitFile", "2.0.5"),
//
// // 2.0.6
// NavTree("navtree", "2.0.6"),
// DocCommentTemplate("docCommentTemplate", "2.0.6"),
//
// // 2.1.0
// Implementation("implementation", "2.1.0"),
// GetSupportedCodeFixes("getSupportedCodeFixes", "2.1.0"),
// GetCodeFixes("getCodeFixes", "2.1.0"),
//
// // 2.4.0
// GetApplicableRefactors("getApplicableRefactors", "2.4.0"),
// GetEditsForRefactor("getEditsForRefactor", "2.4.0"),
//
// OpenExternalProject("openExternalProject");
//
// private final String name;
// private final String sinceVersion;
//
// private CommandNames(String name) {
// this(name, null);
// }
//
// private CommandNames(String name, String sinceVersion) {
// this.name = name;
// this.sinceVersion = sinceVersion;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Return true if the tsserver command support the given version and false
// * otherwise.
// *
// * @param version
// * @return true if the tsserver command support the given version and false
// * otherwise.
// */
// public boolean canSupport(String version) {
// return VersionHelper.canSupport(version, sinceVersion);
// }
//
// }
//
// Path: core/ts.core/src/ts/client/ScriptKindName.java
// public enum ScriptKindName {
//
// TS ,JS ,TSX ,JSX
// }
// Path: core/ts.core/src/ts/internal/client/protocol/OpenRequest.java
import com.google.gson.JsonObject;
import ts.client.CommandNames;
import ts.client.ScriptKindName;
/**
* Copyright (c) 2015-2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
*/
package ts.internal.client.protocol;
/**
* Open request; value of command field is "open". Notify the server that the
* client has file open. The server will not monitor the filesystem for changes
* in this file and will assume that the client is updating the server (using
* the change and/or reload messages) when the file changes. Server does not
* currently send a response to an open request.
*
* @see https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts
*
*/
public class OpenRequest extends Request<OpenRequestArgs> {
public OpenRequest(String file, String projectName, String fileContent, ScriptKindName scriptKindName) {
| super(CommandNames.Open.getName(), new OpenRequestArgs(file, projectName, fileContent, scriptKindName));
|
Canadensys/canadensys-data-access | src/main/java/net/canadensys/dataportal/occurrence/dao/impl/ElasticSearchOccurrenceAutoCompleteDAO.java | // Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAO.java
// public interface OccurrenceAutoCompleteDAO {
//
// /**
// * Returns suggestions as JSON string for a field and a current value.
// * @param field
// * @param currValue
// * @param useSanitizedValue compare with sanitized value instead of real value
// * @return result as JSON string
// */
// public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue);
//
// /**
// * Returns all possible values as UniqueValuesModel list.
// * @param field
// * @return
// */
// public List<UniqueValuesModel> getAllPossibleValues(String field);
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/UniqueValuesModel.java
// @Entity
// @Table(name = "unique_values")
// public class UniqueValuesModel {
//
// @Id
// private int id;
//
// @Column(name = "key")
// private String key;
//
// @Column(name = "occurrence_count")
// private int occurrence_count;
//
// @Column(name = "value")
// private String value;
//
// @Column(name = "unaccented_value")
// private String unaccented_value;
//
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public String getKey() {
// return key;
// }
// public void setKey(String key) {
// this.key = key;
// }
//
// public int getOccurrence_count() {
// return occurrence_count;
// }
// public void setOccurrence_count(int occurrence_count) {
// this.occurrence_count = occurrence_count;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getUnaccented_value() {
// return unaccented_value;
// }
// public void setUnaccented_value(String unaccented_value) {
// this.unaccented_value = unaccented_value;
// }
// }
| import java.util.List;
import net.canadensys.dataportal.occurrence.dao.OccurrenceAutoCompleteDAO;
import net.canadensys.dataportal.occurrence.model.UniqueValuesModel;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.Client;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; | package net.canadensys.dataportal.occurrence.dao.impl;
/**
* WORK IN PROGRESS
* Requires ElasticSearch > 1.0
* @author cgendreau
*
*/
public class ElasticSearchOccurrenceAutoCompleteDAO implements OccurrenceAutoCompleteDAO{
private static final String INDEX_NAME = "portal";
private static final String OCCURRENCE_TYPE = "occurrence";
private static final int MAX_SIZE = 10;
@Autowired
@Qualifier("esClient")
private Client client;
// curl -X GET 'localhost:9200/portal/_search?pretty' -d '{
// "query":{
// "match" : {
// "country.autocomplete" : "Ca"
// }
// },
// "aggs" : {
// "countries" : {
// "terms" : { "field" : "country" }
// }
// }
// }'
@Override
public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue) {
SearchRequestBuilder srb = client.prepareSearch(INDEX_NAME)
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(QueryBuilders.matchQuery("country.autocomplete", currValue))
//TODO add aggregation, requires ES > 1.0
.setSize(MAX_SIZE)
.setTypes(OCCURRENCE_TYPE);
SearchResponse response = srb
.execute()
.actionGet();
response.getHits();
return null;
}
@Override | // Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAO.java
// public interface OccurrenceAutoCompleteDAO {
//
// /**
// * Returns suggestions as JSON string for a field and a current value.
// * @param field
// * @param currValue
// * @param useSanitizedValue compare with sanitized value instead of real value
// * @return result as JSON string
// */
// public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue);
//
// /**
// * Returns all possible values as UniqueValuesModel list.
// * @param field
// * @return
// */
// public List<UniqueValuesModel> getAllPossibleValues(String field);
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/UniqueValuesModel.java
// @Entity
// @Table(name = "unique_values")
// public class UniqueValuesModel {
//
// @Id
// private int id;
//
// @Column(name = "key")
// private String key;
//
// @Column(name = "occurrence_count")
// private int occurrence_count;
//
// @Column(name = "value")
// private String value;
//
// @Column(name = "unaccented_value")
// private String unaccented_value;
//
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public String getKey() {
// return key;
// }
// public void setKey(String key) {
// this.key = key;
// }
//
// public int getOccurrence_count() {
// return occurrence_count;
// }
// public void setOccurrence_count(int occurrence_count) {
// this.occurrence_count = occurrence_count;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getUnaccented_value() {
// return unaccented_value;
// }
// public void setUnaccented_value(String unaccented_value) {
// this.unaccented_value = unaccented_value;
// }
// }
// Path: src/main/java/net/canadensys/dataportal/occurrence/dao/impl/ElasticSearchOccurrenceAutoCompleteDAO.java
import java.util.List;
import net.canadensys.dataportal.occurrence.dao.OccurrenceAutoCompleteDAO;
import net.canadensys.dataportal.occurrence.model.UniqueValuesModel;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.Client;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
package net.canadensys.dataportal.occurrence.dao.impl;
/**
* WORK IN PROGRESS
* Requires ElasticSearch > 1.0
* @author cgendreau
*
*/
public class ElasticSearchOccurrenceAutoCompleteDAO implements OccurrenceAutoCompleteDAO{
private static final String INDEX_NAME = "portal";
private static final String OCCURRENCE_TYPE = "occurrence";
private static final int MAX_SIZE = 10;
@Autowired
@Qualifier("esClient")
private Client client;
// curl -X GET 'localhost:9200/portal/_search?pretty' -d '{
// "query":{
// "match" : {
// "country.autocomplete" : "Ca"
// }
// },
// "aggs" : {
// "countries" : {
// "terms" : { "field" : "country" }
// }
// }
// }'
@Override
public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue) {
SearchRequestBuilder srb = client.prepareSearch(INDEX_NAME)
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(QueryBuilders.matchQuery("country.autocomplete", currValue))
//TODO add aggregation, requires ES > 1.0
.setSize(MAX_SIZE)
.setTypes(OCCURRENCE_TYPE);
SearchResponse response = srb
.execute()
.actionGet();
response.getHits();
return null;
}
@Override | public List<UniqueValuesModel> getAllPossibleValues(String field) { |
Canadensys/canadensys-data-access | src/test/java/net/canadensys/dataportal/vascan/dao/VernacularNameDAOTest.java | // Path: src/main/java/net/canadensys/dataportal/vascan/model/VernacularNameModel.java
// @Entity
// @Table(name="vernacularname")
// public class VernacularNameModel {
//
// private int id;
// private String name;
// private StatusModel status;
// private TaxonModel taxon;
// private String language;
// private ReferenceModel reference;
// @Temporal(TemporalType.TIMESTAMP)
// private Date cdate;
// @Temporal(TemporalType.TIMESTAMP)
// private Date mdate;
//
// /**
// * @return the id
// */
// @Id
// @GeneratedValue(strategy=GenerationType.AUTO)
// public int getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @ManyToOne
// @JoinColumn(name="statusid")
// public StatusModel getStatus() {
// return status;
// }
//
// /**
// * @param status
// */
// public void setStatus(StatusModel status) {
// this.status = status;
// }
//
// @ManyToOne
// @JoinColumn(name="taxonid")
// public TaxonModel getTaxon() {
// return taxon;
// }
//
// /**
// * @param taxon
// */
//
// public void setTaxon(TaxonModel taxon) {
// this.taxon = taxon;
// }
//
// /**
// * @return the language
// */
// public String getLanguage() {
// return language;
// }
//
// /**
// * @param language
// */
// public void setLanguage(String language) {
// this.language = language;
// }
//
// @ManyToOne
// @JoinColumn(name="referenceid")
// public ReferenceModel getReference() {
// return reference;
// }
//
// /**
// * @param refrence
// */
// public void setReference(ReferenceModel reference) {
// this.reference = reference;
// }
//
// /**
// * @return the creation date
// */
// public Date getCdate() {
// return cdate;
// }
//
// /**
// * @param cdate
// */
// public void setCdate(Date cdate) {
// this.cdate = cdate;
// }
//
// /**
// * @return the modification date
// */
// public Date getMdate() {
// return mdate;
// }
//
// /**
// * @param mdate
// */
// public void setMdate(Date mdate) {
// this.mdate = mdate;
// }
//
// @Override
// /**
// * toString is mainly used in the admin backend, where a basic string representation
// * is dumped to the logfile, in a before/after fashion (changed from / changed to)
// */
// public String toString() {
// String delimiter = " ";
// //String newline = "\n";
// StringBuffer lookup = new StringBuffer("");
// lookup.append(this.id).append(delimiter);
// lookup.append(this.name).append(delimiter);
// lookup.append(this.status).append(delimiter);
// lookup.append(this.taxon.getLookup().getCalname()).append(delimiter);
// lookup.append(this.getLanguage()).append(delimiter);
// lookup.append(this.getReference().getReferenceshort());
// return lookup.toString();
// }
// }
| import static org.junit.Assert.assertEquals;
import java.util.List;
import net.canadensys.dataportal.vascan.model.VernacularNameModel;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration; | package net.canadensys.dataportal.vascan.dao;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/vascan/vascan-test-context.xml" })
@TransactionConfiguration(transactionManager="hibernateTransactionManager")
public class VernacularNameDAOTest extends AbstractTransactionalJUnit4SpringContextTests{
@Autowired
private VernacularNameDAO vernacularNameDAO;
/**
* Data loaded from test/resources/vascan/vascan-insertData-dao.sql file
*/
@Test
public void testLoadVernacularNameModel(){ | // Path: src/main/java/net/canadensys/dataportal/vascan/model/VernacularNameModel.java
// @Entity
// @Table(name="vernacularname")
// public class VernacularNameModel {
//
// private int id;
// private String name;
// private StatusModel status;
// private TaxonModel taxon;
// private String language;
// private ReferenceModel reference;
// @Temporal(TemporalType.TIMESTAMP)
// private Date cdate;
// @Temporal(TemporalType.TIMESTAMP)
// private Date mdate;
//
// /**
// * @return the id
// */
// @Id
// @GeneratedValue(strategy=GenerationType.AUTO)
// public int getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @ManyToOne
// @JoinColumn(name="statusid")
// public StatusModel getStatus() {
// return status;
// }
//
// /**
// * @param status
// */
// public void setStatus(StatusModel status) {
// this.status = status;
// }
//
// @ManyToOne
// @JoinColumn(name="taxonid")
// public TaxonModel getTaxon() {
// return taxon;
// }
//
// /**
// * @param taxon
// */
//
// public void setTaxon(TaxonModel taxon) {
// this.taxon = taxon;
// }
//
// /**
// * @return the language
// */
// public String getLanguage() {
// return language;
// }
//
// /**
// * @param language
// */
// public void setLanguage(String language) {
// this.language = language;
// }
//
// @ManyToOne
// @JoinColumn(name="referenceid")
// public ReferenceModel getReference() {
// return reference;
// }
//
// /**
// * @param refrence
// */
// public void setReference(ReferenceModel reference) {
// this.reference = reference;
// }
//
// /**
// * @return the creation date
// */
// public Date getCdate() {
// return cdate;
// }
//
// /**
// * @param cdate
// */
// public void setCdate(Date cdate) {
// this.cdate = cdate;
// }
//
// /**
// * @return the modification date
// */
// public Date getMdate() {
// return mdate;
// }
//
// /**
// * @param mdate
// */
// public void setMdate(Date mdate) {
// this.mdate = mdate;
// }
//
// @Override
// /**
// * toString is mainly used in the admin backend, where a basic string representation
// * is dumped to the logfile, in a before/after fashion (changed from / changed to)
// */
// public String toString() {
// String delimiter = " ";
// //String newline = "\n";
// StringBuffer lookup = new StringBuffer("");
// lookup.append(this.id).append(delimiter);
// lookup.append(this.name).append(delimiter);
// lookup.append(this.status).append(delimiter);
// lookup.append(this.taxon.getLookup().getCalname()).append(delimiter);
// lookup.append(this.getLanguage()).append(delimiter);
// lookup.append(this.getReference().getReferenceshort());
// return lookup.toString();
// }
// }
// Path: src/test/java/net/canadensys/dataportal/vascan/dao/VernacularNameDAOTest.java
import static org.junit.Assert.assertEquals;
import java.util.List;
import net.canadensys.dataportal.vascan.model.VernacularNameModel;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
package net.canadensys.dataportal.vascan.dao;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/vascan/vascan-test-context.xml" })
@TransactionConfiguration(transactionManager="hibernateTransactionManager")
public class VernacularNameDAOTest extends AbstractTransactionalJUnit4SpringContextTests{
@Autowired
private VernacularNameDAO vernacularNameDAO;
/**
* Data loaded from test/resources/vascan/vascan-insertData-dao.sql file
*/
@Test
public void testLoadVernacularNameModel(){ | VernacularNameModel vernacularNameModel = vernacularNameDAO.loadVernacularName(1); |
Canadensys/canadensys-data-access | src/main/java/net/canadensys/dataportal/vascan/dao/VernacularNameDAO.java | // Path: src/main/java/net/canadensys/dataportal/vascan/model/VernacularNameModel.java
// @Entity
// @Table(name="vernacularname")
// public class VernacularNameModel {
//
// private int id;
// private String name;
// private StatusModel status;
// private TaxonModel taxon;
// private String language;
// private ReferenceModel reference;
// @Temporal(TemporalType.TIMESTAMP)
// private Date cdate;
// @Temporal(TemporalType.TIMESTAMP)
// private Date mdate;
//
// /**
// * @return the id
// */
// @Id
// @GeneratedValue(strategy=GenerationType.AUTO)
// public int getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @ManyToOne
// @JoinColumn(name="statusid")
// public StatusModel getStatus() {
// return status;
// }
//
// /**
// * @param status
// */
// public void setStatus(StatusModel status) {
// this.status = status;
// }
//
// @ManyToOne
// @JoinColumn(name="taxonid")
// public TaxonModel getTaxon() {
// return taxon;
// }
//
// /**
// * @param taxon
// */
//
// public void setTaxon(TaxonModel taxon) {
// this.taxon = taxon;
// }
//
// /**
// * @return the language
// */
// public String getLanguage() {
// return language;
// }
//
// /**
// * @param language
// */
// public void setLanguage(String language) {
// this.language = language;
// }
//
// @ManyToOne
// @JoinColumn(name="referenceid")
// public ReferenceModel getReference() {
// return reference;
// }
//
// /**
// * @param refrence
// */
// public void setReference(ReferenceModel reference) {
// this.reference = reference;
// }
//
// /**
// * @return the creation date
// */
// public Date getCdate() {
// return cdate;
// }
//
// /**
// * @param cdate
// */
// public void setCdate(Date cdate) {
// this.cdate = cdate;
// }
//
// /**
// * @return the modification date
// */
// public Date getMdate() {
// return mdate;
// }
//
// /**
// * @param mdate
// */
// public void setMdate(Date mdate) {
// this.mdate = mdate;
// }
//
// @Override
// /**
// * toString is mainly used in the admin backend, where a basic string representation
// * is dumped to the logfile, in a before/after fashion (changed from / changed to)
// */
// public String toString() {
// String delimiter = " ";
// //String newline = "\n";
// StringBuffer lookup = new StringBuffer("");
// lookup.append(this.id).append(delimiter);
// lookup.append(this.name).append(delimiter);
// lookup.append(this.status).append(delimiter);
// lookup.append(this.taxon.getLookup().getCalname()).append(delimiter);
// lookup.append(this.getLanguage()).append(delimiter);
// lookup.append(this.getReference().getReferenceshort());
// return lookup.toString();
// }
// }
| import java.util.List;
import java.util.Map;
import net.canadensys.dataportal.vascan.model.VernacularNameModel; | package net.canadensys.dataportal.vascan.dao;
/**
* Interface for accessing vernacular names
*
* @author cgendreau
*
*/
public interface VernacularNameDAO {
//denormalized data (DD) keys
public static final String DD_TAXON_ID = "taxonid";
public static final String DD_NAME = "name";
public static final String DD_REFERENCE = "reference";
public static final String DD_URL = "url";
public static final String DD_LANGUAGE = "language";
public static final String DD_STATUS_ID = "statusid";
/**
* Load a VernacularNameModel from an identifier
* @param vernacularNameId
* @return
*/ | // Path: src/main/java/net/canadensys/dataportal/vascan/model/VernacularNameModel.java
// @Entity
// @Table(name="vernacularname")
// public class VernacularNameModel {
//
// private int id;
// private String name;
// private StatusModel status;
// private TaxonModel taxon;
// private String language;
// private ReferenceModel reference;
// @Temporal(TemporalType.TIMESTAMP)
// private Date cdate;
// @Temporal(TemporalType.TIMESTAMP)
// private Date mdate;
//
// /**
// * @return the id
// */
// @Id
// @GeneratedValue(strategy=GenerationType.AUTO)
// public int getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @ManyToOne
// @JoinColumn(name="statusid")
// public StatusModel getStatus() {
// return status;
// }
//
// /**
// * @param status
// */
// public void setStatus(StatusModel status) {
// this.status = status;
// }
//
// @ManyToOne
// @JoinColumn(name="taxonid")
// public TaxonModel getTaxon() {
// return taxon;
// }
//
// /**
// * @param taxon
// */
//
// public void setTaxon(TaxonModel taxon) {
// this.taxon = taxon;
// }
//
// /**
// * @return the language
// */
// public String getLanguage() {
// return language;
// }
//
// /**
// * @param language
// */
// public void setLanguage(String language) {
// this.language = language;
// }
//
// @ManyToOne
// @JoinColumn(name="referenceid")
// public ReferenceModel getReference() {
// return reference;
// }
//
// /**
// * @param refrence
// */
// public void setReference(ReferenceModel reference) {
// this.reference = reference;
// }
//
// /**
// * @return the creation date
// */
// public Date getCdate() {
// return cdate;
// }
//
// /**
// * @param cdate
// */
// public void setCdate(Date cdate) {
// this.cdate = cdate;
// }
//
// /**
// * @return the modification date
// */
// public Date getMdate() {
// return mdate;
// }
//
// /**
// * @param mdate
// */
// public void setMdate(Date mdate) {
// this.mdate = mdate;
// }
//
// @Override
// /**
// * toString is mainly used in the admin backend, where a basic string representation
// * is dumped to the logfile, in a before/after fashion (changed from / changed to)
// */
// public String toString() {
// String delimiter = " ";
// //String newline = "\n";
// StringBuffer lookup = new StringBuffer("");
// lookup.append(this.id).append(delimiter);
// lookup.append(this.name).append(delimiter);
// lookup.append(this.status).append(delimiter);
// lookup.append(this.taxon.getLookup().getCalname()).append(delimiter);
// lookup.append(this.getLanguage()).append(delimiter);
// lookup.append(this.getReference().getReferenceshort());
// return lookup.toString();
// }
// }
// Path: src/main/java/net/canadensys/dataportal/vascan/dao/VernacularNameDAO.java
import java.util.List;
import java.util.Map;
import net.canadensys.dataportal.vascan.model.VernacularNameModel;
package net.canadensys.dataportal.vascan.dao;
/**
* Interface for accessing vernacular names
*
* @author cgendreau
*
*/
public interface VernacularNameDAO {
//denormalized data (DD) keys
public static final String DD_TAXON_ID = "taxonid";
public static final String DD_NAME = "name";
public static final String DD_REFERENCE = "reference";
public static final String DD_URL = "url";
public static final String DD_LANGUAGE = "language";
public static final String DD_STATUS_ID = "statusid";
/**
* Load a VernacularNameModel from an identifier
* @param vernacularNameId
* @return
*/ | public VernacularNameModel loadVernacularName(Integer vernacularNameId); |
Canadensys/canadensys-data-access | src/test/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAOTest.java | // Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAO.java
// public interface OccurrenceAutoCompleteDAO {
//
// /**
// * Returns suggestions as JSON string for a field and a current value.
// * @param field
// * @param currValue
// * @param useSanitizedValue compare with sanitized value instead of real value
// * @return result as JSON string
// */
// public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue);
//
// /**
// * Returns all possible values as UniqueValuesModel list.
// * @param field
// * @return
// */
// public List<UniqueValuesModel> getAllPossibleValues(String field);
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/UniqueValuesModel.java
// @Entity
// @Table(name = "unique_values")
// public class UniqueValuesModel {
//
// @Id
// private int id;
//
// @Column(name = "key")
// private String key;
//
// @Column(name = "occurrence_count")
// private int occurrence_count;
//
// @Column(name = "value")
// private String value;
//
// @Column(name = "unaccented_value")
// private String unaccented_value;
//
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public String getKey() {
// return key;
// }
// public void setKey(String key) {
// this.key = key;
// }
//
// public int getOccurrence_count() {
// return occurrence_count;
// }
// public void setOccurrence_count(int occurrence_count) {
// this.occurrence_count = occurrence_count;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getUnaccented_value() {
// return unaccented_value;
// }
// public void setUnaccented_value(String unaccented_value) {
// this.unaccented_value = unaccented_value;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import net.canadensys.dataportal.occurrence.dao.OccurrenceAutoCompleteDAO;
import net.canadensys.dataportal.occurrence.model.UniqueValuesModel;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration; | package net.canadensys.dataportal.occurrence.dao;
/**
* Test Coverage :
* -Unaccented search
* -Load all possible values for a field
* @author canadensys
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/test-spring.xml" })
@TransactionConfiguration(transactionManager="hibernateTransactionManager")
public class OccurrenceAutoCompleteDAOTest extends AbstractTransactionalJUnit4SpringContextTests{
@Autowired | // Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAO.java
// public interface OccurrenceAutoCompleteDAO {
//
// /**
// * Returns suggestions as JSON string for a field and a current value.
// * @param field
// * @param currValue
// * @param useSanitizedValue compare with sanitized value instead of real value
// * @return result as JSON string
// */
// public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue);
//
// /**
// * Returns all possible values as UniqueValuesModel list.
// * @param field
// * @return
// */
// public List<UniqueValuesModel> getAllPossibleValues(String field);
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/UniqueValuesModel.java
// @Entity
// @Table(name = "unique_values")
// public class UniqueValuesModel {
//
// @Id
// private int id;
//
// @Column(name = "key")
// private String key;
//
// @Column(name = "occurrence_count")
// private int occurrence_count;
//
// @Column(name = "value")
// private String value;
//
// @Column(name = "unaccented_value")
// private String unaccented_value;
//
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public String getKey() {
// return key;
// }
// public void setKey(String key) {
// this.key = key;
// }
//
// public int getOccurrence_count() {
// return occurrence_count;
// }
// public void setOccurrence_count(int occurrence_count) {
// this.occurrence_count = occurrence_count;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getUnaccented_value() {
// return unaccented_value;
// }
// public void setUnaccented_value(String unaccented_value) {
// this.unaccented_value = unaccented_value;
// }
// }
// Path: src/test/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAOTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import net.canadensys.dataportal.occurrence.dao.OccurrenceAutoCompleteDAO;
import net.canadensys.dataportal.occurrence.model.UniqueValuesModel;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
package net.canadensys.dataportal.occurrence.dao;
/**
* Test Coverage :
* -Unaccented search
* -Load all possible values for a field
* @author canadensys
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/test-spring.xml" })
@TransactionConfiguration(transactionManager="hibernateTransactionManager")
public class OccurrenceAutoCompleteDAOTest extends AbstractTransactionalJUnit4SpringContextTests{
@Autowired | private OccurrenceAutoCompleteDAO autoCompleteOccurrenceDAO; |
Canadensys/canadensys-data-access | src/test/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAOTest.java | // Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAO.java
// public interface OccurrenceAutoCompleteDAO {
//
// /**
// * Returns suggestions as JSON string for a field and a current value.
// * @param field
// * @param currValue
// * @param useSanitizedValue compare with sanitized value instead of real value
// * @return result as JSON string
// */
// public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue);
//
// /**
// * Returns all possible values as UniqueValuesModel list.
// * @param field
// * @return
// */
// public List<UniqueValuesModel> getAllPossibleValues(String field);
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/UniqueValuesModel.java
// @Entity
// @Table(name = "unique_values")
// public class UniqueValuesModel {
//
// @Id
// private int id;
//
// @Column(name = "key")
// private String key;
//
// @Column(name = "occurrence_count")
// private int occurrence_count;
//
// @Column(name = "value")
// private String value;
//
// @Column(name = "unaccented_value")
// private String unaccented_value;
//
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public String getKey() {
// return key;
// }
// public void setKey(String key) {
// this.key = key;
// }
//
// public int getOccurrence_count() {
// return occurrence_count;
// }
// public void setOccurrence_count(int occurrence_count) {
// this.occurrence_count = occurrence_count;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getUnaccented_value() {
// return unaccented_value;
// }
// public void setUnaccented_value(String unaccented_value) {
// this.unaccented_value = unaccented_value;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import net.canadensys.dataportal.occurrence.dao.OccurrenceAutoCompleteDAO;
import net.canadensys.dataportal.occurrence.model.UniqueValuesModel;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration; | jdbcTemplate.update("INSERT INTO unique_values (key,occurrence_count,value,unaccented_value) VALUES ('country',125,'Canada','canada')");
jdbcTemplate.update("INSERT INTO unique_values (key,occurrence_count,value,unaccented_value) VALUES ('country',1,'canada','canada')");
jdbcTemplate.update("INSERT INTO unique_values (key,occurrence_count,value,unaccented_value) VALUES ('country',8,'Côte d''Ivoire','cote d''ivoire')");
jdbcTemplate.update("INSERT INTO unique_values (key,occurrence_count,value,unaccented_value) VALUES ('country',3,'Norway','norway')");
}
@Test
public void testUnaccentedSearch(){
List<String> expectedCountryList = new ArrayList<String>();
expectedCountryList.add("Canada");
expectedCountryList.add("canada");
expectedCountryList.add("Côte d'Ivoire");
String json = autoCompleteOccurrenceDAO.getSuggestionsFor("country", "c", true);
try{
JSONObject jsonObj = new JSONObject(json);
JSONArray jsonRows = (JSONArray)jsonObj.get("rows");
for(int i=0;i<jsonRows.length();i++){
assertTrue(expectedCountryList.contains(
((JSONObject)jsonRows.get(i)).get("value")));
}
}
catch (Exception e) {
fail();
}
}
@Test
public void testGetAllPossibleValues(){ | // Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAO.java
// public interface OccurrenceAutoCompleteDAO {
//
// /**
// * Returns suggestions as JSON string for a field and a current value.
// * @param field
// * @param currValue
// * @param useSanitizedValue compare with sanitized value instead of real value
// * @return result as JSON string
// */
// public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue);
//
// /**
// * Returns all possible values as UniqueValuesModel list.
// * @param field
// * @return
// */
// public List<UniqueValuesModel> getAllPossibleValues(String field);
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/UniqueValuesModel.java
// @Entity
// @Table(name = "unique_values")
// public class UniqueValuesModel {
//
// @Id
// private int id;
//
// @Column(name = "key")
// private String key;
//
// @Column(name = "occurrence_count")
// private int occurrence_count;
//
// @Column(name = "value")
// private String value;
//
// @Column(name = "unaccented_value")
// private String unaccented_value;
//
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public String getKey() {
// return key;
// }
// public void setKey(String key) {
// this.key = key;
// }
//
// public int getOccurrence_count() {
// return occurrence_count;
// }
// public void setOccurrence_count(int occurrence_count) {
// this.occurrence_count = occurrence_count;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getUnaccented_value() {
// return unaccented_value;
// }
// public void setUnaccented_value(String unaccented_value) {
// this.unaccented_value = unaccented_value;
// }
// }
// Path: src/test/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAOTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import net.canadensys.dataportal.occurrence.dao.OccurrenceAutoCompleteDAO;
import net.canadensys.dataportal.occurrence.model.UniqueValuesModel;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
jdbcTemplate.update("INSERT INTO unique_values (key,occurrence_count,value,unaccented_value) VALUES ('country',125,'Canada','canada')");
jdbcTemplate.update("INSERT INTO unique_values (key,occurrence_count,value,unaccented_value) VALUES ('country',1,'canada','canada')");
jdbcTemplate.update("INSERT INTO unique_values (key,occurrence_count,value,unaccented_value) VALUES ('country',8,'Côte d''Ivoire','cote d''ivoire')");
jdbcTemplate.update("INSERT INTO unique_values (key,occurrence_count,value,unaccented_value) VALUES ('country',3,'Norway','norway')");
}
@Test
public void testUnaccentedSearch(){
List<String> expectedCountryList = new ArrayList<String>();
expectedCountryList.add("Canada");
expectedCountryList.add("canada");
expectedCountryList.add("Côte d'Ivoire");
String json = autoCompleteOccurrenceDAO.getSuggestionsFor("country", "c", true);
try{
JSONObject jsonObj = new JSONObject(json);
JSONArray jsonRows = (JSONArray)jsonObj.get("rows");
for(int i=0;i<jsonRows.length();i++){
assertTrue(expectedCountryList.contains(
((JSONObject)jsonRows.get(i)).get("value")));
}
}
catch (Exception e) {
fail();
}
}
@Test
public void testGetAllPossibleValues(){ | List<UniqueValuesModel> possibleValues = autoCompleteOccurrenceDAO.getAllPossibleValues("country"); |
Canadensys/canadensys-data-access | src/test/java/net/canadensys/databaseutils/ScrollableResultsIteratorWrapperTest.java | // Path: src/main/java/net/canadensys/dataportal/vascan/model/RankModel.java
// @Entity
// @Table(name="rank")
// public class RankModel{
// private int id;
// private String rank;
// private int sort;
//
// @Id
// @GeneratedValue(strategy=GenerationType.AUTO)
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public int getSort(){
// return sort;
// }
// public void setSort(int sort){
// this.sort = sort;
// }
//
// /**
// *
// * @return the rank name
// */
// public String getRank(){
// return rank;
// }
// /**
// *
// * @param rank the rank name
// */
// public void setRank(String rank){
// this.rank = rank;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import javax.transaction.Transactional;
import net.canadensys.dataportal.vascan.model.RankModel;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.exception.GenericJDBCException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration; | package net.canadensys.databaseutils;
/**
* Test ScrollableResultsIteratorWrapper implementation
* @author cgendreau
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/vascan/vascan-test-context.xml" })
@TransactionConfiguration(transactionManager="hibernateTransactionManager")
public class ScrollableResultsIteratorWrapperTest {
@Autowired
private SessionFactory sessionFactory;
@Test
@Transactional
public void testScrollableResultsIteratorWrapperHasNext(){
Session hibernateSession = sessionFactory.getCurrentSession(); | // Path: src/main/java/net/canadensys/dataportal/vascan/model/RankModel.java
// @Entity
// @Table(name="rank")
// public class RankModel{
// private int id;
// private String rank;
// private int sort;
//
// @Id
// @GeneratedValue(strategy=GenerationType.AUTO)
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public int getSort(){
// return sort;
// }
// public void setSort(int sort){
// this.sort = sort;
// }
//
// /**
// *
// * @return the rank name
// */
// public String getRank(){
// return rank;
// }
// /**
// *
// * @param rank the rank name
// */
// public void setRank(String rank){
// this.rank = rank;
// }
// }
// Path: src/test/java/net/canadensys/databaseutils/ScrollableResultsIteratorWrapperTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import javax.transaction.Transactional;
import net.canadensys.dataportal.vascan.model.RankModel;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.exception.GenericJDBCException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
package net.canadensys.databaseutils;
/**
* Test ScrollableResultsIteratorWrapper implementation
* @author cgendreau
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/vascan/vascan-test-context.xml" })
@TransactionConfiguration(transactionManager="hibernateTransactionManager")
public class ScrollableResultsIteratorWrapperTest {
@Autowired
private SessionFactory sessionFactory;
@Test
@Transactional
public void testScrollableResultsIteratorWrapperHasNext(){
Session hibernateSession = sessionFactory.getCurrentSession(); | ScrollableResults sr = hibernateSession.createCriteria(RankModel.class).scroll(); |
Canadensys/canadensys-data-access | src/test/java/net/canadensys/dataportal/vascan/dao/DistributionDAOTest.java | // Path: src/main/java/net/canadensys/dataportal/vascan/model/DistributionStatusModel.java
// @Entity
// @Table(name="distributionstatus")
// public class DistributionStatusModel{
//
// private int id;
// private String distributionstatus;
// private String occurrencestatus;
// private String establishmentmeans;
//
//
// @Id
// @GeneratedValue(strategy=GenerationType.AUTO)
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * @return the distributionstatus
// */
// public String getDistributionstatus() {
// return distributionstatus;
// }
//
// /**
// * @param distributionstatus the distributionstatus to set
// */
// public void setDistributionstatus(String distributionstatus) {
// this.distributionstatus = distributionstatus;
// }
//
// /**
// * @return the occurencestatus
// */
// public String getOccurrencestatus() {
// return occurrencestatus;
// }
//
// /**
// * @param occurencestatus the occurencestatus to set
// */
// public void setOccurrencestatus(String occurrencestatus) {
// this.occurrencestatus = occurrencestatus;
// }
//
// /**
// * @return the establishmentmeans
// */
// public String getEstablishmentmeans() {
// return establishmentmeans;
// }
//
// /**
// * @param establishmentmeans the establishmentmeans to set
// */
// public void setEstablishmentmeans(String establishmentmeans) {
// this.establishmentmeans = establishmentmeans;
// }
// }
| import static org.junit.Assert.assertTrue;
import java.util.List;
import net.canadensys.dataportal.vascan.model.DistributionStatusModel;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration; | package net.canadensys.dataportal.vascan.dao;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/vascan/vascan-test-context.xml" })
@TransactionConfiguration(transactionManager="hibernateTransactionManager")
public class DistributionDAOTest extends AbstractTransactionalJUnit4SpringContextTests{
@Autowired
private DistributionDAO distributionDAO;
/**
* Data loaded from test/resources/vascan/vascan-insertData-dao.sql file
*/
@Test
public void testDistributionStatus(){ | // Path: src/main/java/net/canadensys/dataportal/vascan/model/DistributionStatusModel.java
// @Entity
// @Table(name="distributionstatus")
// public class DistributionStatusModel{
//
// private int id;
// private String distributionstatus;
// private String occurrencestatus;
// private String establishmentmeans;
//
//
// @Id
// @GeneratedValue(strategy=GenerationType.AUTO)
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// /**
// * @return the distributionstatus
// */
// public String getDistributionstatus() {
// return distributionstatus;
// }
//
// /**
// * @param distributionstatus the distributionstatus to set
// */
// public void setDistributionstatus(String distributionstatus) {
// this.distributionstatus = distributionstatus;
// }
//
// /**
// * @return the occurencestatus
// */
// public String getOccurrencestatus() {
// return occurrencestatus;
// }
//
// /**
// * @param occurencestatus the occurencestatus to set
// */
// public void setOccurrencestatus(String occurrencestatus) {
// this.occurrencestatus = occurrencestatus;
// }
//
// /**
// * @return the establishmentmeans
// */
// public String getEstablishmentmeans() {
// return establishmentmeans;
// }
//
// /**
// * @param establishmentmeans the establishmentmeans to set
// */
// public void setEstablishmentmeans(String establishmentmeans) {
// this.establishmentmeans = establishmentmeans;
// }
// }
// Path: src/test/java/net/canadensys/dataportal/vascan/dao/DistributionDAOTest.java
import static org.junit.Assert.assertTrue;
import java.util.List;
import net.canadensys.dataportal.vascan.model.DistributionStatusModel;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
package net.canadensys.dataportal.vascan.dao;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/vascan/vascan-test-context.xml" })
@TransactionConfiguration(transactionManager="hibernateTransactionManager")
public class DistributionDAOTest extends AbstractTransactionalJUnit4SpringContextTests{
@Autowired
private DistributionDAO distributionDAO;
/**
* Data loaded from test/resources/vascan/vascan-insertData-dao.sql file
*/
@Test
public void testDistributionStatus(){ | List<DistributionStatusModel> distributionStatusModelList = distributionDAO.loadAllDistributionStatus(); |
Canadensys/canadensys-data-access | src/test/java/net/canadensys/dataportal/occurrence/dao/OccurrenceExtensionDAOTest.java | // Path: src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceExtensionModel.java
// @Entity
// @Table(name = "occurrence_extension")
// @TypeDefs( {@TypeDef( name= "KeyValueType", typeClass = KeyValueType.class)})
// public class OccurrenceExtensionModel {
//
// @Id
// private long auto_id;
//
// @NaturalId
// private String dwcaid;
// @NaturalId
// private String sourcefileid;
// @NaturalId
// private String resource_uuid;
//
// private String ext_type;
// private String ext_version;
//
// @Type(type="KeyValueType")
// private Map<String,String> ext_data;
//
// public long getAuto_id() {
// return auto_id;
// }
// public void setAuto_id(long auto_id) {
// this.auto_id = auto_id;
// }
//
// public String getDwcaid() {
// return dwcaid;
// }
// public void setDwcaid(String dwcaid) {
// this.dwcaid = dwcaid;
// }
//
// public String getSourcefileid() {
// return sourcefileid;
// }
// public void setSourcefileid(String sourcefileid) {
// this.sourcefileid = sourcefileid;
// }
//
// public String getResource_uuid() {
// return resource_uuid;
// }
// public void setResource_uuid(String resource_uuid) {
// this.resource_uuid = resource_uuid;
// }
//
// public String getExt_type() {
// return ext_type;
// }
// public void setExt_type(String ext_type) {
// this.ext_type = ext_type;
// }
//
// public String getExt_version() {
// return ext_version;
// }
// public void setExt_version(String ext_version) {
// this.ext_version = ext_version;
// }
//
// public Map<String,String> getExt_data() {
// return ext_data;
// }
// public void setExt_data(Map<String,String> ext_data) {
// this.ext_data = ext_data;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.canadensys.dataportal.occurrence.model.OccurrenceExtensionModel;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration; | package net.canadensys.dataportal.occurrence.dao;
/**
* This test is using a 'stub' hstore since hstore is PostgreSQL specific.
* The trick to use it with h2 is available in src/test/resources/h2/h2setup.sql
* Test Coverage :
* -Insert extension data using jdbcTemplate
* -Save OccurrenceExtensionModel
* -Load OccurrenceExtensionModel from id
* -Load OccurrenceExtensionModel list from extensionType, resourceUUID, dwcaID
* @author canadensys
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/test-spring.xml" })
@TransactionConfiguration(transactionManager = "hibernateTransactionManager")
public class OccurrenceExtensionDAOTest extends AbstractTransactionalJUnit4SpringContextTests {
@Autowired
private OccurrenceExtensionDAO occurrenceExtDAO;
@Before
public void setup() {
// make sure the table is empty
jdbcTemplate.update("DELETE FROM occurrence_extension");
jdbcTemplate
.update("INSERT INTO occurrence_extension (auto_id,dwcaid,sourcefileid,resource_uuid,ext_type,ext_data) VALUES (1,'1','source','1111-1111','image', toKeyValue('image_type=>png','author=>darwin','licence=>cc0'))");
}
@Test
public void testSaveAndLoad() {
| // Path: src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceExtensionModel.java
// @Entity
// @Table(name = "occurrence_extension")
// @TypeDefs( {@TypeDef( name= "KeyValueType", typeClass = KeyValueType.class)})
// public class OccurrenceExtensionModel {
//
// @Id
// private long auto_id;
//
// @NaturalId
// private String dwcaid;
// @NaturalId
// private String sourcefileid;
// @NaturalId
// private String resource_uuid;
//
// private String ext_type;
// private String ext_version;
//
// @Type(type="KeyValueType")
// private Map<String,String> ext_data;
//
// public long getAuto_id() {
// return auto_id;
// }
// public void setAuto_id(long auto_id) {
// this.auto_id = auto_id;
// }
//
// public String getDwcaid() {
// return dwcaid;
// }
// public void setDwcaid(String dwcaid) {
// this.dwcaid = dwcaid;
// }
//
// public String getSourcefileid() {
// return sourcefileid;
// }
// public void setSourcefileid(String sourcefileid) {
// this.sourcefileid = sourcefileid;
// }
//
// public String getResource_uuid() {
// return resource_uuid;
// }
// public void setResource_uuid(String resource_uuid) {
// this.resource_uuid = resource_uuid;
// }
//
// public String getExt_type() {
// return ext_type;
// }
// public void setExt_type(String ext_type) {
// this.ext_type = ext_type;
// }
//
// public String getExt_version() {
// return ext_version;
// }
// public void setExt_version(String ext_version) {
// this.ext_version = ext_version;
// }
//
// public Map<String,String> getExt_data() {
// return ext_data;
// }
// public void setExt_data(Map<String,String> ext_data) {
// this.ext_data = ext_data;
// }
//
// }
// Path: src/test/java/net/canadensys/dataportal/occurrence/dao/OccurrenceExtensionDAOTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.canadensys.dataportal.occurrence.model.OccurrenceExtensionModel;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
package net.canadensys.dataportal.occurrence.dao;
/**
* This test is using a 'stub' hstore since hstore is PostgreSQL specific.
* The trick to use it with h2 is available in src/test/resources/h2/h2setup.sql
* Test Coverage :
* -Insert extension data using jdbcTemplate
* -Save OccurrenceExtensionModel
* -Load OccurrenceExtensionModel from id
* -Load OccurrenceExtensionModel list from extensionType, resourceUUID, dwcaID
* @author canadensys
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/test-spring.xml" })
@TransactionConfiguration(transactionManager = "hibernateTransactionManager")
public class OccurrenceExtensionDAOTest extends AbstractTransactionalJUnit4SpringContextTests {
@Autowired
private OccurrenceExtensionDAO occurrenceExtDAO;
@Before
public void setup() {
// make sure the table is empty
jdbcTemplate.update("DELETE FROM occurrence_extension");
jdbcTemplate
.update("INSERT INTO occurrence_extension (auto_id,dwcaid,sourcefileid,resource_uuid,ext_type,ext_data) VALUES (1,'1','source','1111-1111','image', toKeyValue('image_type=>png','author=>darwin','licence=>cc0'))");
}
@Test
public void testSaveAndLoad() {
| OccurrenceExtensionModel occExtModel = new OccurrenceExtensionModel(); |
Canadensys/canadensys-data-access | src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceExtensionModel.java | // Path: src/main/java/net/canadensys/databaseutils/hibernate/KeyValueType.java
// public class KeyValueType implements UserType {
//
// public Object assemble(Serializable cached, Object owner) throws HibernateException {
// return cached;
// }
//
// @SuppressWarnings("unchecked")
// public Object deepCopy(Object o) throws HibernateException {
// if( o == null){
// return null;
// }
// // Not a true deep copy but since the map contains immutable Strings, it's fine.
// return new HashMap<String, String>((Map<String, String>) o);
// }
//
// public Serializable disassemble(Object o) throws HibernateException {
// return (Serializable) o;
// }
//
// @SuppressWarnings("deprecation")
// public boolean equals(Object o1, Object o2) throws HibernateException {
// // deprecated in Java 7
// return ObjectUtils.equals(o1, o2);
// }
//
// public int hashCode(Object o) throws HibernateException {
// return o.hashCode();
// }
//
// public boolean isMutable() {
// return true;
// }
//
// public Object replace(Object original, Object target, Object owner) throws HibernateException {
// return original;
// }
//
// public Class<?> returnedClass() {
// return Map.class;
// }
//
// public int[] sqlTypes() {
// return new int[] { Types.OTHER };
// }
//
// @Override
// public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
// if(rs.getString(names[0]) == null){
// return null;
// }
// return rs.getObject(names[0]);
// }
//
// @Override
// public void nullSafeSet(PreparedStatement ps, Object obj, int index, SessionImplementor session) throws HibernateException, SQLException {
// if (obj == null) {
// ps.setNull(index, Types.OTHER);
// return;
// }
// // can't use ps.setObject(index, obj, Types.OTHER) for now
// // see https://github.com/pgjdbc/pgjdbc/issues/199
// ps.setObject(index, obj);
// }
// }
| import java.util.Map;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import net.canadensys.databaseutils.hibernate.KeyValueType;
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs; | package net.canadensys.dataportal.occurrence.model;
/**
* Model containing data related to a DarwinCore occurrence extension. Data are stored in a key/value map allowing to abstract specific extension columns.
* @author cgendreau
*
*/
@Entity
@Table(name = "occurrence_extension") | // Path: src/main/java/net/canadensys/databaseutils/hibernate/KeyValueType.java
// public class KeyValueType implements UserType {
//
// public Object assemble(Serializable cached, Object owner) throws HibernateException {
// return cached;
// }
//
// @SuppressWarnings("unchecked")
// public Object deepCopy(Object o) throws HibernateException {
// if( o == null){
// return null;
// }
// // Not a true deep copy but since the map contains immutable Strings, it's fine.
// return new HashMap<String, String>((Map<String, String>) o);
// }
//
// public Serializable disassemble(Object o) throws HibernateException {
// return (Serializable) o;
// }
//
// @SuppressWarnings("deprecation")
// public boolean equals(Object o1, Object o2) throws HibernateException {
// // deprecated in Java 7
// return ObjectUtils.equals(o1, o2);
// }
//
// public int hashCode(Object o) throws HibernateException {
// return o.hashCode();
// }
//
// public boolean isMutable() {
// return true;
// }
//
// public Object replace(Object original, Object target, Object owner) throws HibernateException {
// return original;
// }
//
// public Class<?> returnedClass() {
// return Map.class;
// }
//
// public int[] sqlTypes() {
// return new int[] { Types.OTHER };
// }
//
// @Override
// public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
// if(rs.getString(names[0]) == null){
// return null;
// }
// return rs.getObject(names[0]);
// }
//
// @Override
// public void nullSafeSet(PreparedStatement ps, Object obj, int index, SessionImplementor session) throws HibernateException, SQLException {
// if (obj == null) {
// ps.setNull(index, Types.OTHER);
// return;
// }
// // can't use ps.setObject(index, obj, Types.OTHER) for now
// // see https://github.com/pgjdbc/pgjdbc/issues/199
// ps.setObject(index, obj);
// }
// }
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceExtensionModel.java
import java.util.Map;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import net.canadensys.databaseutils.hibernate.KeyValueType;
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
package net.canadensys.dataportal.occurrence.model;
/**
* Model containing data related to a DarwinCore occurrence extension. Data are stored in a key/value map allowing to abstract specific extension columns.
* @author cgendreau
*
*/
@Entity
@Table(name = "occurrence_extension") | @TypeDefs( {@TypeDef( name= "KeyValueType", typeClass = KeyValueType.class)}) |
Canadensys/canadensys-data-access | src/main/java/net/canadensys/query/sort/SearchSortPart.java | // Path: src/main/java/net/canadensys/query/OrderEnum.java
// public enum OrderEnum {
// ASC,DESC;
// }
| import net.canadensys.query.OrderEnum; | package net.canadensys.query.sort;
/**
* SearchSortPart represents the sorting part of a search query and is not tied to a specific technology.
* The main usage is to translate a sort options of a search query received via URL parameters.
* @author canadensys
*
*/
public class SearchSortPart {
private Integer pageNumber;
private Integer pageSize;
private String orderByColumn; | // Path: src/main/java/net/canadensys/query/OrderEnum.java
// public enum OrderEnum {
// ASC,DESC;
// }
// Path: src/main/java/net/canadensys/query/sort/SearchSortPart.java
import net.canadensys.query.OrderEnum;
package net.canadensys.query.sort;
/**
* SearchSortPart represents the sorting part of a search query and is not tied to a specific technology.
* The main usage is to translate a sort options of a search query received via URL parameters.
* @author canadensys
*
*/
public class SearchSortPart {
private Integer pageNumber;
private Integer pageSize;
private String orderByColumn; | private OrderEnum order; |
Canadensys/canadensys-data-access | src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAO.java | // Path: src/main/java/net/canadensys/dataportal/occurrence/model/UniqueValuesModel.java
// @Entity
// @Table(name = "unique_values")
// public class UniqueValuesModel {
//
// @Id
// private int id;
//
// @Column(name = "key")
// private String key;
//
// @Column(name = "occurrence_count")
// private int occurrence_count;
//
// @Column(name = "value")
// private String value;
//
// @Column(name = "unaccented_value")
// private String unaccented_value;
//
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public String getKey() {
// return key;
// }
// public void setKey(String key) {
// this.key = key;
// }
//
// public int getOccurrence_count() {
// return occurrence_count;
// }
// public void setOccurrence_count(int occurrence_count) {
// this.occurrence_count = occurrence_count;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getUnaccented_value() {
// return unaccented_value;
// }
// public void setUnaccented_value(String unaccented_value) {
// this.unaccented_value = unaccented_value;
// }
// }
| import java.util.List;
import net.canadensys.dataportal.occurrence.model.UniqueValuesModel; | package net.canadensys.dataportal.occurrence.dao;
/**
* Interface to add a AutoComplete feature to some occurrence data.
* @author canadensys
*
*/
public interface OccurrenceAutoCompleteDAO {
/**
* Returns suggestions as JSON string for a field and a current value.
* @param field
* @param currValue
* @param useSanitizedValue compare with sanitized value instead of real value
* @return result as JSON string
*/
public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue);
/**
* Returns all possible values as UniqueValuesModel list.
* @param field
* @return
*/ | // Path: src/main/java/net/canadensys/dataportal/occurrence/model/UniqueValuesModel.java
// @Entity
// @Table(name = "unique_values")
// public class UniqueValuesModel {
//
// @Id
// private int id;
//
// @Column(name = "key")
// private String key;
//
// @Column(name = "occurrence_count")
// private int occurrence_count;
//
// @Column(name = "value")
// private String value;
//
// @Column(name = "unaccented_value")
// private String unaccented_value;
//
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public String getKey() {
// return key;
// }
// public void setKey(String key) {
// this.key = key;
// }
//
// public int getOccurrence_count() {
// return occurrence_count;
// }
// public void setOccurrence_count(int occurrence_count) {
// this.occurrence_count = occurrence_count;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getUnaccented_value() {
// return unaccented_value;
// }
// public void setUnaccented_value(String unaccented_value) {
// this.unaccented_value = unaccented_value;
// }
// }
// Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAO.java
import java.util.List;
import net.canadensys.dataportal.occurrence.model.UniqueValuesModel;
package net.canadensys.dataportal.occurrence.dao;
/**
* Interface to add a AutoComplete feature to some occurrence data.
* @author canadensys
*
*/
public interface OccurrenceAutoCompleteDAO {
/**
* Returns suggestions as JSON string for a field and a current value.
* @param field
* @param currValue
* @param useSanitizedValue compare with sanitized value instead of real value
* @return result as JSON string
*/
public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue);
/**
* Returns all possible values as UniqueValuesModel list.
* @param field
* @return
*/ | public List<UniqueValuesModel> getAllPossibleValues(String field); |
Canadensys/canadensys-data-access | src/main/java/net/canadensys/dataportal/vascan/dao/impl/HibernateRegionDAO.java | // Path: src/main/java/net/canadensys/dataportal/vascan/dao/RegionDAO.java
// public interface RegionDAO {
//
// public List<RegionModel> loadAllRegion();
// }
//
// Path: src/main/java/net/canadensys/dataportal/vascan/model/RegionModel.java
// @Entity
// @Table(name="region")
// public class RegionModel{
//
// private int id;
// private String region;
// private String iso3166_1;
// private String iso3166_2;
// private int sort;
//
// @Id
// @GeneratedValue(strategy=GenerationType.AUTO)
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public String getRegion() {
// return region;
// }
// public void setRegion(String region) {
// this.region = region;
// }
//
// public String getIso3166_1() {
// return iso3166_1;
// }
// public void setIso3166_1(String iso3166_1) {
// this.iso3166_1 = iso3166_1;
// }
//
// public String getIso3166_2() {
// return iso3166_2;
// }
// public void setIso3166_2(String iso3166_2) {
// this.iso3166_2 = iso3166_2;
// }
//
// public int getSort() {
// return sort;
// }
// public void setSort(int sort) {
// this.sort = sort;
// }
//
// }
| import java.util.List;
import net.canadensys.dataportal.vascan.dao.RegionDAO;
import net.canadensys.dataportal.vascan.model.RegionModel;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; | package net.canadensys.dataportal.vascan.dao.impl;
/**
* Implementation for accessing region data through Hibernate technology.
* @author canadensys
*
*/
@Repository("regionDAO")
public class HibernateRegionDAO implements RegionDAO{
@Autowired
private SessionFactory sessionFactory;
@SuppressWarnings("unchecked")
@Override | // Path: src/main/java/net/canadensys/dataportal/vascan/dao/RegionDAO.java
// public interface RegionDAO {
//
// public List<RegionModel> loadAllRegion();
// }
//
// Path: src/main/java/net/canadensys/dataportal/vascan/model/RegionModel.java
// @Entity
// @Table(name="region")
// public class RegionModel{
//
// private int id;
// private String region;
// private String iso3166_1;
// private String iso3166_2;
// private int sort;
//
// @Id
// @GeneratedValue(strategy=GenerationType.AUTO)
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public String getRegion() {
// return region;
// }
// public void setRegion(String region) {
// this.region = region;
// }
//
// public String getIso3166_1() {
// return iso3166_1;
// }
// public void setIso3166_1(String iso3166_1) {
// this.iso3166_1 = iso3166_1;
// }
//
// public String getIso3166_2() {
// return iso3166_2;
// }
// public void setIso3166_2(String iso3166_2) {
// this.iso3166_2 = iso3166_2;
// }
//
// public int getSort() {
// return sort;
// }
// public void setSort(int sort) {
// this.sort = sort;
// }
//
// }
// Path: src/main/java/net/canadensys/dataportal/vascan/dao/impl/HibernateRegionDAO.java
import java.util.List;
import net.canadensys.dataportal.vascan.dao.RegionDAO;
import net.canadensys.dataportal.vascan.model.RegionModel;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
package net.canadensys.dataportal.vascan.dao.impl;
/**
* Implementation for accessing region data through Hibernate technology.
* @author canadensys
*
*/
@Repository("regionDAO")
public class HibernateRegionDAO implements RegionDAO{
@Autowired
private SessionFactory sessionFactory;
@SuppressWarnings("unchecked")
@Override | public List<RegionModel> loadAllRegion() { |
Canadensys/canadensys-data-access | src/main/java/net/canadensys/dataportal/occurrence/dao/impl/HibernateOccurrenceExtensionDAO.java | // Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceExtensionDAO.java
// public interface OccurrenceExtensionDAO {
//
// /**
// * Load a OccurrenceExtensionModel from an id
// * @param id
// * @return OccurrenceExtensionModel or null if nothing is found
// */
// public OccurrenceExtensionModel load(Long id);
//
// /**
// * Load all OccurrenceExtensionModel of a certain type linked to a resourceUUID/dwcaId
// * @param extensionType e.g. multimedia
// * @param resourceUUID
// * @param dwcaId
// * @return list of matching OccurrenceExtensionModel or empty list
// */
// public List<OccurrenceExtensionModel> load(String extensionType, String resourceUUID, String dwcaId);
//
// /**
// * Save a OccurrenceExtensionModel
// * @param occurrenceExtensionModel
// * @return success or not
// */
// public boolean save(OccurrenceExtensionModel occurrenceExtensionModel);
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceExtensionModel.java
// @Entity
// @Table(name = "occurrence_extension")
// @TypeDefs( {@TypeDef( name= "KeyValueType", typeClass = KeyValueType.class)})
// public class OccurrenceExtensionModel {
//
// @Id
// private long auto_id;
//
// @NaturalId
// private String dwcaid;
// @NaturalId
// private String sourcefileid;
// @NaturalId
// private String resource_uuid;
//
// private String ext_type;
// private String ext_version;
//
// @Type(type="KeyValueType")
// private Map<String,String> ext_data;
//
// public long getAuto_id() {
// return auto_id;
// }
// public void setAuto_id(long auto_id) {
// this.auto_id = auto_id;
// }
//
// public String getDwcaid() {
// return dwcaid;
// }
// public void setDwcaid(String dwcaid) {
// this.dwcaid = dwcaid;
// }
//
// public String getSourcefileid() {
// return sourcefileid;
// }
// public void setSourcefileid(String sourcefileid) {
// this.sourcefileid = sourcefileid;
// }
//
// public String getResource_uuid() {
// return resource_uuid;
// }
// public void setResource_uuid(String resource_uuid) {
// this.resource_uuid = resource_uuid;
// }
//
// public String getExt_type() {
// return ext_type;
// }
// public void setExt_type(String ext_type) {
// this.ext_type = ext_type;
// }
//
// public String getExt_version() {
// return ext_version;
// }
// public void setExt_version(String ext_version) {
// this.ext_version = ext_version;
// }
//
// public Map<String,String> getExt_data() {
// return ext_data;
// }
// public void setExt_data(Map<String,String> ext_data) {
// this.ext_data = ext_data;
// }
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceFieldConstants.java
// public class OccurrenceFieldConstants {
//
// public static final String DWCA_ID = "dwcaid";
// public static final String SOURCE_FILE_ID = "sourcefileid";
// public static final String RESOURCE_UUID = "resource_uuid";
//
// }
| import java.util.List;
import net.canadensys.dataportal.occurrence.dao.OccurrenceExtensionDAO;
import net.canadensys.dataportal.occurrence.model.OccurrenceExtensionModel;
import net.canadensys.dataportal.occurrence.model.OccurrenceFieldConstants;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; | package net.canadensys.dataportal.occurrence.dao.impl;
/**
* Implementation for accessing occurrence extension data through Hibernate technology.
* @author canadensys
*
*/
@Repository("occurrenceExtensionDAO")
public class HibernateOccurrenceExtensionDAO implements OccurrenceExtensionDAO{
//get log4j handler
private static final Logger LOGGER = Logger.getLogger(HibernateOccurrenceExtensionDAO.class);
private static final String MANAGED_ID = "id";
private static final String EXTENSION_TYPE = "ext_type";
@Autowired
private SessionFactory sessionFactory;
@Override | // Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceExtensionDAO.java
// public interface OccurrenceExtensionDAO {
//
// /**
// * Load a OccurrenceExtensionModel from an id
// * @param id
// * @return OccurrenceExtensionModel or null if nothing is found
// */
// public OccurrenceExtensionModel load(Long id);
//
// /**
// * Load all OccurrenceExtensionModel of a certain type linked to a resourceUUID/dwcaId
// * @param extensionType e.g. multimedia
// * @param resourceUUID
// * @param dwcaId
// * @return list of matching OccurrenceExtensionModel or empty list
// */
// public List<OccurrenceExtensionModel> load(String extensionType, String resourceUUID, String dwcaId);
//
// /**
// * Save a OccurrenceExtensionModel
// * @param occurrenceExtensionModel
// * @return success or not
// */
// public boolean save(OccurrenceExtensionModel occurrenceExtensionModel);
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceExtensionModel.java
// @Entity
// @Table(name = "occurrence_extension")
// @TypeDefs( {@TypeDef( name= "KeyValueType", typeClass = KeyValueType.class)})
// public class OccurrenceExtensionModel {
//
// @Id
// private long auto_id;
//
// @NaturalId
// private String dwcaid;
// @NaturalId
// private String sourcefileid;
// @NaturalId
// private String resource_uuid;
//
// private String ext_type;
// private String ext_version;
//
// @Type(type="KeyValueType")
// private Map<String,String> ext_data;
//
// public long getAuto_id() {
// return auto_id;
// }
// public void setAuto_id(long auto_id) {
// this.auto_id = auto_id;
// }
//
// public String getDwcaid() {
// return dwcaid;
// }
// public void setDwcaid(String dwcaid) {
// this.dwcaid = dwcaid;
// }
//
// public String getSourcefileid() {
// return sourcefileid;
// }
// public void setSourcefileid(String sourcefileid) {
// this.sourcefileid = sourcefileid;
// }
//
// public String getResource_uuid() {
// return resource_uuid;
// }
// public void setResource_uuid(String resource_uuid) {
// this.resource_uuid = resource_uuid;
// }
//
// public String getExt_type() {
// return ext_type;
// }
// public void setExt_type(String ext_type) {
// this.ext_type = ext_type;
// }
//
// public String getExt_version() {
// return ext_version;
// }
// public void setExt_version(String ext_version) {
// this.ext_version = ext_version;
// }
//
// public Map<String,String> getExt_data() {
// return ext_data;
// }
// public void setExt_data(Map<String,String> ext_data) {
// this.ext_data = ext_data;
// }
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceFieldConstants.java
// public class OccurrenceFieldConstants {
//
// public static final String DWCA_ID = "dwcaid";
// public static final String SOURCE_FILE_ID = "sourcefileid";
// public static final String RESOURCE_UUID = "resource_uuid";
//
// }
// Path: src/main/java/net/canadensys/dataportal/occurrence/dao/impl/HibernateOccurrenceExtensionDAO.java
import java.util.List;
import net.canadensys.dataportal.occurrence.dao.OccurrenceExtensionDAO;
import net.canadensys.dataportal.occurrence.model.OccurrenceExtensionModel;
import net.canadensys.dataportal.occurrence.model.OccurrenceFieldConstants;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
package net.canadensys.dataportal.occurrence.dao.impl;
/**
* Implementation for accessing occurrence extension data through Hibernate technology.
* @author canadensys
*
*/
@Repository("occurrenceExtensionDAO")
public class HibernateOccurrenceExtensionDAO implements OccurrenceExtensionDAO{
//get log4j handler
private static final Logger LOGGER = Logger.getLogger(HibernateOccurrenceExtensionDAO.class);
private static final String MANAGED_ID = "id";
private static final String EXTENSION_TYPE = "ext_type";
@Autowired
private SessionFactory sessionFactory;
@Override | public boolean save(OccurrenceExtensionModel occurrenceExtensionModel) { |
Canadensys/canadensys-data-access | src/main/java/net/canadensys/dataportal/occurrence/dao/impl/HibernateOccurrenceExtensionDAO.java | // Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceExtensionDAO.java
// public interface OccurrenceExtensionDAO {
//
// /**
// * Load a OccurrenceExtensionModel from an id
// * @param id
// * @return OccurrenceExtensionModel or null if nothing is found
// */
// public OccurrenceExtensionModel load(Long id);
//
// /**
// * Load all OccurrenceExtensionModel of a certain type linked to a resourceUUID/dwcaId
// * @param extensionType e.g. multimedia
// * @param resourceUUID
// * @param dwcaId
// * @return list of matching OccurrenceExtensionModel or empty list
// */
// public List<OccurrenceExtensionModel> load(String extensionType, String resourceUUID, String dwcaId);
//
// /**
// * Save a OccurrenceExtensionModel
// * @param occurrenceExtensionModel
// * @return success or not
// */
// public boolean save(OccurrenceExtensionModel occurrenceExtensionModel);
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceExtensionModel.java
// @Entity
// @Table(name = "occurrence_extension")
// @TypeDefs( {@TypeDef( name= "KeyValueType", typeClass = KeyValueType.class)})
// public class OccurrenceExtensionModel {
//
// @Id
// private long auto_id;
//
// @NaturalId
// private String dwcaid;
// @NaturalId
// private String sourcefileid;
// @NaturalId
// private String resource_uuid;
//
// private String ext_type;
// private String ext_version;
//
// @Type(type="KeyValueType")
// private Map<String,String> ext_data;
//
// public long getAuto_id() {
// return auto_id;
// }
// public void setAuto_id(long auto_id) {
// this.auto_id = auto_id;
// }
//
// public String getDwcaid() {
// return dwcaid;
// }
// public void setDwcaid(String dwcaid) {
// this.dwcaid = dwcaid;
// }
//
// public String getSourcefileid() {
// return sourcefileid;
// }
// public void setSourcefileid(String sourcefileid) {
// this.sourcefileid = sourcefileid;
// }
//
// public String getResource_uuid() {
// return resource_uuid;
// }
// public void setResource_uuid(String resource_uuid) {
// this.resource_uuid = resource_uuid;
// }
//
// public String getExt_type() {
// return ext_type;
// }
// public void setExt_type(String ext_type) {
// this.ext_type = ext_type;
// }
//
// public String getExt_version() {
// return ext_version;
// }
// public void setExt_version(String ext_version) {
// this.ext_version = ext_version;
// }
//
// public Map<String,String> getExt_data() {
// return ext_data;
// }
// public void setExt_data(Map<String,String> ext_data) {
// this.ext_data = ext_data;
// }
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceFieldConstants.java
// public class OccurrenceFieldConstants {
//
// public static final String DWCA_ID = "dwcaid";
// public static final String SOURCE_FILE_ID = "sourcefileid";
// public static final String RESOURCE_UUID = "resource_uuid";
//
// }
| import java.util.List;
import net.canadensys.dataportal.occurrence.dao.OccurrenceExtensionDAO;
import net.canadensys.dataportal.occurrence.model.OccurrenceExtensionModel;
import net.canadensys.dataportal.occurrence.model.OccurrenceFieldConstants;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; | package net.canadensys.dataportal.occurrence.dao.impl;
/**
* Implementation for accessing occurrence extension data through Hibernate technology.
* @author canadensys
*
*/
@Repository("occurrenceExtensionDAO")
public class HibernateOccurrenceExtensionDAO implements OccurrenceExtensionDAO{
//get log4j handler
private static final Logger LOGGER = Logger.getLogger(HibernateOccurrenceExtensionDAO.class);
private static final String MANAGED_ID = "id";
private static final String EXTENSION_TYPE = "ext_type";
@Autowired
private SessionFactory sessionFactory;
@Override
public boolean save(OccurrenceExtensionModel occurrenceExtensionModel) {
try{
sessionFactory.getCurrentSession().saveOrUpdate(occurrenceExtensionModel);
}
catch (HibernateException e) {
LOGGER.fatal("Couldn't save OccurrenceExtensionModel", e);
return false;
}
return true;
}
@Override
public OccurrenceExtensionModel load(Long id) {
Criteria searchCriteria = sessionFactory.getCurrentSession().createCriteria(OccurrenceExtensionModel.class);
searchCriteria.add(Restrictions.eq(MANAGED_ID, id));
return (OccurrenceExtensionModel)searchCriteria.uniqueResult();
}
@SuppressWarnings("unchecked")
@Override
public List<OccurrenceExtensionModel> load(String extensionType, String resourceUUID, String dwcaId) {
Criteria searchCriteria = sessionFactory.getCurrentSession().createCriteria(OccurrenceExtensionModel.class);
searchCriteria.add(Restrictions.eq(EXTENSION_TYPE, extensionType)); | // Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceExtensionDAO.java
// public interface OccurrenceExtensionDAO {
//
// /**
// * Load a OccurrenceExtensionModel from an id
// * @param id
// * @return OccurrenceExtensionModel or null if nothing is found
// */
// public OccurrenceExtensionModel load(Long id);
//
// /**
// * Load all OccurrenceExtensionModel of a certain type linked to a resourceUUID/dwcaId
// * @param extensionType e.g. multimedia
// * @param resourceUUID
// * @param dwcaId
// * @return list of matching OccurrenceExtensionModel or empty list
// */
// public List<OccurrenceExtensionModel> load(String extensionType, String resourceUUID, String dwcaId);
//
// /**
// * Save a OccurrenceExtensionModel
// * @param occurrenceExtensionModel
// * @return success or not
// */
// public boolean save(OccurrenceExtensionModel occurrenceExtensionModel);
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceExtensionModel.java
// @Entity
// @Table(name = "occurrence_extension")
// @TypeDefs( {@TypeDef( name= "KeyValueType", typeClass = KeyValueType.class)})
// public class OccurrenceExtensionModel {
//
// @Id
// private long auto_id;
//
// @NaturalId
// private String dwcaid;
// @NaturalId
// private String sourcefileid;
// @NaturalId
// private String resource_uuid;
//
// private String ext_type;
// private String ext_version;
//
// @Type(type="KeyValueType")
// private Map<String,String> ext_data;
//
// public long getAuto_id() {
// return auto_id;
// }
// public void setAuto_id(long auto_id) {
// this.auto_id = auto_id;
// }
//
// public String getDwcaid() {
// return dwcaid;
// }
// public void setDwcaid(String dwcaid) {
// this.dwcaid = dwcaid;
// }
//
// public String getSourcefileid() {
// return sourcefileid;
// }
// public void setSourcefileid(String sourcefileid) {
// this.sourcefileid = sourcefileid;
// }
//
// public String getResource_uuid() {
// return resource_uuid;
// }
// public void setResource_uuid(String resource_uuid) {
// this.resource_uuid = resource_uuid;
// }
//
// public String getExt_type() {
// return ext_type;
// }
// public void setExt_type(String ext_type) {
// this.ext_type = ext_type;
// }
//
// public String getExt_version() {
// return ext_version;
// }
// public void setExt_version(String ext_version) {
// this.ext_version = ext_version;
// }
//
// public Map<String,String> getExt_data() {
// return ext_data;
// }
// public void setExt_data(Map<String,String> ext_data) {
// this.ext_data = ext_data;
// }
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/OccurrenceFieldConstants.java
// public class OccurrenceFieldConstants {
//
// public static final String DWCA_ID = "dwcaid";
// public static final String SOURCE_FILE_ID = "sourcefileid";
// public static final String RESOURCE_UUID = "resource_uuid";
//
// }
// Path: src/main/java/net/canadensys/dataportal/occurrence/dao/impl/HibernateOccurrenceExtensionDAO.java
import java.util.List;
import net.canadensys.dataportal.occurrence.dao.OccurrenceExtensionDAO;
import net.canadensys.dataportal.occurrence.model.OccurrenceExtensionModel;
import net.canadensys.dataportal.occurrence.model.OccurrenceFieldConstants;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
package net.canadensys.dataportal.occurrence.dao.impl;
/**
* Implementation for accessing occurrence extension data through Hibernate technology.
* @author canadensys
*
*/
@Repository("occurrenceExtensionDAO")
public class HibernateOccurrenceExtensionDAO implements OccurrenceExtensionDAO{
//get log4j handler
private static final Logger LOGGER = Logger.getLogger(HibernateOccurrenceExtensionDAO.class);
private static final String MANAGED_ID = "id";
private static final String EXTENSION_TYPE = "ext_type";
@Autowired
private SessionFactory sessionFactory;
@Override
public boolean save(OccurrenceExtensionModel occurrenceExtensionModel) {
try{
sessionFactory.getCurrentSession().saveOrUpdate(occurrenceExtensionModel);
}
catch (HibernateException e) {
LOGGER.fatal("Couldn't save OccurrenceExtensionModel", e);
return false;
}
return true;
}
@Override
public OccurrenceExtensionModel load(Long id) {
Criteria searchCriteria = sessionFactory.getCurrentSession().createCriteria(OccurrenceExtensionModel.class);
searchCriteria.add(Restrictions.eq(MANAGED_ID, id));
return (OccurrenceExtensionModel)searchCriteria.uniqueResult();
}
@SuppressWarnings("unchecked")
@Override
public List<OccurrenceExtensionModel> load(String extensionType, String resourceUUID, String dwcaId) {
Criteria searchCriteria = sessionFactory.getCurrentSession().createCriteria(OccurrenceExtensionModel.class);
searchCriteria.add(Restrictions.eq(EXTENSION_TYPE, extensionType)); | searchCriteria.add(Restrictions.eq(OccurrenceFieldConstants.RESOURCE_UUID, resourceUUID)); |
Canadensys/canadensys-data-access | src/main/java/net/canadensys/dataportal/occurrence/dao/impl/HibernateOccurrenceAutoCompleteDAO.java | // Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAO.java
// public interface OccurrenceAutoCompleteDAO {
//
// /**
// * Returns suggestions as JSON string for a field and a current value.
// * @param field
// * @param currValue
// * @param useSanitizedValue compare with sanitized value instead of real value
// * @return result as JSON string
// */
// public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue);
//
// /**
// * Returns all possible values as UniqueValuesModel list.
// * @param field
// * @return
// */
// public List<UniqueValuesModel> getAllPossibleValues(String field);
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/UniqueValuesModel.java
// @Entity
// @Table(name = "unique_values")
// public class UniqueValuesModel {
//
// @Id
// private int id;
//
// @Column(name = "key")
// private String key;
//
// @Column(name = "occurrence_count")
// private int occurrence_count;
//
// @Column(name = "value")
// private String value;
//
// @Column(name = "unaccented_value")
// private String unaccented_value;
//
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public String getKey() {
// return key;
// }
// public void setKey(String key) {
// this.key = key;
// }
//
// public int getOccurrence_count() {
// return occurrence_count;
// }
// public void setOccurrence_count(int occurrence_count) {
// this.occurrence_count = occurrence_count;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getUnaccented_value() {
// return unaccented_value;
// }
// public void setUnaccented_value(String unaccented_value) {
// this.unaccented_value = unaccented_value;
// }
// }
| import java.io.IOException;
import java.util.List;
import net.canadensys.dataportal.occurrence.dao.OccurrenceAutoCompleteDAO;
import net.canadensys.dataportal.occurrence.model.UniqueValuesModel;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper; | package net.canadensys.dataportal.occurrence.dao.impl;
/**
* Implementation for accessing UniqueValuesModel through Hibernate technology.
* @author canadensys
*
*/
@Repository("occDAO")
public class HibernateOccurrenceAutoCompleteDAO implements OccurrenceAutoCompleteDAO{
//get log4j handler
private static final Logger LOGGER = Logger.getLogger(HibernateOccurrenceAutoCompleteDAO.class);
@Autowired
private SessionFactory sessionFactory;
//this object is expensive to create so only create one and reuse it. This object
//is thread safe after configuration.
private ObjectMapper jacksonMapper = new ObjectMapper();
/**
* TODO : get rid of the Wrapper
*/
@Override
public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue) { | // Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAO.java
// public interface OccurrenceAutoCompleteDAO {
//
// /**
// * Returns suggestions as JSON string for a field and a current value.
// * @param field
// * @param currValue
// * @param useSanitizedValue compare with sanitized value instead of real value
// * @return result as JSON string
// */
// public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue);
//
// /**
// * Returns all possible values as UniqueValuesModel list.
// * @param field
// * @return
// */
// public List<UniqueValuesModel> getAllPossibleValues(String field);
//
// }
//
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/UniqueValuesModel.java
// @Entity
// @Table(name = "unique_values")
// public class UniqueValuesModel {
//
// @Id
// private int id;
//
// @Column(name = "key")
// private String key;
//
// @Column(name = "occurrence_count")
// private int occurrence_count;
//
// @Column(name = "value")
// private String value;
//
// @Column(name = "unaccented_value")
// private String unaccented_value;
//
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
//
// public String getKey() {
// return key;
// }
// public void setKey(String key) {
// this.key = key;
// }
//
// public int getOccurrence_count() {
// return occurrence_count;
// }
// public void setOccurrence_count(int occurrence_count) {
// this.occurrence_count = occurrence_count;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getUnaccented_value() {
// return unaccented_value;
// }
// public void setUnaccented_value(String unaccented_value) {
// this.unaccented_value = unaccented_value;
// }
// }
// Path: src/main/java/net/canadensys/dataportal/occurrence/dao/impl/HibernateOccurrenceAutoCompleteDAO.java
import java.io.IOException;
import java.util.List;
import net.canadensys.dataportal.occurrence.dao.OccurrenceAutoCompleteDAO;
import net.canadensys.dataportal.occurrence.model.UniqueValuesModel;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
package net.canadensys.dataportal.occurrence.dao.impl;
/**
* Implementation for accessing UniqueValuesModel through Hibernate technology.
* @author canadensys
*
*/
@Repository("occDAO")
public class HibernateOccurrenceAutoCompleteDAO implements OccurrenceAutoCompleteDAO{
//get log4j handler
private static final Logger LOGGER = Logger.getLogger(HibernateOccurrenceAutoCompleteDAO.class);
@Autowired
private SessionFactory sessionFactory;
//this object is expensive to create so only create one and reuse it. This object
//is thread safe after configuration.
private ObjectMapper jacksonMapper = new ObjectMapper();
/**
* TODO : get rid of the Wrapper
*/
@Override
public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue) { | Criteria suggestionCriteria = sessionFactory.getCurrentSession().createCriteria(UniqueValuesModel.class) |
ow2-proactive/scheduling | scheduler/scheduler-api/src/test/java/org/ow2/proactive/scheduler/common/job/factories/spi/model/validator/AcceptAllValidatorTest.java | // Path: scheduler/scheduler-api/src/main/java/org/ow2/proactive/scheduler/common/job/factories/spi/model/exceptions/ValidationException.java
// public class ValidationException extends Exception {
//
// public ValidationException() {
// super();
// }
//
// public ValidationException(String message) {
// super(message);
// }
//
// public ValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ValidationException(Throwable cause) {
// super(cause);
// }
// }
| import org.junit.Assert;
import org.junit.Test;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.exceptions.ValidationException; | /*
* ProActive Parallel Suite(TM):
* The Open Source library for parallel and distributed
* Workflows & Scheduling, Orchestration, Cloud Automation
* and Big Data Analysis on Enterprise Grids & Clouds.
*
* Copyright (c) 2007 - 2017 ActiveEon
* Contact: contact@activeeon.com
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation: version 3 of
* the License.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* If needed, contact us to obtain a release under GPL Version 2 or 3
* or a different license than the AGPL.
*/
package org.ow2.proactive.scheduler.common.job.factories.spi.model.validator;
public class AcceptAllValidatorTest {
@Test | // Path: scheduler/scheduler-api/src/main/java/org/ow2/proactive/scheduler/common/job/factories/spi/model/exceptions/ValidationException.java
// public class ValidationException extends Exception {
//
// public ValidationException() {
// super();
// }
//
// public ValidationException(String message) {
// super(message);
// }
//
// public ValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ValidationException(Throwable cause) {
// super(cause);
// }
// }
// Path: scheduler/scheduler-api/src/test/java/org/ow2/proactive/scheduler/common/job/factories/spi/model/validator/AcceptAllValidatorTest.java
import org.junit.Assert;
import org.junit.Test;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.exceptions.ValidationException;
/*
* ProActive Parallel Suite(TM):
* The Open Source library for parallel and distributed
* Workflows & Scheduling, Orchestration, Cloud Automation
* and Big Data Analysis on Enterprise Grids & Clouds.
*
* Copyright (c) 2007 - 2017 ActiveEon
* Contact: contact@activeeon.com
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation: version 3 of
* the License.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* If needed, contact us to obtain a release under GPL Version 2 or 3
* or a different license than the AGPL.
*/
package org.ow2.proactive.scheduler.common.job.factories.spi.model.validator;
public class AcceptAllValidatorTest {
@Test | public void testAcceptAll() throws ValidationException { |
ow2-proactive/scheduling | scheduler/scheduler-api/src/test/java/org/ow2/proactive/scheduler/common/job/factories/spi/model/validator/URLValidatorTest.java | // Path: scheduler/scheduler-api/src/main/java/org/ow2/proactive/scheduler/common/job/factories/spi/model/exceptions/ValidationException.java
// public class ValidationException extends Exception {
//
// public ValidationException() {
// super();
// }
//
// public ValidationException(String message) {
// super(message);
// }
//
// public ValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ValidationException(Throwable cause) {
// super(cause);
// }
// }
| import org.junit.Assert;
import org.junit.Test;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.exceptions.ValidationException; | /*
* ProActive Parallel Suite(TM):
* The Open Source library for parallel and distributed
* Workflows & Scheduling, Orchestration, Cloud Automation
* and Big Data Analysis on Enterprise Grids & Clouds.
*
* Copyright (c) 2007 - 2017 ActiveEon
* Contact: contact@activeeon.com
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation: version 3 of
* the License.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* If needed, contact us to obtain a release under GPL Version 2 or 3
* or a different license than the AGPL.
*/
package org.ow2.proactive.scheduler.common.job.factories.spi.model.validator;
public class URLValidatorTest {
@Test | // Path: scheduler/scheduler-api/src/main/java/org/ow2/proactive/scheduler/common/job/factories/spi/model/exceptions/ValidationException.java
// public class ValidationException extends Exception {
//
// public ValidationException() {
// super();
// }
//
// public ValidationException(String message) {
// super(message);
// }
//
// public ValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ValidationException(Throwable cause) {
// super(cause);
// }
// }
// Path: scheduler/scheduler-api/src/test/java/org/ow2/proactive/scheduler/common/job/factories/spi/model/validator/URLValidatorTest.java
import org.junit.Assert;
import org.junit.Test;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.exceptions.ValidationException;
/*
* ProActive Parallel Suite(TM):
* The Open Source library for parallel and distributed
* Workflows & Scheduling, Orchestration, Cloud Automation
* and Big Data Analysis on Enterprise Grids & Clouds.
*
* Copyright (c) 2007 - 2017 ActiveEon
* Contact: contact@activeeon.com
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation: version 3 of
* the License.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* If needed, contact us to obtain a release under GPL Version 2 or 3
* or a different license than the AGPL.
*/
package org.ow2.proactive.scheduler.common.job.factories.spi.model.validator;
public class URLValidatorTest {
@Test | public void testThatValidURLIsOK() throws ValidationException { |
ow2-proactive/scheduling | scheduler/scheduler-api/src/main/java/org/ow2/proactive/scheduler/common/job/factories/spi/model/factory/JSONParserValidator.java | // Path: scheduler/scheduler-api/src/main/java/org/ow2/proactive/scheduler/common/job/factories/spi/model/converter/Converter.java
// public interface Converter<T> {
//
// /**
// * Converts the specified string parameter {@code value} to a given type. If the conversion is impossible,
// * a checked exception that contains the cause is thrown.
// *
// * @param parameterValue the string value to convert.
// * @throws ConversionException if an error occurred during the conversion.
// */
// T convert(String parameterValue) throws ConversionException;
// }
| import org.springframework.expression.ParseException;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.converter.Converter;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.converter.IdentityConverter;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.exceptions.ModelSyntaxException;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.validator.JSONValidator;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.validator.Validator; | /*
* ProActive Parallel Suite(TM):
* The Open Source library for parallel and distributed
* Workflows & Scheduling, Orchestration, Cloud Automation
* and Big Data Analysis on Enterprise Grids & Clouds.
*
* Copyright (c) 2007 - 2017 ActiveEon
* Contact: contact@activeeon.com
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation: version 3 of
* the License.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* If needed, contact us to obtain a release under GPL Version 2 or 3
* or a different license than the AGPL.
*/
package org.ow2.proactive.scheduler.common.job.factories.spi.model.factory;
/**
* @author ActiveEon Team
* @since 06/03/2019
*/
public class JSONParserValidator extends BaseParserValidator<String> {
public JSONParserValidator(String model) throws ModelSyntaxException {
super(model, ModelType.JSON);
}
@Override | // Path: scheduler/scheduler-api/src/main/java/org/ow2/proactive/scheduler/common/job/factories/spi/model/converter/Converter.java
// public interface Converter<T> {
//
// /**
// * Converts the specified string parameter {@code value} to a given type. If the conversion is impossible,
// * a checked exception that contains the cause is thrown.
// *
// * @param parameterValue the string value to convert.
// * @throws ConversionException if an error occurred during the conversion.
// */
// T convert(String parameterValue) throws ConversionException;
// }
// Path: scheduler/scheduler-api/src/main/java/org/ow2/proactive/scheduler/common/job/factories/spi/model/factory/JSONParserValidator.java
import org.springframework.expression.ParseException;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.converter.Converter;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.converter.IdentityConverter;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.exceptions.ModelSyntaxException;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.validator.JSONValidator;
import org.ow2.proactive.scheduler.common.job.factories.spi.model.validator.Validator;
/*
* ProActive Parallel Suite(TM):
* The Open Source library for parallel and distributed
* Workflows & Scheduling, Orchestration, Cloud Automation
* and Big Data Analysis on Enterprise Grids & Clouds.
*
* Copyright (c) 2007 - 2017 ActiveEon
* Contact: contact@activeeon.com
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation: version 3 of
* the License.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* If needed, contact us to obtain a release under GPL Version 2 or 3
* or a different license than the AGPL.
*/
package org.ow2.proactive.scheduler.common.job.factories.spi.model.factory;
/**
* @author ActiveEon Team
* @since 06/03/2019
*/
public class JSONParserValidator extends BaseParserValidator<String> {
public JSONParserValidator(String model) throws ModelSyntaxException {
super(model, ModelType.JSON);
}
@Override | protected Converter<String> createConverter(String model) throws ModelSyntaxException { |
trichner/libschem | src/main/java/ch/n1b/worldedit/schematic/schematic/SchematicFormat.java | // Path: src/main/java/ch/n1b/worldedit/schematic/block/BaseBlock.java
// public class BaseBlock extends Block {
//
// /**
// * Construct the block with its type, with default data value 0.
// *
// * @param type type ID of block
// */
// public BaseBlock(int type) {
// this(type, 0);
// }
//
// /**
// * Construct the block with its type and data.
// *
// * @param type type ID of block
// * @param data data value
// */
// public BaseBlock(int type, int data) {
// super(type, data);
// }
//
// /**
// * Get the type of block.
// *
// * @return the type
// */
// public int getType() {
// return getId();
// }
//
// /**
// * Set the type of block.
// *
// * @param type the type to set
// */
// public void setType(int type) {
// setId(type);
// }
//
// /**
// * Returns true if it's air.
// *
// * @return if air
// */
// public boolean isAir() {
// return getType() == BlockID.AIR;
// }
//
// /**
// * Rotate this block 90 degrees.
// *
// * @return new data value
// */
// public int rotate90() {
// int newData = BlockData.rotate90(getType(), getData());
// setData(newData);
// return newData;
// }
//
// /**
// * Rotate this block -90 degrees.
// *
// * @return new data value
// */
// public int rotate90Reverse() {
// int newData = BlockData.rotate90Reverse(getType(), getData());
// setData((short) newData);
// return newData;
// }
//
// /**
// * Checks whether the type ID and data value are equal.
// */
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof BaseBlock)) {
// return false;
// }
//
// final BaseBlock otherBlock = (BaseBlock) o;
// if (getType() != otherBlock.getType()) {
// return false;
// }
//
// return getData() == otherBlock.getData();
// }
// }
//
// Path: src/main/java/ch/n1b/worldedit/schematic/data/DataException.java
// public class DataException extends Exception {
// private static final long serialVersionUID = 5806521052111023788L;
//
// public DataException(String msg) {
// super(msg);
// }
//
// public DataException() {
// super();
// }
// }
| import java.util.Map;
import java.util.Set;
import ch.n1b.worldedit.schematic.block.BaseBlock;
import ch.n1b.worldedit.schematic.data.DataException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List; | }
private final String name;
private final String[] lookupNames;
protected SchematicFormat(String name, String... lookupNames) {
this.name = name;
List<String> registeredLookupNames = new ArrayList<String>(lookupNames.length);
for (int i = 0; i < lookupNames.length; ++i) {
if (i == 0 || !SCHEMATIC_FORMATS.containsKey(lookupNames[i].toLowerCase())) {
SCHEMATIC_FORMATS.put(lookupNames[i].toLowerCase(), this);
registeredLookupNames.add(lookupNames[i].toLowerCase());
}
}
this.lookupNames = registeredLookupNames.toArray(new String[registeredLookupNames.size()]);
}
/**
* Gets the official/display name for this schematic format
*
* @return The display name for this schematic format
*/
public String getName() {
return name;
}
public String[] getLookupNames() {
return lookupNames;
}
| // Path: src/main/java/ch/n1b/worldedit/schematic/block/BaseBlock.java
// public class BaseBlock extends Block {
//
// /**
// * Construct the block with its type, with default data value 0.
// *
// * @param type type ID of block
// */
// public BaseBlock(int type) {
// this(type, 0);
// }
//
// /**
// * Construct the block with its type and data.
// *
// * @param type type ID of block
// * @param data data value
// */
// public BaseBlock(int type, int data) {
// super(type, data);
// }
//
// /**
// * Get the type of block.
// *
// * @return the type
// */
// public int getType() {
// return getId();
// }
//
// /**
// * Set the type of block.
// *
// * @param type the type to set
// */
// public void setType(int type) {
// setId(type);
// }
//
// /**
// * Returns true if it's air.
// *
// * @return if air
// */
// public boolean isAir() {
// return getType() == BlockID.AIR;
// }
//
// /**
// * Rotate this block 90 degrees.
// *
// * @return new data value
// */
// public int rotate90() {
// int newData = BlockData.rotate90(getType(), getData());
// setData(newData);
// return newData;
// }
//
// /**
// * Rotate this block -90 degrees.
// *
// * @return new data value
// */
// public int rotate90Reverse() {
// int newData = BlockData.rotate90Reverse(getType(), getData());
// setData((short) newData);
// return newData;
// }
//
// /**
// * Checks whether the type ID and data value are equal.
// */
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof BaseBlock)) {
// return false;
// }
//
// final BaseBlock otherBlock = (BaseBlock) o;
// if (getType() != otherBlock.getType()) {
// return false;
// }
//
// return getData() == otherBlock.getData();
// }
// }
//
// Path: src/main/java/ch/n1b/worldedit/schematic/data/DataException.java
// public class DataException extends Exception {
// private static final long serialVersionUID = 5806521052111023788L;
//
// public DataException(String msg) {
// super(msg);
// }
//
// public DataException() {
// super();
// }
// }
// Path: src/main/java/ch/n1b/worldedit/schematic/schematic/SchematicFormat.java
import java.util.Map;
import java.util.Set;
import ch.n1b.worldedit.schematic.block.BaseBlock;
import ch.n1b.worldedit.schematic.data.DataException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
}
private final String name;
private final String[] lookupNames;
protected SchematicFormat(String name, String... lookupNames) {
this.name = name;
List<String> registeredLookupNames = new ArrayList<String>(lookupNames.length);
for (int i = 0; i < lookupNames.length; ++i) {
if (i == 0 || !SCHEMATIC_FORMATS.containsKey(lookupNames[i].toLowerCase())) {
SCHEMATIC_FORMATS.put(lookupNames[i].toLowerCase(), this);
registeredLookupNames.add(lookupNames[i].toLowerCase());
}
}
this.lookupNames = registeredLookupNames.toArray(new String[registeredLookupNames.size()]);
}
/**
* Gets the official/display name for this schematic format
*
* @return The display name for this schematic format
*/
public String getName() {
return name;
}
public String[] getLookupNames() {
return lookupNames;
}
| public BaseBlock getBlockForId(int id, short data) { |
trichner/libschem | src/main/java/ch/n1b/worldedit/schematic/schematic/SchematicFormat.java | // Path: src/main/java/ch/n1b/worldedit/schematic/block/BaseBlock.java
// public class BaseBlock extends Block {
//
// /**
// * Construct the block with its type, with default data value 0.
// *
// * @param type type ID of block
// */
// public BaseBlock(int type) {
// this(type, 0);
// }
//
// /**
// * Construct the block with its type and data.
// *
// * @param type type ID of block
// * @param data data value
// */
// public BaseBlock(int type, int data) {
// super(type, data);
// }
//
// /**
// * Get the type of block.
// *
// * @return the type
// */
// public int getType() {
// return getId();
// }
//
// /**
// * Set the type of block.
// *
// * @param type the type to set
// */
// public void setType(int type) {
// setId(type);
// }
//
// /**
// * Returns true if it's air.
// *
// * @return if air
// */
// public boolean isAir() {
// return getType() == BlockID.AIR;
// }
//
// /**
// * Rotate this block 90 degrees.
// *
// * @return new data value
// */
// public int rotate90() {
// int newData = BlockData.rotate90(getType(), getData());
// setData(newData);
// return newData;
// }
//
// /**
// * Rotate this block -90 degrees.
// *
// * @return new data value
// */
// public int rotate90Reverse() {
// int newData = BlockData.rotate90Reverse(getType(), getData());
// setData((short) newData);
// return newData;
// }
//
// /**
// * Checks whether the type ID and data value are equal.
// */
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof BaseBlock)) {
// return false;
// }
//
// final BaseBlock otherBlock = (BaseBlock) o;
// if (getType() != otherBlock.getType()) {
// return false;
// }
//
// return getData() == otherBlock.getData();
// }
// }
//
// Path: src/main/java/ch/n1b/worldedit/schematic/data/DataException.java
// public class DataException extends Exception {
// private static final long serialVersionUID = 5806521052111023788L;
//
// public DataException(String msg) {
// super(msg);
// }
//
// public DataException() {
// super();
// }
// }
| import java.util.Map;
import java.util.Set;
import ch.n1b.worldedit.schematic.block.BaseBlock;
import ch.n1b.worldedit.schematic.data.DataException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List; | case BlockID.BURNING_FURNACE:
block = new FurnaceBlock(id, data);
break;
case BlockID.DISPENSER:
block = new DispenserBlock(data);
break;
case BlockID.MOB_SPAWNER:
block = new MobSpawnerBlock(id);
break;
case BlockID.NOTE_BLOCK:
block = new NoteBlock(data);
break;*/
default:
block = new BaseBlock(id, data);
break;
}
return block;
}
/**
* Loads a schematic from the given file into a CuboidClipboard
* @param file The file to load from
* @return The CuboidClipboard containing the contents of this schematic
* @throws IOException If an error occurs while reading data
* @throws DataException if data is not in the correct format
*/ | // Path: src/main/java/ch/n1b/worldedit/schematic/block/BaseBlock.java
// public class BaseBlock extends Block {
//
// /**
// * Construct the block with its type, with default data value 0.
// *
// * @param type type ID of block
// */
// public BaseBlock(int type) {
// this(type, 0);
// }
//
// /**
// * Construct the block with its type and data.
// *
// * @param type type ID of block
// * @param data data value
// */
// public BaseBlock(int type, int data) {
// super(type, data);
// }
//
// /**
// * Get the type of block.
// *
// * @return the type
// */
// public int getType() {
// return getId();
// }
//
// /**
// * Set the type of block.
// *
// * @param type the type to set
// */
// public void setType(int type) {
// setId(type);
// }
//
// /**
// * Returns true if it's air.
// *
// * @return if air
// */
// public boolean isAir() {
// return getType() == BlockID.AIR;
// }
//
// /**
// * Rotate this block 90 degrees.
// *
// * @return new data value
// */
// public int rotate90() {
// int newData = BlockData.rotate90(getType(), getData());
// setData(newData);
// return newData;
// }
//
// /**
// * Rotate this block -90 degrees.
// *
// * @return new data value
// */
// public int rotate90Reverse() {
// int newData = BlockData.rotate90Reverse(getType(), getData());
// setData((short) newData);
// return newData;
// }
//
// /**
// * Checks whether the type ID and data value are equal.
// */
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof BaseBlock)) {
// return false;
// }
//
// final BaseBlock otherBlock = (BaseBlock) o;
// if (getType() != otherBlock.getType()) {
// return false;
// }
//
// return getData() == otherBlock.getData();
// }
// }
//
// Path: src/main/java/ch/n1b/worldedit/schematic/data/DataException.java
// public class DataException extends Exception {
// private static final long serialVersionUID = 5806521052111023788L;
//
// public DataException(String msg) {
// super(msg);
// }
//
// public DataException() {
// super();
// }
// }
// Path: src/main/java/ch/n1b/worldedit/schematic/schematic/SchematicFormat.java
import java.util.Map;
import java.util.Set;
import ch.n1b.worldedit.schematic.block.BaseBlock;
import ch.n1b.worldedit.schematic.data.DataException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
case BlockID.BURNING_FURNACE:
block = new FurnaceBlock(id, data);
break;
case BlockID.DISPENSER:
block = new DispenserBlock(data);
break;
case BlockID.MOB_SPAWNER:
block = new MobSpawnerBlock(id);
break;
case BlockID.NOTE_BLOCK:
block = new NoteBlock(data);
break;*/
default:
block = new BaseBlock(id, data);
break;
}
return block;
}
/**
* Loads a schematic from the given file into a CuboidClipboard
* @param file The file to load from
* @return The CuboidClipboard containing the contents of this schematic
* @throws IOException If an error occurs while reading data
* @throws DataException if data is not in the correct format
*/ | public abstract Cuboid load(File file) throws IOException, DataException; |
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/settings/SettingBoolean.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
| import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
| package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingBoolean extends Setting {
public final boolean defaultValue;
public boolean value;
public SettingBoolean(String ID, boolean defaultValue) {
super(ID);
this.defaultValue = defaultValue;
this.value = defaultValue;
}
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/settings/SettingBoolean.java
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingBoolean extends Setting {
public final boolean defaultValue;
public boolean value;
public SettingBoolean(String ID, boolean defaultValue) {
super(ID);
this.defaultValue = defaultValue;
this.value = defaultValue;
}
| public SettingBoolean(String ID, HudElementType type, boolean defaultValue) {
|
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/settings/SettingFloat.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
| import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.math.MathHelper;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
| package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingFloat extends Setting {
public final float defaultValue;
public float value;
public final float minValue;
public final float maxValue;
public final float step;
public SettingFloat(String ID, float defaultValue, float minValue, float maxValue, float step) {
super(ID);
this.defaultValue = defaultValue;
this.value = defaultValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.step = step;
}
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/settings/SettingFloat.java
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.math.MathHelper;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingFloat extends Setting {
public final float defaultValue;
public float value;
public final float minValue;
public final float maxValue;
public final float step;
public SettingFloat(String ID, float defaultValue, float minValue, float maxValue, float step) {
super(ID);
this.defaultValue = defaultValue;
this.value = defaultValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.step = step;
}
| public SettingFloat(String ID, HudElementType type, float defaultValue, float minValue, float maxValue, float step) {
|
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/settings/SettingInteger.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
| import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
| package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingInteger extends Setting {
public final int defaultValue;
public int value;
public final int minValue;
public final int maxValue;
public SettingInteger(String ID, int defaultValue, int minValue, int maxValue) {
super(ID);
this.defaultValue = defaultValue;
this.value = defaultValue;
this.minValue = minValue;
this.maxValue = maxValue;
}
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/settings/SettingInteger.java
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingInteger extends Setting {
public final int defaultValue;
public int value;
public final int minValue;
public final int maxValue;
public SettingInteger(String ID, int defaultValue, int minValue, int maxValue) {
super(ID);
this.defaultValue = defaultValue;
this.value = defaultValue;
this.minValue = minValue;
this.maxValue = maxValue;
}
| public SettingInteger(String ID, HudElementType type, int defaultValue, int minValue, int maxValue) {
|
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/gui/TextFieldWidgetMod.java | // Path: src/main/java/net/spellcraftgaming/rpghud/main/ModRPGHud.java
// @Environment(EnvType.CLIENT)
//
// public class ModRPGHud implements ClientModInitializer{
// public final String MODID = "rpg-hud";
//
// public static ModRPGHud instance;
//
// public static boolean[] renderDetailsAgain = { false, false, false };
//
// public static int screenOffset = 0;
//
// public Settings settings;
//
// /** Map of all registered HUDs */
// public Map<String, Hud> huds = new LinkedHashMap<String, Hud>();
//
// public void onInitializeClient()
// {
// instance = this;
// this.settings = new Settings();
// this.registerHud(new HudVanilla(MinecraftClient.getInstance(), "vanilla", "Vanilla"));
// this.registerHud(new HudSimple(MinecraftClient.getInstance(), "simple", "Simplified"));
// this.registerHud(new HudDefault(MinecraftClient.getInstance(), "default", "Default"));
// this.registerHud(new HudExtendedWidget(MinecraftClient.getInstance(), "extended", "Extended Widget"));
// this.registerHud(new HudFullTexture(MinecraftClient.getInstance(), "texture", "Full Texture"));
// //this.registerHud(new HudHotbarWidget(MinecraftClient.getInstance(), "hotbar", "Hotbar Widget"));
// this.registerHud(new HudModern(MinecraftClient.getInstance(), "modern", "Modern Style"));
//
// if (!isHudKeyValid(this.settings.getStringValue(Settings.hud_type))) {
// this.settings.setSetting(Settings.hud_type, "vanilla");
// }
// new RenderOverlay();
// if (isClass("io.github.prospector.modmenu.ModMenu")) screenOffset = 12;
// }
//
// /**
// * Register a new HUD
// *
// * @param hud
// * the hud to be registered
// */
// public void registerHud(Hud hud) {
// this.huds.put(hud.getHudKey(), hud);
// }
//
// /** Returns the active HUD */
// public Hud getActiveHud() {
// return this.huds.get(this.settings.getStringValue(Settings.hud_type));
// }
//
// /** Returns the vanilla HUD */
// public Hud getVanillaHud() {
// return this.huds.get("vanilla");
// }
//
// public boolean isVanillaHud() {
// return this.settings.getStringValue(Settings.hud_type) == "vanilla";
// }
//
// /** Checks if a Hud with the specified key is registered */
// public boolean isHudKeyValid(String key) {
// return this.huds.containsKey(key);
// }
//
// public static boolean isClass(String className) {
// try {
// Class.forName(className);
// return true;
// } catch (ClassNotFoundException e) {
// return false;
// }
// }
// }
| import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.Text;
import net.spellcraftgaming.rpghud.main.ModRPGHud;
| package net.spellcraftgaming.rpghud.gui;
@Environment(EnvType.CLIENT)
public class TextFieldWidgetMod extends TextFieldWidget {
/** Variable to contain the (possible) setting of this button */
public final String enumOptions;
/** Array that contains the tooltip of this button */
private String[] tooltip;
private ValueType type;
public TextFieldWidgetMod(TextRenderer fontIn, ValueType type, String setting, int xIn, int yIn, int widthIn, int heightIn, Text msg) {
super(fontIn, xIn, yIn, widthIn, heightIn, msg);
this.type = type;
this.enumOptions = setting;
}
public TextFieldWidgetMod(TextRenderer fontIn, ValueType type, int xIn, int yIn, int widthIn, int heightIn, Text msg) {
super(fontIn, xIn, yIn, widthIn, heightIn, msg);
this.type = type;
this.enumOptions = null;
}
public ValueType getValueType() {
return type;
}
public enum ValueType{
DOUBLE,
POSITION;
}
@Override
public void tick() {
super.tick();
}
/**
* Sets the tooltip of this button. Should be appended at the constructor.
*
* @param tooltip
* The String which'll be the button's tooltip. Line breaks are
* managed via the /n symbol combination.
* @return the button
*/
public TextFieldWidgetMod setTooltip(String tooltip) {
this.tooltip = tooltip.split("/n");
return this;
}
/**
* Sets the tooltip to the one the setting of hits button contain.
*
* @return the button
*/
public TextFieldWidgetMod setTooltip() {
if (this.enumOptions != null)
| // Path: src/main/java/net/spellcraftgaming/rpghud/main/ModRPGHud.java
// @Environment(EnvType.CLIENT)
//
// public class ModRPGHud implements ClientModInitializer{
// public final String MODID = "rpg-hud";
//
// public static ModRPGHud instance;
//
// public static boolean[] renderDetailsAgain = { false, false, false };
//
// public static int screenOffset = 0;
//
// public Settings settings;
//
// /** Map of all registered HUDs */
// public Map<String, Hud> huds = new LinkedHashMap<String, Hud>();
//
// public void onInitializeClient()
// {
// instance = this;
// this.settings = new Settings();
// this.registerHud(new HudVanilla(MinecraftClient.getInstance(), "vanilla", "Vanilla"));
// this.registerHud(new HudSimple(MinecraftClient.getInstance(), "simple", "Simplified"));
// this.registerHud(new HudDefault(MinecraftClient.getInstance(), "default", "Default"));
// this.registerHud(new HudExtendedWidget(MinecraftClient.getInstance(), "extended", "Extended Widget"));
// this.registerHud(new HudFullTexture(MinecraftClient.getInstance(), "texture", "Full Texture"));
// //this.registerHud(new HudHotbarWidget(MinecraftClient.getInstance(), "hotbar", "Hotbar Widget"));
// this.registerHud(new HudModern(MinecraftClient.getInstance(), "modern", "Modern Style"));
//
// if (!isHudKeyValid(this.settings.getStringValue(Settings.hud_type))) {
// this.settings.setSetting(Settings.hud_type, "vanilla");
// }
// new RenderOverlay();
// if (isClass("io.github.prospector.modmenu.ModMenu")) screenOffset = 12;
// }
//
// /**
// * Register a new HUD
// *
// * @param hud
// * the hud to be registered
// */
// public void registerHud(Hud hud) {
// this.huds.put(hud.getHudKey(), hud);
// }
//
// /** Returns the active HUD */
// public Hud getActiveHud() {
// return this.huds.get(this.settings.getStringValue(Settings.hud_type));
// }
//
// /** Returns the vanilla HUD */
// public Hud getVanillaHud() {
// return this.huds.get("vanilla");
// }
//
// public boolean isVanillaHud() {
// return this.settings.getStringValue(Settings.hud_type) == "vanilla";
// }
//
// /** Checks if a Hud with the specified key is registered */
// public boolean isHudKeyValid(String key) {
// return this.huds.containsKey(key);
// }
//
// public static boolean isClass(String className) {
// try {
// Class.forName(className);
// return true;
// } catch (ClassNotFoundException e) {
// return false;
// }
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/gui/TextFieldWidgetMod.java
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.Text;
import net.spellcraftgaming.rpghud.main.ModRPGHud;
package net.spellcraftgaming.rpghud.gui;
@Environment(EnvType.CLIENT)
public class TextFieldWidgetMod extends TextFieldWidget {
/** Variable to contain the (possible) setting of this button */
public final String enumOptions;
/** Array that contains the tooltip of this button */
private String[] tooltip;
private ValueType type;
public TextFieldWidgetMod(TextRenderer fontIn, ValueType type, String setting, int xIn, int yIn, int widthIn, int heightIn, Text msg) {
super(fontIn, xIn, yIn, widthIn, heightIn, msg);
this.type = type;
this.enumOptions = setting;
}
public TextFieldWidgetMod(TextRenderer fontIn, ValueType type, int xIn, int yIn, int widthIn, int heightIn, Text msg) {
super(fontIn, xIn, yIn, widthIn, heightIn, msg);
this.type = type;
this.enumOptions = null;
}
public ValueType getValueType() {
return type;
}
public enum ValueType{
DOUBLE,
POSITION;
}
@Override
public void tick() {
super.tick();
}
/**
* Sets the tooltip of this button. Should be appended at the constructor.
*
* @param tooltip
* The String which'll be the button's tooltip. Line breaks are
* managed via the /n symbol combination.
* @return the button
*/
public TextFieldWidgetMod setTooltip(String tooltip) {
this.tooltip = tooltip.split("/n");
return this;
}
/**
* Sets the tooltip to the one the setting of hits button contain.
*
* @return the button
*/
public TextFieldWidgetMod setTooltip() {
if (this.enumOptions != null)
| return setTooltip(ModRPGHud.instance.settings.getSetting(this.enumOptions).getTooltip());
|
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/settings/SettingPosition.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
| import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType; | package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingPosition extends Setting{
public final int defaultX, defaultY;
public int x, y;
public SettingPosition(String ID, int x, int y) {
super(ID);
this.defaultX = x;
this.x = x;
this.defaultY = y;
this.y = y;
}
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/settings/SettingPosition.java
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingPosition extends Setting{
public final int defaultX, defaultY;
public int x, y;
public SettingPosition(String ID, int x, int y) {
super(ID);
this.defaultX = x;
this.x = x;
this.defaultY = y;
this.y = y;
}
| public SettingPosition(String ID, HudElementType type, int x, int y) { |
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/settings/Setting.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
| import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.resource.language.I18n;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
| package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public abstract class Setting {
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/settings/Setting.java
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.resource.language.I18n;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public abstract class Setting {
| public final HudElementType associatedType;
|
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/settings/SettingBooleanDebug.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
| import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.resource.language.I18n;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
| package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingBooleanDebug extends SettingBoolean{
public static final String force_render = "force_render";
public static final String render_vanilla = "render_vanilla";
public static final String prevent_event = "prevent_event";
public static final String prevent_element_render = "prevent_element_render";
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/settings/SettingBooleanDebug.java
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.resource.language.I18n;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingBooleanDebug extends SettingBoolean{
public static final String force_render = "force_render";
public static final String render_vanilla = "render_vanilla";
public static final String prevent_event = "prevent_event";
public static final String prevent_element_render = "prevent_element_render";
| public SettingBooleanDebug(String ID, HudElementType type, boolean defaultValue) {
|
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/settings/SettingColor.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
| import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
| package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingColor extends Setting{
public final int defaultColor;
public int color;
public SettingColor(String ID, int color) {
super(ID);
this.defaultColor = color;
this.color = color;
}
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/settings/SettingColor.java
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingColor extends Setting{
public final int defaultColor;
public int color;
public SettingColor(String ID, int color) {
super(ID);
this.defaultColor = color;
this.color = color;
}
| public SettingColor(String ID, HudElementType type, int color) {
|
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/settings/SettingString.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
| import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
| package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingString extends Setting {
public final int defaultValueId;
public int valueId;
public final String[] possibleValues;
public SettingString(String ID, int defaultValueId, String[] possibleValues) {
super(ID);
this.possibleValues = possibleValues;
this.defaultValueId = defaultValueId;
this.valueId = defaultValueId;
}
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/settings/SettingString.java
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingString extends Setting {
public final int defaultValueId;
public int valueId;
public final String[] possibleValues;
public SettingString(String ID, int defaultValueId, String[] possibleValues) {
super(ID);
this.possibleValues = possibleValues;
this.defaultValueId = defaultValueId;
this.valueId = defaultValueId;
}
| public SettingString(String ID, HudElementType type, int defaultValueId, String[] possibleValues) {
|
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/settings/SettingDouble.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
| import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.math.MathHelper;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
| package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingDouble extends Setting {
public final double defaultValue;
public double value;
public final double minValue;
public final double maxValue;
public final double step;
public SettingDouble(String ID, double defaultValue, double minValue, double maxValue, double step) {
super(ID);
this.defaultValue = defaultValue;
this.value = defaultValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.step = step;
}
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/settings/SettingDouble.java
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.math.MathHelper;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingDouble extends Setting {
public final double defaultValue;
public double value;
public final double minValue;
public final double maxValue;
public final double step;
public SettingDouble(String ID, double defaultValue, double minValue, double maxValue, double step) {
super(ID);
this.defaultValue = defaultValue;
this.value = defaultValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.step = step;
}
| public SettingDouble(String ID, HudElementType type, double defaultValue, double minValue, double maxValue, double step) {
|
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/settings/SettingHudType.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
//
// Path: src/main/java/net/spellcraftgaming/rpghud/main/ModRPGHud.java
// @Environment(EnvType.CLIENT)
//
// public class ModRPGHud implements ClientModInitializer{
// public final String MODID = "rpg-hud";
//
// public static ModRPGHud instance;
//
// public static boolean[] renderDetailsAgain = { false, false, false };
//
// public static int screenOffset = 0;
//
// public Settings settings;
//
// /** Map of all registered HUDs */
// public Map<String, Hud> huds = new LinkedHashMap<String, Hud>();
//
// public void onInitializeClient()
// {
// instance = this;
// this.settings = new Settings();
// this.registerHud(new HudVanilla(MinecraftClient.getInstance(), "vanilla", "Vanilla"));
// this.registerHud(new HudSimple(MinecraftClient.getInstance(), "simple", "Simplified"));
// this.registerHud(new HudDefault(MinecraftClient.getInstance(), "default", "Default"));
// this.registerHud(new HudExtendedWidget(MinecraftClient.getInstance(), "extended", "Extended Widget"));
// this.registerHud(new HudFullTexture(MinecraftClient.getInstance(), "texture", "Full Texture"));
// //this.registerHud(new HudHotbarWidget(MinecraftClient.getInstance(), "hotbar", "Hotbar Widget"));
// this.registerHud(new HudModern(MinecraftClient.getInstance(), "modern", "Modern Style"));
//
// if (!isHudKeyValid(this.settings.getStringValue(Settings.hud_type))) {
// this.settings.setSetting(Settings.hud_type, "vanilla");
// }
// new RenderOverlay();
// if (isClass("io.github.prospector.modmenu.ModMenu")) screenOffset = 12;
// }
//
// /**
// * Register a new HUD
// *
// * @param hud
// * the hud to be registered
// */
// public void registerHud(Hud hud) {
// this.huds.put(hud.getHudKey(), hud);
// }
//
// /** Returns the active HUD */
// public Hud getActiveHud() {
// return this.huds.get(this.settings.getStringValue(Settings.hud_type));
// }
//
// /** Returns the vanilla HUD */
// public Hud getVanillaHud() {
// return this.huds.get("vanilla");
// }
//
// public boolean isVanillaHud() {
// return this.settings.getStringValue(Settings.hud_type) == "vanilla";
// }
//
// /** Checks if a Hud with the specified key is registered */
// public boolean isHudKeyValid(String key) {
// return this.huds.containsKey(key);
// }
//
// public static boolean isClass(String className) {
// try {
// Class.forName(className);
// return true;
// } catch (ClassNotFoundException e) {
// return false;
// }
// }
// }
| import java.util.Set;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
import net.spellcraftgaming.rpghud.main.ModRPGHud;
| package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingHudType extends Setting {
public final String defaultValue;
public String value;
public SettingHudType(String ID, String value) {
super(ID);
this.defaultValue = value;
this.value = this.defaultValue;
}
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
//
// Path: src/main/java/net/spellcraftgaming/rpghud/main/ModRPGHud.java
// @Environment(EnvType.CLIENT)
//
// public class ModRPGHud implements ClientModInitializer{
// public final String MODID = "rpg-hud";
//
// public static ModRPGHud instance;
//
// public static boolean[] renderDetailsAgain = { false, false, false };
//
// public static int screenOffset = 0;
//
// public Settings settings;
//
// /** Map of all registered HUDs */
// public Map<String, Hud> huds = new LinkedHashMap<String, Hud>();
//
// public void onInitializeClient()
// {
// instance = this;
// this.settings = new Settings();
// this.registerHud(new HudVanilla(MinecraftClient.getInstance(), "vanilla", "Vanilla"));
// this.registerHud(new HudSimple(MinecraftClient.getInstance(), "simple", "Simplified"));
// this.registerHud(new HudDefault(MinecraftClient.getInstance(), "default", "Default"));
// this.registerHud(new HudExtendedWidget(MinecraftClient.getInstance(), "extended", "Extended Widget"));
// this.registerHud(new HudFullTexture(MinecraftClient.getInstance(), "texture", "Full Texture"));
// //this.registerHud(new HudHotbarWidget(MinecraftClient.getInstance(), "hotbar", "Hotbar Widget"));
// this.registerHud(new HudModern(MinecraftClient.getInstance(), "modern", "Modern Style"));
//
// if (!isHudKeyValid(this.settings.getStringValue(Settings.hud_type))) {
// this.settings.setSetting(Settings.hud_type, "vanilla");
// }
// new RenderOverlay();
// if (isClass("io.github.prospector.modmenu.ModMenu")) screenOffset = 12;
// }
//
// /**
// * Register a new HUD
// *
// * @param hud
// * the hud to be registered
// */
// public void registerHud(Hud hud) {
// this.huds.put(hud.getHudKey(), hud);
// }
//
// /** Returns the active HUD */
// public Hud getActiveHud() {
// return this.huds.get(this.settings.getStringValue(Settings.hud_type));
// }
//
// /** Returns the vanilla HUD */
// public Hud getVanillaHud() {
// return this.huds.get("vanilla");
// }
//
// public boolean isVanillaHud() {
// return this.settings.getStringValue(Settings.hud_type) == "vanilla";
// }
//
// /** Checks if a Hud with the specified key is registered */
// public boolean isHudKeyValid(String key) {
// return this.huds.containsKey(key);
// }
//
// public static boolean isClass(String className) {
// try {
// Class.forName(className);
// return true;
// } catch (ClassNotFoundException e) {
// return false;
// }
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/settings/SettingHudType.java
import java.util.Set;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
import net.spellcraftgaming.rpghud.main.ModRPGHud;
package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingHudType extends Setting {
public final String defaultValue;
public String value;
public SettingHudType(String ID, String value) {
super(ID);
this.defaultValue = value;
this.value = this.defaultValue;
}
| public SettingHudType(String ID, HudElementType type, int defaultValueId) {
|
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/settings/SettingHudType.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
//
// Path: src/main/java/net/spellcraftgaming/rpghud/main/ModRPGHud.java
// @Environment(EnvType.CLIENT)
//
// public class ModRPGHud implements ClientModInitializer{
// public final String MODID = "rpg-hud";
//
// public static ModRPGHud instance;
//
// public static boolean[] renderDetailsAgain = { false, false, false };
//
// public static int screenOffset = 0;
//
// public Settings settings;
//
// /** Map of all registered HUDs */
// public Map<String, Hud> huds = new LinkedHashMap<String, Hud>();
//
// public void onInitializeClient()
// {
// instance = this;
// this.settings = new Settings();
// this.registerHud(new HudVanilla(MinecraftClient.getInstance(), "vanilla", "Vanilla"));
// this.registerHud(new HudSimple(MinecraftClient.getInstance(), "simple", "Simplified"));
// this.registerHud(new HudDefault(MinecraftClient.getInstance(), "default", "Default"));
// this.registerHud(new HudExtendedWidget(MinecraftClient.getInstance(), "extended", "Extended Widget"));
// this.registerHud(new HudFullTexture(MinecraftClient.getInstance(), "texture", "Full Texture"));
// //this.registerHud(new HudHotbarWidget(MinecraftClient.getInstance(), "hotbar", "Hotbar Widget"));
// this.registerHud(new HudModern(MinecraftClient.getInstance(), "modern", "Modern Style"));
//
// if (!isHudKeyValid(this.settings.getStringValue(Settings.hud_type))) {
// this.settings.setSetting(Settings.hud_type, "vanilla");
// }
// new RenderOverlay();
// if (isClass("io.github.prospector.modmenu.ModMenu")) screenOffset = 12;
// }
//
// /**
// * Register a new HUD
// *
// * @param hud
// * the hud to be registered
// */
// public void registerHud(Hud hud) {
// this.huds.put(hud.getHudKey(), hud);
// }
//
// /** Returns the active HUD */
// public Hud getActiveHud() {
// return this.huds.get(this.settings.getStringValue(Settings.hud_type));
// }
//
// /** Returns the vanilla HUD */
// public Hud getVanillaHud() {
// return this.huds.get("vanilla");
// }
//
// public boolean isVanillaHud() {
// return this.settings.getStringValue(Settings.hud_type) == "vanilla";
// }
//
// /** Checks if a Hud with the specified key is registered */
// public boolean isHudKeyValid(String key) {
// return this.huds.containsKey(key);
// }
//
// public static boolean isClass(String className) {
// try {
// Class.forName(className);
// return true;
// } catch (ClassNotFoundException e) {
// return false;
// }
// }
// }
| import java.util.Set;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
import net.spellcraftgaming.rpghud.main.ModRPGHud;
| package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingHudType extends Setting {
public final String defaultValue;
public String value;
public SettingHudType(String ID, String value) {
super(ID);
this.defaultValue = value;
this.value = this.defaultValue;
}
public SettingHudType(String ID, HudElementType type, int defaultValueId) {
super(ID, type);
this.defaultValue = this.value;
this.value = this.defaultValue;
}
@Override
public void increment() {
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/element/HudElementType.java
// @Environment(EnvType.CLIENT)
// public enum HudElementType {
// VOID("name.void"),
// HOTBAR("name.hotbar"),
// HEALTH("name.health"),
// ARMOR("name.armor"),
// FOOD("name.food"),
// HEALTH_MOUNT("name.health_mount"),
// AIR("name.air"),
// JUMP_BAR("name.jump_bar"),
// EXPERIENCE("name.experience"),
// LEVEL("name.level"),
// CLOCK("name.clock"),
// DETAILS("name.details"),
// WIDGET("name.widget"),
// COMPASS("name.compass"),
// ENTITY_INSPECT("name.entity_inspect"),
// STATUS_EFFECTS("name.status_effects");
//
// private String displayName;
//
// private HudElementType(String displayName) {
// this.displayName = displayName;
// }
//
// public String getDisplayName() {
// return I18n.translate(this.displayName);
// }
// }
//
// Path: src/main/java/net/spellcraftgaming/rpghud/main/ModRPGHud.java
// @Environment(EnvType.CLIENT)
//
// public class ModRPGHud implements ClientModInitializer{
// public final String MODID = "rpg-hud";
//
// public static ModRPGHud instance;
//
// public static boolean[] renderDetailsAgain = { false, false, false };
//
// public static int screenOffset = 0;
//
// public Settings settings;
//
// /** Map of all registered HUDs */
// public Map<String, Hud> huds = new LinkedHashMap<String, Hud>();
//
// public void onInitializeClient()
// {
// instance = this;
// this.settings = new Settings();
// this.registerHud(new HudVanilla(MinecraftClient.getInstance(), "vanilla", "Vanilla"));
// this.registerHud(new HudSimple(MinecraftClient.getInstance(), "simple", "Simplified"));
// this.registerHud(new HudDefault(MinecraftClient.getInstance(), "default", "Default"));
// this.registerHud(new HudExtendedWidget(MinecraftClient.getInstance(), "extended", "Extended Widget"));
// this.registerHud(new HudFullTexture(MinecraftClient.getInstance(), "texture", "Full Texture"));
// //this.registerHud(new HudHotbarWidget(MinecraftClient.getInstance(), "hotbar", "Hotbar Widget"));
// this.registerHud(new HudModern(MinecraftClient.getInstance(), "modern", "Modern Style"));
//
// if (!isHudKeyValid(this.settings.getStringValue(Settings.hud_type))) {
// this.settings.setSetting(Settings.hud_type, "vanilla");
// }
// new RenderOverlay();
// if (isClass("io.github.prospector.modmenu.ModMenu")) screenOffset = 12;
// }
//
// /**
// * Register a new HUD
// *
// * @param hud
// * the hud to be registered
// */
// public void registerHud(Hud hud) {
// this.huds.put(hud.getHudKey(), hud);
// }
//
// /** Returns the active HUD */
// public Hud getActiveHud() {
// return this.huds.get(this.settings.getStringValue(Settings.hud_type));
// }
//
// /** Returns the vanilla HUD */
// public Hud getVanillaHud() {
// return this.huds.get("vanilla");
// }
//
// public boolean isVanillaHud() {
// return this.settings.getStringValue(Settings.hud_type) == "vanilla";
// }
//
// /** Checks if a Hud with the specified key is registered */
// public boolean isHudKeyValid(String key) {
// return this.huds.containsKey(key);
// }
//
// public static boolean isClass(String className) {
// try {
// Class.forName(className);
// return true;
// } catch (ClassNotFoundException e) {
// return false;
// }
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/settings/SettingHudType.java
import java.util.Set;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.spellcraftgaming.rpghud.gui.hud.element.HudElementType;
import net.spellcraftgaming.rpghud.main.ModRPGHud;
package net.spellcraftgaming.rpghud.settings;
@Environment(EnvType.CLIENT)
public class SettingHudType extends Setting {
public final String defaultValue;
public String value;
public SettingHudType(String ID, String value) {
super(ID);
this.defaultValue = value;
this.value = this.defaultValue;
}
public SettingHudType(String ID, HudElementType type, int defaultValueId) {
super(ID, type);
this.defaultValue = this.value;
this.value = this.defaultValue;
}
@Override
public void increment() {
| Set<String> huds = ModRPGHud.instance.huds.keySet();
|
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/gui/GuiButtonTooltip.java | // Path: src/main/java/net/spellcraftgaming/rpghud/main/ModRPGHud.java
// @Environment(EnvType.CLIENT)
//
// public class ModRPGHud implements ClientModInitializer{
// public final String MODID = "rpg-hud";
//
// public static ModRPGHud instance;
//
// public static boolean[] renderDetailsAgain = { false, false, false };
//
// public static int screenOffset = 0;
//
// public Settings settings;
//
// /** Map of all registered HUDs */
// public Map<String, Hud> huds = new LinkedHashMap<String, Hud>();
//
// public void onInitializeClient()
// {
// instance = this;
// this.settings = new Settings();
// this.registerHud(new HudVanilla(MinecraftClient.getInstance(), "vanilla", "Vanilla"));
// this.registerHud(new HudSimple(MinecraftClient.getInstance(), "simple", "Simplified"));
// this.registerHud(new HudDefault(MinecraftClient.getInstance(), "default", "Default"));
// this.registerHud(new HudExtendedWidget(MinecraftClient.getInstance(), "extended", "Extended Widget"));
// this.registerHud(new HudFullTexture(MinecraftClient.getInstance(), "texture", "Full Texture"));
// //this.registerHud(new HudHotbarWidget(MinecraftClient.getInstance(), "hotbar", "Hotbar Widget"));
// this.registerHud(new HudModern(MinecraftClient.getInstance(), "modern", "Modern Style"));
//
// if (!isHudKeyValid(this.settings.getStringValue(Settings.hud_type))) {
// this.settings.setSetting(Settings.hud_type, "vanilla");
// }
// new RenderOverlay();
// if (isClass("io.github.prospector.modmenu.ModMenu")) screenOffset = 12;
// }
//
// /**
// * Register a new HUD
// *
// * @param hud
// * the hud to be registered
// */
// public void registerHud(Hud hud) {
// this.huds.put(hud.getHudKey(), hud);
// }
//
// /** Returns the active HUD */
// public Hud getActiveHud() {
// return this.huds.get(this.settings.getStringValue(Settings.hud_type));
// }
//
// /** Returns the vanilla HUD */
// public Hud getVanillaHud() {
// return this.huds.get("vanilla");
// }
//
// public boolean isVanillaHud() {
// return this.settings.getStringValue(Settings.hud_type) == "vanilla";
// }
//
// /** Checks if a Hud with the specified key is registered */
// public boolean isHudKeyValid(String key) {
// return this.huds.containsKey(key);
// }
//
// public static boolean isClass(String className) {
// try {
// Class.forName(className);
// return true;
// } catch (ClassNotFoundException e) {
// return false;
// }
// }
// }
| import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
import net.spellcraftgaming.rpghud.main.ModRPGHud; | package net.spellcraftgaming.rpghud.gui;
@Environment(EnvType.CLIENT)
public class GuiButtonTooltip extends GuiButtonLib {
/** Variable to contain the (possible) setting of this button */
public final String enumOptions;
public int id;
/** Array that contains the tooltip of this button */
private String[] tooltip;
/**
* Initiates a new button
*
* @param buttonId
* The ID of the button
* @param x
* The x position on the screen
* @param y
* The y position on the screen
* @param buttonText
* The display Text of this button
*/
public GuiButtonTooltip(int x, int y, Text buttonText, ButtonWidget.PressAction ip) {
super(x, y, buttonText, ip);
this.enumOptions = null;
}
/**
* Initiates a new button
*
* @param buttonId
* The ID of the button
* @param x
* The x position on the screen
* @param y
* The y position on the screen
* @param width
* the width of the button
* @param height
* the height of the button
* @param buttonText
* The display Text of this button
*/
public GuiButtonTooltip(int x, int y, int width, int height, Text buttonText, ButtonWidget.PressAction ip) {
super(x, y, width, height, buttonText, ip);
this.enumOptions = null;
}
public GuiButtonTooltip(int id, int x, int y, int width, int height, Text buttonText, ButtonWidget.PressAction ip) {
super(x, y, width, height, buttonText, ip);
this.id = id;
this.enumOptions = null;
}
/**
* Initiates a new button
*
* @param buttonId
* The ID of the button
* @param x
* The x position on the screen
* @param y
* The y position on the screen
* @param setting
* The possible setting of this button
* @param buttonText
* The display Text of this button
*/
public GuiButtonTooltip(int x, int y, String setting, Text buttonText, ButtonWidget.PressAction ip) {
super(x, y, 150, 20, buttonText, ip);
this.enumOptions = setting;
}
/**
* Sets the tooltip of this button. Should be appended at the constructor.
*
* @param tooltip
* The String which'll be the button's tooltip. Line breaks are
* managed via the /n symbol combination.
* @return the button
*/
public GuiButtonTooltip setTooltip(String tooltip) {
this.tooltip = tooltip.split("/n");
return this;
}
/**
* Sets the tooltip to the one the setting of hits button contain.
*
* @return the button
*/
public GuiButtonTooltip setTooltip() {
if (this.enumOptions != null) | // Path: src/main/java/net/spellcraftgaming/rpghud/main/ModRPGHud.java
// @Environment(EnvType.CLIENT)
//
// public class ModRPGHud implements ClientModInitializer{
// public final String MODID = "rpg-hud";
//
// public static ModRPGHud instance;
//
// public static boolean[] renderDetailsAgain = { false, false, false };
//
// public static int screenOffset = 0;
//
// public Settings settings;
//
// /** Map of all registered HUDs */
// public Map<String, Hud> huds = new LinkedHashMap<String, Hud>();
//
// public void onInitializeClient()
// {
// instance = this;
// this.settings = new Settings();
// this.registerHud(new HudVanilla(MinecraftClient.getInstance(), "vanilla", "Vanilla"));
// this.registerHud(new HudSimple(MinecraftClient.getInstance(), "simple", "Simplified"));
// this.registerHud(new HudDefault(MinecraftClient.getInstance(), "default", "Default"));
// this.registerHud(new HudExtendedWidget(MinecraftClient.getInstance(), "extended", "Extended Widget"));
// this.registerHud(new HudFullTexture(MinecraftClient.getInstance(), "texture", "Full Texture"));
// //this.registerHud(new HudHotbarWidget(MinecraftClient.getInstance(), "hotbar", "Hotbar Widget"));
// this.registerHud(new HudModern(MinecraftClient.getInstance(), "modern", "Modern Style"));
//
// if (!isHudKeyValid(this.settings.getStringValue(Settings.hud_type))) {
// this.settings.setSetting(Settings.hud_type, "vanilla");
// }
// new RenderOverlay();
// if (isClass("io.github.prospector.modmenu.ModMenu")) screenOffset = 12;
// }
//
// /**
// * Register a new HUD
// *
// * @param hud
// * the hud to be registered
// */
// public void registerHud(Hud hud) {
// this.huds.put(hud.getHudKey(), hud);
// }
//
// /** Returns the active HUD */
// public Hud getActiveHud() {
// return this.huds.get(this.settings.getStringValue(Settings.hud_type));
// }
//
// /** Returns the vanilla HUD */
// public Hud getVanillaHud() {
// return this.huds.get("vanilla");
// }
//
// public boolean isVanillaHud() {
// return this.settings.getStringValue(Settings.hud_type) == "vanilla";
// }
//
// /** Checks if a Hud with the specified key is registered */
// public boolean isHudKeyValid(String key) {
// return this.huds.containsKey(key);
// }
//
// public static boolean isClass(String className) {
// try {
// Class.forName(className);
// return true;
// } catch (ClassNotFoundException e) {
// return false;
// }
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/gui/GuiButtonTooltip.java
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
import net.spellcraftgaming.rpghud.main.ModRPGHud;
package net.spellcraftgaming.rpghud.gui;
@Environment(EnvType.CLIENT)
public class GuiButtonTooltip extends GuiButtonLib {
/** Variable to contain the (possible) setting of this button */
public final String enumOptions;
public int id;
/** Array that contains the tooltip of this button */
private String[] tooltip;
/**
* Initiates a new button
*
* @param buttonId
* The ID of the button
* @param x
* The x position on the screen
* @param y
* The y position on the screen
* @param buttonText
* The display Text of this button
*/
public GuiButtonTooltip(int x, int y, Text buttonText, ButtonWidget.PressAction ip) {
super(x, y, buttonText, ip);
this.enumOptions = null;
}
/**
* Initiates a new button
*
* @param buttonId
* The ID of the button
* @param x
* The x position on the screen
* @param y
* The y position on the screen
* @param width
* the width of the button
* @param height
* the height of the button
* @param buttonText
* The display Text of this button
*/
public GuiButtonTooltip(int x, int y, int width, int height, Text buttonText, ButtonWidget.PressAction ip) {
super(x, y, width, height, buttonText, ip);
this.enumOptions = null;
}
public GuiButtonTooltip(int id, int x, int y, int width, int height, Text buttonText, ButtonWidget.PressAction ip) {
super(x, y, width, height, buttonText, ip);
this.id = id;
this.enumOptions = null;
}
/**
* Initiates a new button
*
* @param buttonId
* The ID of the button
* @param x
* The x position on the screen
* @param y
* The y position on the screen
* @param setting
* The possible setting of this button
* @param buttonText
* The display Text of this button
*/
public GuiButtonTooltip(int x, int y, String setting, Text buttonText, ButtonWidget.PressAction ip) {
super(x, y, 150, 20, buttonText, ip);
this.enumOptions = setting;
}
/**
* Sets the tooltip of this button. Should be appended at the constructor.
*
* @param tooltip
* The String which'll be the button's tooltip. Line breaks are
* managed via the /n symbol combination.
* @return the button
*/
public GuiButtonTooltip setTooltip(String tooltip) {
this.tooltip = tooltip.split("/n");
return this;
}
/**
* Sets the tooltip to the one the setting of hits button contain.
*
* @return the button
*/
public GuiButtonTooltip setTooltip() {
if (this.enumOptions != null) | return setTooltip(ModRPGHud.instance.settings.getSetting(this.enumOptions).getTooltip()); |
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/mixin/ChatMixin.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/HudHotbarWidget.java
// @Environment(EnvType.CLIENT)
// public class HudHotbarWidget extends HudDefault {
//
// public HudHotbarWidget(MinecraftClient mc, String hudKey, String hudName) {
// super(mc, hudKey, hudName);
// this.chatOffset = -22;
// }
//
// @Override
// public HudElement setElementArmor() {
// return new HudElementArmorHotbar();
// }
//
// @Override
// public HudElement setElementFood() {
// return new HudElementFoodHotbar();
// }
//
// @Override
// public HudElement setElementHealth() {
// return new HudElementHealthHotbar();
// }
//
// @Override
// public HudElement setElementHealthMount() {
// return new HudElementHealthMountHotbar();
// }
//
// @Override
// public HudElement setElementLevel() {
// return new HudElementLevelHotbar();
// }
//
// @Override
// public HudElement setElementWidget() {
// return new HudElementWidgetHotbar();
// }
//
// @Override
// public HudElement setElementHotbar() {
// return new HudElementHotbarHotbar();
// }
// }
//
// Path: src/main/java/net/spellcraftgaming/rpghud/main/ModRPGHud.java
// @Environment(EnvType.CLIENT)
//
// public class ModRPGHud implements ClientModInitializer{
// public final String MODID = "rpg-hud";
//
// public static ModRPGHud instance;
//
// public static boolean[] renderDetailsAgain = { false, false, false };
//
// public static int screenOffset = 0;
//
// public Settings settings;
//
// /** Map of all registered HUDs */
// public Map<String, Hud> huds = new LinkedHashMap<String, Hud>();
//
// public void onInitializeClient()
// {
// instance = this;
// this.settings = new Settings();
// this.registerHud(new HudVanilla(MinecraftClient.getInstance(), "vanilla", "Vanilla"));
// this.registerHud(new HudSimple(MinecraftClient.getInstance(), "simple", "Simplified"));
// this.registerHud(new HudDefault(MinecraftClient.getInstance(), "default", "Default"));
// this.registerHud(new HudExtendedWidget(MinecraftClient.getInstance(), "extended", "Extended Widget"));
// this.registerHud(new HudFullTexture(MinecraftClient.getInstance(), "texture", "Full Texture"));
// //this.registerHud(new HudHotbarWidget(MinecraftClient.getInstance(), "hotbar", "Hotbar Widget"));
// this.registerHud(new HudModern(MinecraftClient.getInstance(), "modern", "Modern Style"));
//
// if (!isHudKeyValid(this.settings.getStringValue(Settings.hud_type))) {
// this.settings.setSetting(Settings.hud_type, "vanilla");
// }
// new RenderOverlay();
// if (isClass("io.github.prospector.modmenu.ModMenu")) screenOffset = 12;
// }
//
// /**
// * Register a new HUD
// *
// * @param hud
// * the hud to be registered
// */
// public void registerHud(Hud hud) {
// this.huds.put(hud.getHudKey(), hud);
// }
//
// /** Returns the active HUD */
// public Hud getActiveHud() {
// return this.huds.get(this.settings.getStringValue(Settings.hud_type));
// }
//
// /** Returns the vanilla HUD */
// public Hud getVanillaHud() {
// return this.huds.get("vanilla");
// }
//
// public boolean isVanillaHud() {
// return this.settings.getStringValue(Settings.hud_type) == "vanilla";
// }
//
// /** Checks if a Hud with the specified key is registered */
// public boolean isHudKeyValid(String key) {
// return this.huds.containsKey(key);
// }
//
// public static boolean isClass(String className) {
// try {
// Class.forName(className);
// return true;
// } catch (ClassNotFoundException e) {
// return false;
// }
// }
// }
| import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.util.math.MatrixStack;
import net.spellcraftgaming.rpghud.gui.hud.HudHotbarWidget;
import net.spellcraftgaming.rpghud.main.ModRPGHud;
| package net.spellcraftgaming.rpghud.mixin;
@Mixin(ChatHud.class)
public class ChatMixin {
@Inject(at = @At("HEAD"), method = "render")
private void renderChat(CallbackInfo into) {
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/HudHotbarWidget.java
// @Environment(EnvType.CLIENT)
// public class HudHotbarWidget extends HudDefault {
//
// public HudHotbarWidget(MinecraftClient mc, String hudKey, String hudName) {
// super(mc, hudKey, hudName);
// this.chatOffset = -22;
// }
//
// @Override
// public HudElement setElementArmor() {
// return new HudElementArmorHotbar();
// }
//
// @Override
// public HudElement setElementFood() {
// return new HudElementFoodHotbar();
// }
//
// @Override
// public HudElement setElementHealth() {
// return new HudElementHealthHotbar();
// }
//
// @Override
// public HudElement setElementHealthMount() {
// return new HudElementHealthMountHotbar();
// }
//
// @Override
// public HudElement setElementLevel() {
// return new HudElementLevelHotbar();
// }
//
// @Override
// public HudElement setElementWidget() {
// return new HudElementWidgetHotbar();
// }
//
// @Override
// public HudElement setElementHotbar() {
// return new HudElementHotbarHotbar();
// }
// }
//
// Path: src/main/java/net/spellcraftgaming/rpghud/main/ModRPGHud.java
// @Environment(EnvType.CLIENT)
//
// public class ModRPGHud implements ClientModInitializer{
// public final String MODID = "rpg-hud";
//
// public static ModRPGHud instance;
//
// public static boolean[] renderDetailsAgain = { false, false, false };
//
// public static int screenOffset = 0;
//
// public Settings settings;
//
// /** Map of all registered HUDs */
// public Map<String, Hud> huds = new LinkedHashMap<String, Hud>();
//
// public void onInitializeClient()
// {
// instance = this;
// this.settings = new Settings();
// this.registerHud(new HudVanilla(MinecraftClient.getInstance(), "vanilla", "Vanilla"));
// this.registerHud(new HudSimple(MinecraftClient.getInstance(), "simple", "Simplified"));
// this.registerHud(new HudDefault(MinecraftClient.getInstance(), "default", "Default"));
// this.registerHud(new HudExtendedWidget(MinecraftClient.getInstance(), "extended", "Extended Widget"));
// this.registerHud(new HudFullTexture(MinecraftClient.getInstance(), "texture", "Full Texture"));
// //this.registerHud(new HudHotbarWidget(MinecraftClient.getInstance(), "hotbar", "Hotbar Widget"));
// this.registerHud(new HudModern(MinecraftClient.getInstance(), "modern", "Modern Style"));
//
// if (!isHudKeyValid(this.settings.getStringValue(Settings.hud_type))) {
// this.settings.setSetting(Settings.hud_type, "vanilla");
// }
// new RenderOverlay();
// if (isClass("io.github.prospector.modmenu.ModMenu")) screenOffset = 12;
// }
//
// /**
// * Register a new HUD
// *
// * @param hud
// * the hud to be registered
// */
// public void registerHud(Hud hud) {
// this.huds.put(hud.getHudKey(), hud);
// }
//
// /** Returns the active HUD */
// public Hud getActiveHud() {
// return this.huds.get(this.settings.getStringValue(Settings.hud_type));
// }
//
// /** Returns the vanilla HUD */
// public Hud getVanillaHud() {
// return this.huds.get("vanilla");
// }
//
// public boolean isVanillaHud() {
// return this.settings.getStringValue(Settings.hud_type) == "vanilla";
// }
//
// /** Checks if a Hud with the specified key is registered */
// public boolean isHudKeyValid(String key) {
// return this.huds.containsKey(key);
// }
//
// public static boolean isClass(String className) {
// try {
// Class.forName(className);
// return true;
// } catch (ClassNotFoundException e) {
// return false;
// }
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/mixin/ChatMixin.java
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.util.math.MatrixStack;
import net.spellcraftgaming.rpghud.gui.hud.HudHotbarWidget;
import net.spellcraftgaming.rpghud.main.ModRPGHud;
package net.spellcraftgaming.rpghud.mixin;
@Mixin(ChatHud.class)
public class ChatMixin {
@Inject(at = @At("HEAD"), method = "render")
private void renderChat(CallbackInfo into) {
| if(ModRPGHud.instance.getActiveHud() instanceof HudHotbarWidget) {
|
KurodaAkira/RPG-Hud | src/main/java/net/spellcraftgaming/rpghud/mixin/ChatMixin.java | // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/HudHotbarWidget.java
// @Environment(EnvType.CLIENT)
// public class HudHotbarWidget extends HudDefault {
//
// public HudHotbarWidget(MinecraftClient mc, String hudKey, String hudName) {
// super(mc, hudKey, hudName);
// this.chatOffset = -22;
// }
//
// @Override
// public HudElement setElementArmor() {
// return new HudElementArmorHotbar();
// }
//
// @Override
// public HudElement setElementFood() {
// return new HudElementFoodHotbar();
// }
//
// @Override
// public HudElement setElementHealth() {
// return new HudElementHealthHotbar();
// }
//
// @Override
// public HudElement setElementHealthMount() {
// return new HudElementHealthMountHotbar();
// }
//
// @Override
// public HudElement setElementLevel() {
// return new HudElementLevelHotbar();
// }
//
// @Override
// public HudElement setElementWidget() {
// return new HudElementWidgetHotbar();
// }
//
// @Override
// public HudElement setElementHotbar() {
// return new HudElementHotbarHotbar();
// }
// }
//
// Path: src/main/java/net/spellcraftgaming/rpghud/main/ModRPGHud.java
// @Environment(EnvType.CLIENT)
//
// public class ModRPGHud implements ClientModInitializer{
// public final String MODID = "rpg-hud";
//
// public static ModRPGHud instance;
//
// public static boolean[] renderDetailsAgain = { false, false, false };
//
// public static int screenOffset = 0;
//
// public Settings settings;
//
// /** Map of all registered HUDs */
// public Map<String, Hud> huds = new LinkedHashMap<String, Hud>();
//
// public void onInitializeClient()
// {
// instance = this;
// this.settings = new Settings();
// this.registerHud(new HudVanilla(MinecraftClient.getInstance(), "vanilla", "Vanilla"));
// this.registerHud(new HudSimple(MinecraftClient.getInstance(), "simple", "Simplified"));
// this.registerHud(new HudDefault(MinecraftClient.getInstance(), "default", "Default"));
// this.registerHud(new HudExtendedWidget(MinecraftClient.getInstance(), "extended", "Extended Widget"));
// this.registerHud(new HudFullTexture(MinecraftClient.getInstance(), "texture", "Full Texture"));
// //this.registerHud(new HudHotbarWidget(MinecraftClient.getInstance(), "hotbar", "Hotbar Widget"));
// this.registerHud(new HudModern(MinecraftClient.getInstance(), "modern", "Modern Style"));
//
// if (!isHudKeyValid(this.settings.getStringValue(Settings.hud_type))) {
// this.settings.setSetting(Settings.hud_type, "vanilla");
// }
// new RenderOverlay();
// if (isClass("io.github.prospector.modmenu.ModMenu")) screenOffset = 12;
// }
//
// /**
// * Register a new HUD
// *
// * @param hud
// * the hud to be registered
// */
// public void registerHud(Hud hud) {
// this.huds.put(hud.getHudKey(), hud);
// }
//
// /** Returns the active HUD */
// public Hud getActiveHud() {
// return this.huds.get(this.settings.getStringValue(Settings.hud_type));
// }
//
// /** Returns the vanilla HUD */
// public Hud getVanillaHud() {
// return this.huds.get("vanilla");
// }
//
// public boolean isVanillaHud() {
// return this.settings.getStringValue(Settings.hud_type) == "vanilla";
// }
//
// /** Checks if a Hud with the specified key is registered */
// public boolean isHudKeyValid(String key) {
// return this.huds.containsKey(key);
// }
//
// public static boolean isClass(String className) {
// try {
// Class.forName(className);
// return true;
// } catch (ClassNotFoundException e) {
// return false;
// }
// }
// }
| import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.util.math.MatrixStack;
import net.spellcraftgaming.rpghud.gui.hud.HudHotbarWidget;
import net.spellcraftgaming.rpghud.main.ModRPGHud;
| package net.spellcraftgaming.rpghud.mixin;
@Mixin(ChatHud.class)
public class ChatMixin {
@Inject(at = @At("HEAD"), method = "render")
private void renderChat(CallbackInfo into) {
| // Path: src/main/java/net/spellcraftgaming/rpghud/gui/hud/HudHotbarWidget.java
// @Environment(EnvType.CLIENT)
// public class HudHotbarWidget extends HudDefault {
//
// public HudHotbarWidget(MinecraftClient mc, String hudKey, String hudName) {
// super(mc, hudKey, hudName);
// this.chatOffset = -22;
// }
//
// @Override
// public HudElement setElementArmor() {
// return new HudElementArmorHotbar();
// }
//
// @Override
// public HudElement setElementFood() {
// return new HudElementFoodHotbar();
// }
//
// @Override
// public HudElement setElementHealth() {
// return new HudElementHealthHotbar();
// }
//
// @Override
// public HudElement setElementHealthMount() {
// return new HudElementHealthMountHotbar();
// }
//
// @Override
// public HudElement setElementLevel() {
// return new HudElementLevelHotbar();
// }
//
// @Override
// public HudElement setElementWidget() {
// return new HudElementWidgetHotbar();
// }
//
// @Override
// public HudElement setElementHotbar() {
// return new HudElementHotbarHotbar();
// }
// }
//
// Path: src/main/java/net/spellcraftgaming/rpghud/main/ModRPGHud.java
// @Environment(EnvType.CLIENT)
//
// public class ModRPGHud implements ClientModInitializer{
// public final String MODID = "rpg-hud";
//
// public static ModRPGHud instance;
//
// public static boolean[] renderDetailsAgain = { false, false, false };
//
// public static int screenOffset = 0;
//
// public Settings settings;
//
// /** Map of all registered HUDs */
// public Map<String, Hud> huds = new LinkedHashMap<String, Hud>();
//
// public void onInitializeClient()
// {
// instance = this;
// this.settings = new Settings();
// this.registerHud(new HudVanilla(MinecraftClient.getInstance(), "vanilla", "Vanilla"));
// this.registerHud(new HudSimple(MinecraftClient.getInstance(), "simple", "Simplified"));
// this.registerHud(new HudDefault(MinecraftClient.getInstance(), "default", "Default"));
// this.registerHud(new HudExtendedWidget(MinecraftClient.getInstance(), "extended", "Extended Widget"));
// this.registerHud(new HudFullTexture(MinecraftClient.getInstance(), "texture", "Full Texture"));
// //this.registerHud(new HudHotbarWidget(MinecraftClient.getInstance(), "hotbar", "Hotbar Widget"));
// this.registerHud(new HudModern(MinecraftClient.getInstance(), "modern", "Modern Style"));
//
// if (!isHudKeyValid(this.settings.getStringValue(Settings.hud_type))) {
// this.settings.setSetting(Settings.hud_type, "vanilla");
// }
// new RenderOverlay();
// if (isClass("io.github.prospector.modmenu.ModMenu")) screenOffset = 12;
// }
//
// /**
// * Register a new HUD
// *
// * @param hud
// * the hud to be registered
// */
// public void registerHud(Hud hud) {
// this.huds.put(hud.getHudKey(), hud);
// }
//
// /** Returns the active HUD */
// public Hud getActiveHud() {
// return this.huds.get(this.settings.getStringValue(Settings.hud_type));
// }
//
// /** Returns the vanilla HUD */
// public Hud getVanillaHud() {
// return this.huds.get("vanilla");
// }
//
// public boolean isVanillaHud() {
// return this.settings.getStringValue(Settings.hud_type) == "vanilla";
// }
//
// /** Checks if a Hud with the specified key is registered */
// public boolean isHudKeyValid(String key) {
// return this.huds.containsKey(key);
// }
//
// public static boolean isClass(String className) {
// try {
// Class.forName(className);
// return true;
// } catch (ClassNotFoundException e) {
// return false;
// }
// }
// }
// Path: src/main/java/net/spellcraftgaming/rpghud/mixin/ChatMixin.java
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.util.math.MatrixStack;
import net.spellcraftgaming.rpghud.gui.hud.HudHotbarWidget;
import net.spellcraftgaming.rpghud.main.ModRPGHud;
package net.spellcraftgaming.rpghud.mixin;
@Mixin(ChatHud.class)
public class ChatMixin {
@Inject(at = @At("HEAD"), method = "render")
private void renderChat(CallbackInfo into) {
| if(ModRPGHud.instance.getActiveHud() instanceof HudHotbarWidget) {
|
dlcs/the-mathmos-server | the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/OASearchServiceImpl.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/OASearchService.java
// public interface OASearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getAnnotationPage(String query, String queryString, String page, String within, String type, String widthHeight);
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
| import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.OASearchService;
import com.digirati.themathmos.service.TextSearchService; | package com.digirati.themathmos.service.impl;
@Service(OASearchServiceImpl.OA_SERVICE_NAME)
public class OASearchServiceImpl extends AnnotationSearchServiceImpl implements OASearchService{
private static final Logger LOG = Logger.getLogger(OASearchServiceImpl.class);
public static final String OA_SERVICE_NAME = "oaSearchServiceImpl";
@Autowired | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/OASearchService.java
// public interface OASearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getAnnotationPage(String query, String queryString, String page, String within, String type, String widthHeight);
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/OASearchServiceImpl.java
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.OASearchService;
import com.digirati.themathmos.service.TextSearchService;
package com.digirati.themathmos.service.impl;
@Service(OASearchServiceImpl.OA_SERVICE_NAME)
public class OASearchServiceImpl extends AnnotationSearchServiceImpl implements OASearchService{
private static final Logger LOG = Logger.getLogger(OASearchServiceImpl.class);
public static final String OA_SERVICE_NAME = "oaSearchServiceImpl";
@Autowired | public OASearchServiceImpl(AnnotationUtils annotationUtils,ElasticsearchTemplate template,TextSearchService textSearchService, CacheManager cacheManager) { |
dlcs/the-mathmos-server | the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/OASearchServiceImpl.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/OASearchService.java
// public interface OASearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getAnnotationPage(String query, String queryString, String page, String within, String type, String widthHeight);
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
| import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.OASearchService;
import com.digirati.themathmos.service.TextSearchService; | package com.digirati.themathmos.service.impl;
@Service(OASearchServiceImpl.OA_SERVICE_NAME)
public class OASearchServiceImpl extends AnnotationSearchServiceImpl implements OASearchService{
private static final Logger LOG = Logger.getLogger(OASearchServiceImpl.class);
public static final String OA_SERVICE_NAME = "oaSearchServiceImpl";
@Autowired
public OASearchServiceImpl(AnnotationUtils annotationUtils,ElasticsearchTemplate template,TextSearchService textSearchService, CacheManager cacheManager) {
super(annotationUtils, template, textSearchService, cacheManager);
}
@Override
@Transactional(readOnly = true, isolation = Isolation.SERIALIZABLE) | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/OASearchService.java
// public interface OASearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getAnnotationPage(String query, String queryString, String page, String within, String type, String widthHeight);
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/OASearchServiceImpl.java
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.OASearchService;
import com.digirati.themathmos.service.TextSearchService;
package com.digirati.themathmos.service.impl;
@Service(OASearchServiceImpl.OA_SERVICE_NAME)
public class OASearchServiceImpl extends AnnotationSearchServiceImpl implements OASearchService{
private static final Logger LOG = Logger.getLogger(OASearchServiceImpl.class);
public static final String OA_SERVICE_NAME = "oaSearchServiceImpl";
@Autowired
public OASearchServiceImpl(AnnotationUtils annotationUtils,ElasticsearchTemplate template,TextSearchService textSearchService, CacheManager cacheManager) {
super(annotationUtils, template, textSearchService, cacheManager);
}
@Override
@Transactional(readOnly = true, isolation = Isolation.SERIALIZABLE) | public ServiceResponse<Map<String, Object>> getAnnotationPage(String query, String queryString, String page, String within, String type, String widthHeight) { |
dlcs/the-mathmos-server | the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/GetPayloadServiceImpl.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/exception/CoordinatePayloadException.java
// @SuppressWarnings("serial")
// public class CoordinatePayloadException extends RuntimeException {
//
// public CoordinatePayloadException(String msg) {
// super(msg);
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/GetPayloadService.java
// public interface GetPayloadService {
//
// public String getJsonPayload(String url, String payload);
//
// }
| import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.digirati.themathmos.exception.CoordinatePayloadException;
import com.digirati.themathmos.service.GetPayloadService; | package com.digirati.themathmos.service.impl;
@Service(GetPayloadServiceImpl.SERVICE_NAME)
public class GetPayloadServiceImpl implements GetPayloadService{
private static final Logger LOG = Logger.getLogger(GetPayloadServiceImpl.class);
public static final String SERVICE_NAME = "getPayloadServiceImpl";
HttpClient httpClient;
GetPayloadServiceImpl(){
httpClient = HttpClientBuilder.create().build(); //Use this instead
}
@Override
public String getJsonPayload(String url, String payload){
try {
HttpPost request = new HttpPost(url);
StringEntity params = new StringEntity(payload);
LOG.info(payload);
request.addHeader("content-type", "application/json; charset=utf-8");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
if (response.getStatusLine().getStatusCode() != 200) { | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/exception/CoordinatePayloadException.java
// @SuppressWarnings("serial")
// public class CoordinatePayloadException extends RuntimeException {
//
// public CoordinatePayloadException(String msg) {
// super(msg);
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/GetPayloadService.java
// public interface GetPayloadService {
//
// public String getJsonPayload(String url, String payload);
//
// }
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/GetPayloadServiceImpl.java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.digirati.themathmos.exception.CoordinatePayloadException;
import com.digirati.themathmos.service.GetPayloadService;
package com.digirati.themathmos.service.impl;
@Service(GetPayloadServiceImpl.SERVICE_NAME)
public class GetPayloadServiceImpl implements GetPayloadService{
private static final Logger LOG = Logger.getLogger(GetPayloadServiceImpl.class);
public static final String SERVICE_NAME = "getPayloadServiceImpl";
HttpClient httpClient;
GetPayloadServiceImpl(){
httpClient = HttpClientBuilder.create().build(); //Use this instead
}
@Override
public String getJsonPayload(String url, String payload){
try {
HttpPost request = new HttpPost(url);
StringEntity params = new StringEntity(payload);
LOG.info(payload);
request.addHeader("content-type", "application/json; charset=utf-8");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
if (response.getStatusLine().getStatusCode() != 200) { | throw new CoordinatePayloadException("Failed : HTTP error code : " |
dlcs/the-mathmos-server | the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/W3CSearchServiceImpl.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/W3CSearchService.java
// public interface W3CSearchService {
//
//
// public ServiceResponse<Map<String, Object>> getAnnotationPage(String query, String queryString, String page, String within, String type, String widthHeight);
//
// }
| import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.digirati.themathmos.service.W3CSearchService; | package com.digirati.themathmos.service.impl;
@Service(W3CSearchServiceImpl.W3C_SERVICE_NAME)
public class W3CSearchServiceImpl extends AnnotationSearchServiceImpl implements W3CSearchService{
private static final Logger LOG = Logger.getLogger(W3CSearchServiceImpl.class);
public static final String W3C_SERVICE_NAME = "w3cSearchServiceImpl";
@Autowired | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/W3CSearchService.java
// public interface W3CSearchService {
//
//
// public ServiceResponse<Map<String, Object>> getAnnotationPage(String query, String queryString, String page, String within, String type, String widthHeight);
//
// }
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/W3CSearchServiceImpl.java
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.digirati.themathmos.service.W3CSearchService;
package com.digirati.themathmos.service.impl;
@Service(W3CSearchServiceImpl.W3C_SERVICE_NAME)
public class W3CSearchServiceImpl extends AnnotationSearchServiceImpl implements W3CSearchService{
private static final Logger LOG = Logger.getLogger(W3CSearchServiceImpl.class);
public static final String W3C_SERVICE_NAME = "w3cSearchServiceImpl";
@Autowired | public W3CSearchServiceImpl(AnnotationUtils annotationUtils,ElasticsearchTemplate template,TextSearchService textSearchService, CacheManager cacheManager ) { |
dlcs/the-mathmos-server | the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/W3CSearchServiceImpl.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/W3CSearchService.java
// public interface W3CSearchService {
//
//
// public ServiceResponse<Map<String, Object>> getAnnotationPage(String query, String queryString, String page, String within, String type, String widthHeight);
//
// }
| import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.digirati.themathmos.service.W3CSearchService; | package com.digirati.themathmos.service.impl;
@Service(W3CSearchServiceImpl.W3C_SERVICE_NAME)
public class W3CSearchServiceImpl extends AnnotationSearchServiceImpl implements W3CSearchService{
private static final Logger LOG = Logger.getLogger(W3CSearchServiceImpl.class);
public static final String W3C_SERVICE_NAME = "w3cSearchServiceImpl";
@Autowired
public W3CSearchServiceImpl(AnnotationUtils annotationUtils,ElasticsearchTemplate template,TextSearchService textSearchService, CacheManager cacheManager ) {
super(annotationUtils, template, textSearchService, cacheManager);
}
@Override
@Transactional(readOnly = true, isolation = Isolation.SERIALIZABLE) | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/W3CSearchService.java
// public interface W3CSearchService {
//
//
// public ServiceResponse<Map<String, Object>> getAnnotationPage(String query, String queryString, String page, String within, String type, String widthHeight);
//
// }
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/W3CSearchServiceImpl.java
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.digirati.themathmos.service.W3CSearchService;
package com.digirati.themathmos.service.impl;
@Service(W3CSearchServiceImpl.W3C_SERVICE_NAME)
public class W3CSearchServiceImpl extends AnnotationSearchServiceImpl implements W3CSearchService{
private static final Logger LOG = Logger.getLogger(W3CSearchServiceImpl.class);
public static final String W3C_SERVICE_NAME = "w3cSearchServiceImpl";
@Autowired
public W3CSearchServiceImpl(AnnotationUtils annotationUtils,ElasticsearchTemplate template,TextSearchService textSearchService, CacheManager cacheManager ) {
super(annotationUtils, template, textSearchService, cacheManager);
}
@Override
@Transactional(readOnly = true, isolation = Isolation.SERIALIZABLE) | public ServiceResponse<Map<String, Object>> getAnnotationPage(String query, String queryString, String page, String within, String type, String widthHeight) { |
dlcs/the-mathmos-server | the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/TextSearchServiceImplTest.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/GetPayloadService.java
// public interface GetPayloadService {
//
// public String getJsonPayload(String url, String payload);
//
// }
| import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.termvectors.MultiTermVectorsItemResponse;
import org.elasticsearch.action.termvectors.MultiTermVectorsResponse;
import org.elasticsearch.action.termvectors.TermVectorsRequest.Flag;
import org.elasticsearch.action.termvectors.TermVectorsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.service.GetPayloadService;
import com.google.common.collect.Iterators; | package com.digirati.themathmos.service.impl;
@RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class)
public class TextSearchServiceImplTest {
private static final Logger LOG = Logger.getLogger(TextSearchServiceImplTest.class);
TextSearchServiceImpl textSearchServiceImpl;
private ElasticsearchTemplate template;
Client client;
private TextUtils textUtils;
String url = ""; | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/GetPayloadService.java
// public interface GetPayloadService {
//
// public String getJsonPayload(String url, String payload);
//
// }
// Path: the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/TextSearchServiceImplTest.java
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.termvectors.MultiTermVectorsItemResponse;
import org.elasticsearch.action.termvectors.MultiTermVectorsResponse;
import org.elasticsearch.action.termvectors.TermVectorsRequest.Flag;
import org.elasticsearch.action.termvectors.TermVectorsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.service.GetPayloadService;
import com.google.common.collect.Iterators;
package com.digirati.themathmos.service.impl;
@RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class)
public class TextSearchServiceImplTest {
private static final Logger LOG = Logger.getLogger(TextSearchServiceImplTest.class);
TextSearchServiceImpl textSearchServiceImpl;
private ElasticsearchTemplate template;
Client client;
private TextUtils textUtils;
String url = ""; | private GetPayloadService coordinateService; |
dlcs/the-mathmos-server | the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/TextSearchServiceImplTest.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/GetPayloadService.java
// public interface GetPayloadService {
//
// public String getJsonPayload(String url, String payload);
//
// }
| import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.termvectors.MultiTermVectorsItemResponse;
import org.elasticsearch.action.termvectors.MultiTermVectorsResponse;
import org.elasticsearch.action.termvectors.TermVectorsRequest.Flag;
import org.elasticsearch.action.termvectors.TermVectorsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.service.GetPayloadService;
import com.google.common.collect.Iterators; |
TermVectorsResponse tvResponse = new TermVectorsResponse("1","2","3");
tvResponse.setExists(true);
writeStandardTermVector(tvResponse);
MultiTermVectorsItemResponse mtviResponse = new MultiTermVectorsItemResponse(tvResponse, null);
ActionFuture<MultiTermVectorsResponse> mtvAction = mock(ListenableActionFuture.class);
when(client.multiTermVectors(anyObject())).thenReturn(mtvAction);
MultiTermVectorsItemResponse[] itemResponseArray = new MultiTermVectorsItemResponse[]{mtviResponse};
MultiTermVectorsResponse mtvr = new MultiTermVectorsResponse(itemResponseArray);
when(mtvAction.actionGet()).thenReturn(mtvr);
String coordinates = getFileContents("coordinates.json");
when(coordinateService.getJsonPayload(anyString(), anyString())).thenReturn(coordinates);
Cache.ValueWrapper obj = mock(Cache.ValueWrapper.class);
Cache mockCache = mock(Cache.class);
when(cacheManager.getCache("textSearchCache")).thenReturn(mockCache);
when(mockCache.get(anyString())).thenReturn(null); | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/GetPayloadService.java
// public interface GetPayloadService {
//
// public String getJsonPayload(String url, String payload);
//
// }
// Path: the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/TextSearchServiceImplTest.java
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.termvectors.MultiTermVectorsItemResponse;
import org.elasticsearch.action.termvectors.MultiTermVectorsResponse;
import org.elasticsearch.action.termvectors.TermVectorsRequest.Flag;
import org.elasticsearch.action.termvectors.TermVectorsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.service.GetPayloadService;
import com.google.common.collect.Iterators;
TermVectorsResponse tvResponse = new TermVectorsResponse("1","2","3");
tvResponse.setExists(true);
writeStandardTermVector(tvResponse);
MultiTermVectorsItemResponse mtviResponse = new MultiTermVectorsItemResponse(tvResponse, null);
ActionFuture<MultiTermVectorsResponse> mtvAction = mock(ListenableActionFuture.class);
when(client.multiTermVectors(anyObject())).thenReturn(mtvAction);
MultiTermVectorsItemResponse[] itemResponseArray = new MultiTermVectorsItemResponse[]{mtviResponse};
MultiTermVectorsResponse mtvr = new MultiTermVectorsResponse(itemResponseArray);
when(mtvAction.actionGet()).thenReturn(mtvr);
String coordinates = getFileContents("coordinates.json");
when(coordinateService.getJsonPayload(anyString(), anyString())).thenReturn(coordinates);
Cache.ValueWrapper obj = mock(Cache.ValueWrapper.class);
Cache mockCache = mock(Cache.class);
when(cacheManager.getCache("textSearchCache")).thenReturn(mockCache);
when(mockCache.get(anyString())).thenReturn(null); | ServiceResponse<Map<String, Object>> serviceResponse = textSearchServiceImpl.getTextPositions(query, queryString, isW3c, page, isMixedSearch, null, null); |
dlcs/the-mathmos-server | the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/TextSearchServiceImplTest.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/GetPayloadService.java
// public interface GetPayloadService {
//
// public String getJsonPayload(String url, String payload);
//
// }
| import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.termvectors.MultiTermVectorsItemResponse;
import org.elasticsearch.action.termvectors.MultiTermVectorsResponse;
import org.elasticsearch.action.termvectors.TermVectorsRequest.Flag;
import org.elasticsearch.action.termvectors.TermVectorsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.service.GetPayloadService;
import com.google.common.collect.Iterators; |
TermVectorsResponse tvResponse = new TermVectorsResponse("1","2","3");
tvResponse.setExists(true);
writeStandardTermVector(tvResponse);
MultiTermVectorsItemResponse mtviResponse = new MultiTermVectorsItemResponse(tvResponse, null);
ActionFuture<MultiTermVectorsResponse> mtvAction = mock(ListenableActionFuture.class);
when(client.multiTermVectors(anyObject())).thenReturn(mtvAction);
MultiTermVectorsItemResponse[] itemResponseArray = new MultiTermVectorsItemResponse[]{mtviResponse};
MultiTermVectorsResponse mtvr = new MultiTermVectorsResponse(itemResponseArray);
when(mtvAction.actionGet()).thenReturn(mtvr);
String coordinates = getFileContents("coordinates.json");
when(coordinateService.getJsonPayload(anyString(), anyString())).thenReturn(coordinates);
Cache.ValueWrapper obj = mock(Cache.ValueWrapper.class);
Cache mockCache = mock(Cache.class);
when(cacheManager.getCache("textSearchCache")).thenReturn(mockCache);
when(mockCache.get(anyString())).thenReturn(null);
ServiceResponse<Map<String, Object>> serviceResponse = textSearchServiceImpl.getTextPositions(query, queryString, isW3c, page, isMixedSearch, null, null); | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/GetPayloadService.java
// public interface GetPayloadService {
//
// public String getJsonPayload(String url, String payload);
//
// }
// Path: the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/TextSearchServiceImplTest.java
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.termvectors.MultiTermVectorsItemResponse;
import org.elasticsearch.action.termvectors.MultiTermVectorsResponse;
import org.elasticsearch.action.termvectors.TermVectorsRequest.Flag;
import org.elasticsearch.action.termvectors.TermVectorsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.ServiceResponse.Status;
import com.digirati.themathmos.service.GetPayloadService;
import com.google.common.collect.Iterators;
TermVectorsResponse tvResponse = new TermVectorsResponse("1","2","3");
tvResponse.setExists(true);
writeStandardTermVector(tvResponse);
MultiTermVectorsItemResponse mtviResponse = new MultiTermVectorsItemResponse(tvResponse, null);
ActionFuture<MultiTermVectorsResponse> mtvAction = mock(ListenableActionFuture.class);
when(client.multiTermVectors(anyObject())).thenReturn(mtvAction);
MultiTermVectorsItemResponse[] itemResponseArray = new MultiTermVectorsItemResponse[]{mtviResponse};
MultiTermVectorsResponse mtvr = new MultiTermVectorsResponse(itemResponseArray);
when(mtvAction.actionGet()).thenReturn(mtvr);
String coordinates = getFileContents("coordinates.json");
when(coordinateService.getJsonPayload(anyString(), anyString())).thenReturn(coordinates);
Cache.ValueWrapper obj = mock(Cache.ValueWrapper.class);
Cache mockCache = mock(Cache.class);
when(cacheManager.getCache("textSearchCache")).thenReturn(mockCache);
when(mockCache.get(anyString())).thenReturn(null);
ServiceResponse<Map<String, Object>> serviceResponse = textSearchServiceImpl.getTextPositions(query, queryString, isW3c, page, isMixedSearch, null, null); | assertEquals(serviceResponse.getStatus(), Status.OK); |
dlcs/the-mathmos-server | the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/W3CSearchServiceImpTest.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
| import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.google.common.collect.Iterators; | package com.digirati.themathmos.service.impl;
public class W3CSearchServiceImpTest {
private static final Logger LOG = Logger.getLogger(W3CSearchServiceImpTest.class);
private W3CSearchServiceImpl impl;
String queryString = "http://www.example.com/search?q=finger";
String queryStringWithPage = "http://www.example.com/search?q=finger&page=2";
AnnotationUtils annotationUtils;
ElasticsearchTemplate template;
Client client;
SearchQueryUtils searchQueryUtils; | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
// Path: the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/W3CSearchServiceImpTest.java
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.google.common.collect.Iterators;
package com.digirati.themathmos.service.impl;
public class W3CSearchServiceImpTest {
private static final Logger LOG = Logger.getLogger(W3CSearchServiceImpTest.class);
private W3CSearchServiceImpl impl;
String queryString = "http://www.example.com/search?q=finger";
String queryStringWithPage = "http://www.example.com/search?q=finger&page=2";
AnnotationUtils annotationUtils;
ElasticsearchTemplate template;
Client client;
SearchQueryUtils searchQueryUtils; | private TextSearchService textSearchService; |
dlcs/the-mathmos-server | the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/W3CSearchServiceImpTest.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
| import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.google.common.collect.Iterators; | String widthHeight=null;
long totalHits = 10;
when(template.getClient()).thenReturn(client);
SearchHits searchHits = mock(SearchHits.class);
when(searchHits.getTotalHits()).thenReturn(totalHits);
SearchHit[] hits = new SearchHit[1];
SearchHit hit = mock(SearchHit.class);
hits[0] = hit;
when(searchHits.iterator()).thenReturn(Iterators.forArray(hits));
when(hit.getSourceAsString()).thenReturn(null);
SearchResponse response = mock(SearchResponse.class);
when(response.getHits()).thenReturn(searchHits);
ListenableActionFuture<SearchResponse> action = mock(ListenableActionFuture.class);
when(action.actionGet()).thenReturn(response);
SearchRequestBuilder builder = mock(SearchRequestBuilder.class);
when(builder.setQuery(anyObject())).thenReturn(builder);
when(builder.setPostFilter(anyObject())).thenReturn(builder);
when(builder.setFrom(anyInt())).thenReturn(builder);
when(builder.setSize(anyInt())).thenReturn(builder);
when(builder.execute()).thenReturn(action);
when(client.prepareSearch("w3cannotation")).thenReturn(builder);
| // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
// Path: the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/W3CSearchServiceImpTest.java
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.google.common.collect.Iterators;
String widthHeight=null;
long totalHits = 10;
when(template.getClient()).thenReturn(client);
SearchHits searchHits = mock(SearchHits.class);
when(searchHits.getTotalHits()).thenReturn(totalHits);
SearchHit[] hits = new SearchHit[1];
SearchHit hit = mock(SearchHit.class);
hits[0] = hit;
when(searchHits.iterator()).thenReturn(Iterators.forArray(hits));
when(hit.getSourceAsString()).thenReturn(null);
SearchResponse response = mock(SearchResponse.class);
when(response.getHits()).thenReturn(searchHits);
ListenableActionFuture<SearchResponse> action = mock(ListenableActionFuture.class);
when(action.actionGet()).thenReturn(response);
SearchRequestBuilder builder = mock(SearchRequestBuilder.class);
when(builder.setQuery(anyObject())).thenReturn(builder);
when(builder.setPostFilter(anyObject())).thenReturn(builder);
when(builder.setFrom(anyInt())).thenReturn(builder);
when(builder.setSize(anyInt())).thenReturn(builder);
when(builder.execute()).thenReturn(action);
when(client.prepareSearch("w3cannotation")).thenReturn(builder);
| PageParameters textPagingParamters = new PageParameters(); |
dlcs/the-mathmos-server | the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/W3CSearchServiceImpTest.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
| import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.google.common.collect.Iterators; |
SearchHits searchHits = mock(SearchHits.class);
when(searchHits.getTotalHits()).thenReturn(totalHits);
SearchHit[] hits = new SearchHit[1];
SearchHit hit = mock(SearchHit.class);
hits[0] = hit;
when(searchHits.iterator()).thenReturn(Iterators.forArray(hits));
when(hit.getSourceAsString()).thenReturn(null);
SearchResponse response = mock(SearchResponse.class);
when(response.getHits()).thenReturn(searchHits);
ListenableActionFuture<SearchResponse> action = mock(ListenableActionFuture.class);
when(action.actionGet()).thenReturn(response);
SearchRequestBuilder builder = mock(SearchRequestBuilder.class);
when(builder.setQuery(anyObject())).thenReturn(builder);
when(builder.setPostFilter(anyObject())).thenReturn(builder);
when(builder.setFrom(anyInt())).thenReturn(builder);
when(builder.setSize(anyInt())).thenReturn(builder);
when(builder.execute()).thenReturn(action);
when(client.prepareSearch("w3cannotation")).thenReturn(builder);
PageParameters textPagingParamters = new PageParameters();
when(textSearchService.getPageParameters()).thenReturn(textPagingParamters);
| // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
// Path: the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/W3CSearchServiceImpTest.java
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.google.common.collect.Iterators;
SearchHits searchHits = mock(SearchHits.class);
when(searchHits.getTotalHits()).thenReturn(totalHits);
SearchHit[] hits = new SearchHit[1];
SearchHit hit = mock(SearchHit.class);
hits[0] = hit;
when(searchHits.iterator()).thenReturn(Iterators.forArray(hits));
when(hit.getSourceAsString()).thenReturn(null);
SearchResponse response = mock(SearchResponse.class);
when(response.getHits()).thenReturn(searchHits);
ListenableActionFuture<SearchResponse> action = mock(ListenableActionFuture.class);
when(action.actionGet()).thenReturn(response);
SearchRequestBuilder builder = mock(SearchRequestBuilder.class);
when(builder.setQuery(anyObject())).thenReturn(builder);
when(builder.setPostFilter(anyObject())).thenReturn(builder);
when(builder.setFrom(anyInt())).thenReturn(builder);
when(builder.setSize(anyInt())).thenReturn(builder);
when(builder.execute()).thenReturn(action);
when(client.prepareSearch("w3cannotation")).thenReturn(builder);
PageParameters textPagingParamters = new PageParameters();
when(textSearchService.getPageParameters()).thenReturn(textPagingParamters);
| ServiceResponse<Map<String, Object>> serviceResponse = impl.getAnnotationPage(query, queryString, page, within, type, widthHeight); |
dlcs/the-mathmos-server | the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/OASearchServiceImpTest.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
| import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.google.common.collect.Iterators; | package com.digirati.themathmos.service.impl;
public class OASearchServiceImpTest {
private static final Logger LOG = Logger.getLogger(W3CSearchServiceImpTest.class);
private OASearchServiceImpl impl;
String queryString = "http://www.example.com/search?q=finger";
String queryStringWithPage = "http://www.example.com/search?q=finger&page=2";
AnnotationUtils annotationUtils;
ElasticsearchTemplate template;
Client client;
SearchQueryUtils searchQueryUtils; | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
//
// /**
// *
// */
// private static final long serialVersionUID = 8231671973667011469L;
//
// public enum Status {
// OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
// }
//
// private final Status status;
// private final transient T obj;
//
// public ServiceResponse(Status status, T obj) {
// this.status = status;
// this.obj = obj;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public T getObj() {
// return obj;
// }
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
//
//
//
// public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
//
//
// public long getTotalHits();
//
// public PageParameters getPageParameters();
//
// public TextUtils getTextUtils();
//
// }
// Path: the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/OASearchServiceImpTest.java
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.google.common.collect.Iterators;
package com.digirati.themathmos.service.impl;
public class OASearchServiceImpTest {
private static final Logger LOG = Logger.getLogger(W3CSearchServiceImpTest.class);
private OASearchServiceImpl impl;
String queryString = "http://www.example.com/search?q=finger";
String queryStringWithPage = "http://www.example.com/search?q=finger&page=2";
AnnotationUtils annotationUtils;
ElasticsearchTemplate template;
Client client;
SearchQueryUtils searchQueryUtils; | private TextSearchService textSearchService; |
dlcs/the-mathmos-server | the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/AnnotationUtils.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/w3c/SuggestOption.java
// public class SuggestOption {
//
// private float score;
// private String text;
//
//
// public SuggestOption(float score, String text){
// this.score = score;
// this.text = text;
// }
//
// public SuggestOption(String text){
// this.text = text;
// }
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public String getText() {
// return text;
// }
// public void setText(String text) {
// this.text = text;
// }
//
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/w3c/W3CAnnotation.java
// public class W3CAnnotation extends AbstractAnnotation {
//
// }
| import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.model.annotation.w3c.SuggestOption;
import com.digirati.themathmos.model.annotation.w3c.W3CAnnotation;
import com.github.jsonldjava.utils.JsonUtils;
import com.google.gson.Gson;
import com.google.gson.internal.LinkedTreeMap; | package com.digirati.themathmos.service.impl;
@Service(AnnotationUtils.SERVICE_NAME)
public class AnnotationUtils extends CommonUtils {
private static final Logger LOG = Logger.getLogger(AnnotationUtils.class);
public static final String SERVICE_NAME = "AnnotationUtils";
private static final String[] SCHEMES = new String[] { "http", "https", "ftp", "mailto", "file", "data" };
| // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/w3c/SuggestOption.java
// public class SuggestOption {
//
// private float score;
// private String text;
//
//
// public SuggestOption(float score, String text){
// this.score = score;
// this.text = text;
// }
//
// public SuggestOption(String text){
// this.text = text;
// }
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public String getText() {
// return text;
// }
// public void setText(String text) {
// this.text = text;
// }
//
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/w3c/W3CAnnotation.java
// public class W3CAnnotation extends AbstractAnnotation {
//
// }
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/AnnotationUtils.java
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.model.annotation.w3c.SuggestOption;
import com.digirati.themathmos.model.annotation.w3c.W3CAnnotation;
import com.github.jsonldjava.utils.JsonUtils;
import com.google.gson.Gson;
import com.google.gson.internal.LinkedTreeMap;
package com.digirati.themathmos.service.impl;
@Service(AnnotationUtils.SERVICE_NAME)
public class AnnotationUtils extends CommonUtils {
private static final Logger LOG = Logger.getLogger(AnnotationUtils.class);
public static final String SERVICE_NAME = "AnnotationUtils";
private static final String[] SCHEMES = new String[] { "http", "https", "ftp", "mailto", "file", "data" };
| public Map<String, Object> createAnnotationPage(String query, List<W3CAnnotation> annoList, boolean isW3c, |
dlcs/the-mathmos-server | the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/AnnotationUtils.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/w3c/SuggestOption.java
// public class SuggestOption {
//
// private float score;
// private String text;
//
//
// public SuggestOption(float score, String text){
// this.score = score;
// this.text = text;
// }
//
// public SuggestOption(String text){
// this.text = text;
// }
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public String getText() {
// return text;
// }
// public void setText(String text) {
// this.text = text;
// }
//
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/w3c/W3CAnnotation.java
// public class W3CAnnotation extends AbstractAnnotation {
//
// }
| import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.model.annotation.w3c.SuggestOption;
import com.digirati.themathmos.model.annotation.w3c.W3CAnnotation;
import com.github.jsonldjava.utils.JsonUtils;
import com.google.gson.Gson;
import com.google.gson.internal.LinkedTreeMap; | package com.digirati.themathmos.service.impl;
@Service(AnnotationUtils.SERVICE_NAME)
public class AnnotationUtils extends CommonUtils {
private static final Logger LOG = Logger.getLogger(AnnotationUtils.class);
public static final String SERVICE_NAME = "AnnotationUtils";
private static final String[] SCHEMES = new String[] { "http", "https", "ftp", "mailto", "file", "data" };
public Map<String, Object> createAnnotationPage(String query, List<W3CAnnotation> annoList, boolean isW3c, | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/w3c/SuggestOption.java
// public class SuggestOption {
//
// private float score;
// private String text;
//
//
// public SuggestOption(float score, String text){
// this.score = score;
// this.text = text;
// }
//
// public SuggestOption(String text){
// this.text = text;
// }
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public String getText() {
// return text;
// }
// public void setText(String text) {
// this.text = text;
// }
//
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/w3c/W3CAnnotation.java
// public class W3CAnnotation extends AbstractAnnotation {
//
// }
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/AnnotationUtils.java
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.model.annotation.w3c.SuggestOption;
import com.digirati.themathmos.model.annotation.w3c.W3CAnnotation;
import com.github.jsonldjava.utils.JsonUtils;
import com.google.gson.Gson;
import com.google.gson.internal.LinkedTreeMap;
package com.digirati.themathmos.service.impl;
@Service(AnnotationUtils.SERVICE_NAME)
public class AnnotationUtils extends CommonUtils {
private static final Logger LOG = Logger.getLogger(AnnotationUtils.class);
public static final String SERVICE_NAME = "AnnotationUtils";
private static final String[] SCHEMES = new String[] { "http", "https", "ftp", "mailto", "file", "data" };
public Map<String, Object> createAnnotationPage(String query, List<W3CAnnotation> annoList, boolean isW3c, | PageParameters pageParams, int totalHits, boolean isMixedSearch) { |
dlcs/the-mathmos-server | the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/AnnotationUtils.java | // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/w3c/SuggestOption.java
// public class SuggestOption {
//
// private float score;
// private String text;
//
//
// public SuggestOption(float score, String text){
// this.score = score;
// this.text = text;
// }
//
// public SuggestOption(String text){
// this.text = text;
// }
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public String getText() {
// return text;
// }
// public void setText(String text) {
// this.text = text;
// }
//
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/w3c/W3CAnnotation.java
// public class W3CAnnotation extends AbstractAnnotation {
//
// }
| import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.model.annotation.w3c.SuggestOption;
import com.digirati.themathmos.model.annotation.w3c.W3CAnnotation;
import com.github.jsonldjava.utils.JsonUtils;
import com.google.gson.Gson;
import com.google.gson.internal.LinkedTreeMap; | // }
return root;
}
/**
* Method to create the terms urls will replace
*
* @param query
* @param optionText
* @return
*/
private String getSearchQueryFromAutocompleteQuery(String query, String optionText) {
String searchQuery = query;
searchQuery = searchQuery.replace("autocomplete", "search");
String tidyQuery = removeParametersAutocompleteQuery(searchQuery, AUTOCOMPLETE_IGNORE_PARAMETERS);
String encodedOptionText = optionText;
try {
encodedOptionText = URLEncoder.encode(optionText, "UTF-8");
} catch (UnsupportedEncodingException e) {
LOG.error(String.format("Autocomplete: unable to encode [%s]", optionText), e);
}
return tidyQuery.replaceAll("q=[^&]+", "q=" + encodedOptionText);
}
| // Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
//
// private int total;
//
// private String firstPageNumber;
// private String lastPageNumber;
// private String nextPageNumber;
// private int nextPage = 0;
// private int lastPage = 0;
// private String previousPageNumber;
// private String startIndexString;
//
// private int startIndex;
//
// public int getTotal() {
// return total;
// }
// public void setTotal(int total) {
// this.total = total;
// }
//
// public String getFirstPageNumber() {
// return firstPageNumber;
// }
// public void setFirstPageNumber(String firstPageNumber) {
// this.firstPageNumber = firstPageNumber;
// }
// public String getLastPageNumber() {
// return lastPageNumber;
// }
// public void setLastPageNumber(String lastPageNumber) {
// this.lastPageNumber = lastPageNumber;
// }
// public String getNextPageNumber() {
// return nextPageNumber;
// }
// public void setNextPageNumber(String nextPageNumber) {
// this.nextPageNumber = nextPageNumber;
// }
// public String getPreviousPageNumber() {
// return previousPageNumber;
// }
// public void setPreviousPageNumber(String previousPageNumber) {
// this.previousPageNumber = previousPageNumber;
// }
// public int getStartIndex() {
// return startIndex;
// }
// public void setStartIndex(int startIndex) {
// this.startIndex = startIndex;
// }
// public int getNextPage() {
// return nextPage;
// }
// public void setNextPage(int nextPage) {
// this.nextPage = nextPage;
// }
// public int getLastPage() {
// return lastPage;
// }
// public void setLastPage(int lastPage) {
// this.lastPage = lastPage;
// }
// public String getStartIndexString() {
// return startIndexString;
// }
// public void setStartIndexString(String startIndexString) {
// this.startIndexString = startIndexString;
// }
//
//
// @Override
// public String toString(){
// return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
// }
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/w3c/SuggestOption.java
// public class SuggestOption {
//
// private float score;
// private String text;
//
//
// public SuggestOption(float score, String text){
// this.score = score;
// this.text = text;
// }
//
// public SuggestOption(String text){
// this.text = text;
// }
// public float getScore() {
// return score;
// }
// public void setScore(float score) {
// this.score = score;
// }
// public String getText() {
// return text;
// }
// public void setText(String text) {
// this.text = text;
// }
//
//
// }
//
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/w3c/W3CAnnotation.java
// public class W3CAnnotation extends AbstractAnnotation {
//
// }
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/AnnotationUtils.java
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.model.annotation.w3c.SuggestOption;
import com.digirati.themathmos.model.annotation.w3c.W3CAnnotation;
import com.github.jsonldjava.utils.JsonUtils;
import com.google.gson.Gson;
import com.google.gson.internal.LinkedTreeMap;
// }
return root;
}
/**
* Method to create the terms urls will replace
*
* @param query
* @param optionText
* @return
*/
private String getSearchQueryFromAutocompleteQuery(String query, String optionText) {
String searchQuery = query;
searchQuery = searchQuery.replace("autocomplete", "search");
String tidyQuery = removeParametersAutocompleteQuery(searchQuery, AUTOCOMPLETE_IGNORE_PARAMETERS);
String encodedOptionText = optionText;
try {
encodedOptionText = URLEncoder.encode(optionText, "UTF-8");
} catch (UnsupportedEncodingException e) {
LOG.error(String.format("Autocomplete: unable to encode [%s]", optionText), e);
}
return tidyQuery.replaceAll("q=[^&]+", "q=" + encodedOptionText);
}
| public Map<String, Object> createAutocompleteList(List<SuggestOption> options, boolean isW3c, String queryString, |
ihongs/HongsCORE | hongs-core/src/main/java/io/github/ihongs/util/Dict.java | // Path: hongs-core/src/main/java/io/github/ihongs/util/Synt.java
// public static enum LOOP {
// NEXT,
// LAST;
// @Override
// public String toString () {
// return "";
// }
// };
| import io.github.ihongs.HongsExemption;
import io.github.ihongs.util.Synt.LOOP;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set; | return new ArrayList(0);
}
private static Object gat(Collection lst, Object def, Object[] keys, int pos)
{
/**
* 获取下面所有的节点的值
* 下面也要列表则向上合并
*/
boolean one = true ;
for ( int j = pos; j < keys.length; j ++ ) {
if (keys[j] == null) {
one = false;
break;
}
}
/**
* 当默认值也是集合类型时
* 直接将获取的值放入其中
*/
Collection col;
if (def != null && def instanceof Collection) {
col = (Collection) def;
} else {
col = new LinkedList();
}
if (one) {
for(Object sub : lst) { | // Path: hongs-core/src/main/java/io/github/ihongs/util/Synt.java
// public static enum LOOP {
// NEXT,
// LAST;
// @Override
// public String toString () {
// return "";
// }
// };
// Path: hongs-core/src/main/java/io/github/ihongs/util/Dict.java
import io.github.ihongs.HongsExemption;
import io.github.ihongs.util.Synt.LOOP;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
return new ArrayList(0);
}
private static Object gat(Collection lst, Object def, Object[] keys, int pos)
{
/**
* 获取下面所有的节点的值
* 下面也要列表则向上合并
*/
boolean one = true ;
for ( int j = pos; j < keys.length; j ++ ) {
if (keys[j] == null) {
one = false;
break;
}
}
/**
* 当默认值也是集合类型时
* 直接将获取的值放入其中
*/
Collection col;
if (def != null && def instanceof Collection) {
col = (Collection) def;
} else {
col = new LinkedList();
}
if (one) {
for(Object sub : lst) { | Object obj = get(sub, LOOP.NEXT, keys, pos); |
code-squad/blue-common | algorithm/codes/LinearList/src/honux/ListTest.java | // Path: algorithm/codes/LinearList/src/honux/util/Time.java
// public class Time {
// private static long timemillis;
// public static void start() {
// timemillis = System.currentTimeMillis();
// }
//
// public static void end() {
// timemillis = System.currentTimeMillis() - timemillis;
// }
//
// public static long getTime() {
// return timemillis;
// }
//
// public static void printTime() {
// System.out.println("Elapsed time(ms): " + timemillis);
// }
// }
| import java.util.List;
import java.util.ArrayList;
import java.util.LinkedList;
import honux.util.Time; | package honux;
public class ListTest {
public static void stringTest(long num) {
String temp = "";
long part = num / 10; | // Path: algorithm/codes/LinearList/src/honux/util/Time.java
// public class Time {
// private static long timemillis;
// public static void start() {
// timemillis = System.currentTimeMillis();
// }
//
// public static void end() {
// timemillis = System.currentTimeMillis() - timemillis;
// }
//
// public static long getTime() {
// return timemillis;
// }
//
// public static void printTime() {
// System.out.println("Elapsed time(ms): " + timemillis);
// }
// }
// Path: algorithm/codes/LinearList/src/honux/ListTest.java
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedList;
import honux.util.Time;
package honux;
public class ListTest {
public static void stringTest(long num) {
String temp = "";
long part = num / 10; | Time.start(); |
eandrejko/RSense.tmbundle | Support/rsense-0.2/src/org/cx4a/rsense/typing/TypeSet.java | // Path: Support/rsense-0.2/src/org/cx4a/rsense/ruby/IRubyObject.java
// public interface IRubyObject {
// public Ruby getRuntime();
// public RubyClass getMetaClass();
// public void setMetaClass(RubyClass metaClass);
// public RubyClass getSingletonClass();
// public RubyClass makeMetaClass(RubyClass superClass);
// public IRubyObject getInstVar(String name);
// public void setInstVar(String name, IRubyObject value);
// public boolean isNil();
// public boolean isInstanceOf(RubyModule klass);
// public boolean isKindOf(RubyModule klass);
// public Object getTag();
// public void setTag(Object tag);
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/ruby/RubyObject.java
// public class RubyObject implements IRubyObject {
// protected Ruby runtime;
// protected RubyClass metaClass;
// private Map<String, IRubyObject> instVars;
// private Object tag;
//
// protected RubyObject(Ruby runtime) {
// this(runtime, null);
// }
//
// public RubyObject(Ruby runtime, RubyClass metaClass) {
// this.runtime = runtime;
// this.metaClass = metaClass;
// }
//
// public Ruby getRuntime() {
// return runtime;
// }
//
// public RubyClass getMetaClass() {
// return metaClass;
// }
//
// public void setMetaClass(RubyClass metaClass) {
// this.metaClass = metaClass;
// }
//
// public RubyClass getSingletonClass() {
// RubyClass klass;
// if (getMetaClass().isSingleton() && ((MetaClass) getMetaClass()).getAttached() == this) {
// klass = getMetaClass();
// } else {
// klass = makeMetaClass(getMetaClass());
// }
// return klass;
// }
//
// public RubyClass makeMetaClass(RubyClass superClass) {
// MetaClass klass = new MetaClass(runtime, superClass);
// setMetaClass(klass);
//
// klass.setAttached(this);
// klass.setMetaClass(superClass.getRealClass().getMetaClass());
//
// superClass.addSubclass(klass);
//
// return klass;
// }
//
// public IRubyObject getInstVar(String name) {
// return instVars == null ? null : instVars.get(name);
// }
//
// public void setInstVar(String name, IRubyObject value) {
// if (instVars == null) {
// instVars = new HashMap<String, IRubyObject>();
// }
// instVars.put(name, value);
// }
//
// public boolean isNil() {
// return this == getRuntime().getNil();
// }
//
// public boolean isInstanceOf(RubyModule klass) {
// return runtime.isInstanceOf(this, klass);
// }
//
// public boolean isKindOf(RubyModule klass) {
// return runtime.isKindOf(this, klass);
// }
//
// public Object getTag() {
// return tag;
// }
//
// public void setTag(Object tag) {
// this.tag = tag;
// }
//
// @Override
// public String toString() {
// return "<obj:" + metaClass.toString() + ">";
// }
// }
| import java.util.Collection;
import java.util.HashSet;
import org.cx4a.rsense.ruby.IRubyObject;
import org.cx4a.rsense.ruby.RubyObject;
import org.cx4a.rsense.util.Logger; | package org.cx4a.rsense.typing;
public class TypeSet extends HashSet<IRubyObject> {
private static final long serialVersionUID = 0L;
public static final int MEGAMORPHIC_THRESHOLD = 5;
public static final TypeSet EMPTY = new TypeSet();
private boolean megamorphic;
public TypeSet() {
super();
}
public TypeSet(TypeSet other) {
super(other);
}
public boolean add(IRubyObject e) {
if (megamorphic) return false;
if (size() >= MEGAMORPHIC_THRESHOLD) {
megamorphic = true;
// FIXME simple way
Logger.warn("megamorphic detected");
clear(); | // Path: Support/rsense-0.2/src/org/cx4a/rsense/ruby/IRubyObject.java
// public interface IRubyObject {
// public Ruby getRuntime();
// public RubyClass getMetaClass();
// public void setMetaClass(RubyClass metaClass);
// public RubyClass getSingletonClass();
// public RubyClass makeMetaClass(RubyClass superClass);
// public IRubyObject getInstVar(String name);
// public void setInstVar(String name, IRubyObject value);
// public boolean isNil();
// public boolean isInstanceOf(RubyModule klass);
// public boolean isKindOf(RubyModule klass);
// public Object getTag();
// public void setTag(Object tag);
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/ruby/RubyObject.java
// public class RubyObject implements IRubyObject {
// protected Ruby runtime;
// protected RubyClass metaClass;
// private Map<String, IRubyObject> instVars;
// private Object tag;
//
// protected RubyObject(Ruby runtime) {
// this(runtime, null);
// }
//
// public RubyObject(Ruby runtime, RubyClass metaClass) {
// this.runtime = runtime;
// this.metaClass = metaClass;
// }
//
// public Ruby getRuntime() {
// return runtime;
// }
//
// public RubyClass getMetaClass() {
// return metaClass;
// }
//
// public void setMetaClass(RubyClass metaClass) {
// this.metaClass = metaClass;
// }
//
// public RubyClass getSingletonClass() {
// RubyClass klass;
// if (getMetaClass().isSingleton() && ((MetaClass) getMetaClass()).getAttached() == this) {
// klass = getMetaClass();
// } else {
// klass = makeMetaClass(getMetaClass());
// }
// return klass;
// }
//
// public RubyClass makeMetaClass(RubyClass superClass) {
// MetaClass klass = new MetaClass(runtime, superClass);
// setMetaClass(klass);
//
// klass.setAttached(this);
// klass.setMetaClass(superClass.getRealClass().getMetaClass());
//
// superClass.addSubclass(klass);
//
// return klass;
// }
//
// public IRubyObject getInstVar(String name) {
// return instVars == null ? null : instVars.get(name);
// }
//
// public void setInstVar(String name, IRubyObject value) {
// if (instVars == null) {
// instVars = new HashMap<String, IRubyObject>();
// }
// instVars.put(name, value);
// }
//
// public boolean isNil() {
// return this == getRuntime().getNil();
// }
//
// public boolean isInstanceOf(RubyModule klass) {
// return runtime.isInstanceOf(this, klass);
// }
//
// public boolean isKindOf(RubyModule klass) {
// return runtime.isKindOf(this, klass);
// }
//
// public Object getTag() {
// return tag;
// }
//
// public void setTag(Object tag) {
// this.tag = tag;
// }
//
// @Override
// public String toString() {
// return "<obj:" + metaClass.toString() + ">";
// }
// }
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/TypeSet.java
import java.util.Collection;
import java.util.HashSet;
import org.cx4a.rsense.ruby.IRubyObject;
import org.cx4a.rsense.ruby.RubyObject;
import org.cx4a.rsense.util.Logger;
package org.cx4a.rsense.typing;
public class TypeSet extends HashSet<IRubyObject> {
private static final long serialVersionUID = 0L;
public static final int MEGAMORPHIC_THRESHOLD = 5;
public static final TypeSet EMPTY = new TypeSet();
private boolean megamorphic;
public TypeSet() {
super();
}
public TypeSet(TypeSet other) {
super(other);
}
public boolean add(IRubyObject e) {
if (megamorphic) return false;
if (size() >= MEGAMORPHIC_THRESHOLD) {
megamorphic = true;
// FIXME simple way
Logger.warn("megamorphic detected");
clear(); | return super.add(new RubyObject(e.getRuntime(), e.getRuntime().getObject())); |
eandrejko/RSense.tmbundle | Support/rsense-0.2/src/org/cx4a/rsense/typing/Propagation.java | // Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/Vertex.java
// public class Vertex {
// protected Node node;
// protected TypeSet typeSet;
// protected List<Vertex> edges;
//
// public Vertex() {
// this(null);
// }
//
// public Vertex(Node node) {
// this(node, new TypeSet());
// }
//
// public Vertex(Node node, TypeSet typeSet) {
// this.node = node;
// this.typeSet = typeSet;
// edges = new ArrayList<Vertex>();
// }
//
// public Node getNode() {
// return node;
// }
//
// public TypeSet getTypeSet() {
// return typeSet;
// }
//
// public List<Vertex> getEdges() {
// return edges;
// }
//
// public boolean isEmpty() {
// return typeSet.isEmpty();
// }
//
// public void addType(IRubyObject type) {
// typeSet.add(type);
// }
//
// public void addTypeSet(TypeSet typeSet) {
// this.typeSet.addAll(typeSet);
// }
//
// public void copyTypeSet(Vertex other) {
// typeSet.addAll(other.getTypeSet());
// }
//
// public IRubyObject singleType() {
// if (typeSet.size() != 1) {
// return null;
// }
// return typeSet.iterator().next();
// }
//
// public void addEdge(Vertex dest) {
// edges.add(dest);
// }
//
// public void removeEdge(Vertex dest) {
// edges.remove(dest);
// }
//
// public boolean accept(Propagation propagation, Vertex src) {
// return propagation.getGraph().propagateVertex(propagation, this, src);
// }
//
// public boolean isFree() {
// return node == null;
// }
//
// @Override
// public String toString() {
// return typeSet.toString();
// }
//
// public static String getName(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof INameNode) {
// return ((INameNode) node).getName();
// } else {
// return null;
// }
// }
//
// public static Integer getFixnum(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof FixnumNode) {
// return Integer.valueOf((int) ((FixnumNode) node).getValue());
// } else {
// return null;
// }
// }
//
// public static String getString(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof StrNode) {
// return ((StrNode) node).getValue().toString();
// } else {
// return null;
// }
// }
//
// public static String getSymbol(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof SymbolNode) {
// return ((SymbolNode) node).getName();
// } else {
// return null;
// }
// }
//
// public static String getStringOrSymbol(Vertex vertex) {
// String value = getString(vertex);
// return value != null ? value : getSymbol(vertex);
// }
// }
| import java.util.Set;
import java.util.HashSet;
import org.cx4a.rsense.typing.vertex.Vertex; | package org.cx4a.rsense.typing;
public class Propagation {
private Graph graph;
private Set<Object> visited;
private int refCount;
public Propagation(Graph graph) {
this.graph = graph;
this.refCount = 0;
}
public Graph getGraph() {
return graph;
}
| // Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/Vertex.java
// public class Vertex {
// protected Node node;
// protected TypeSet typeSet;
// protected List<Vertex> edges;
//
// public Vertex() {
// this(null);
// }
//
// public Vertex(Node node) {
// this(node, new TypeSet());
// }
//
// public Vertex(Node node, TypeSet typeSet) {
// this.node = node;
// this.typeSet = typeSet;
// edges = new ArrayList<Vertex>();
// }
//
// public Node getNode() {
// return node;
// }
//
// public TypeSet getTypeSet() {
// return typeSet;
// }
//
// public List<Vertex> getEdges() {
// return edges;
// }
//
// public boolean isEmpty() {
// return typeSet.isEmpty();
// }
//
// public void addType(IRubyObject type) {
// typeSet.add(type);
// }
//
// public void addTypeSet(TypeSet typeSet) {
// this.typeSet.addAll(typeSet);
// }
//
// public void copyTypeSet(Vertex other) {
// typeSet.addAll(other.getTypeSet());
// }
//
// public IRubyObject singleType() {
// if (typeSet.size() != 1) {
// return null;
// }
// return typeSet.iterator().next();
// }
//
// public void addEdge(Vertex dest) {
// edges.add(dest);
// }
//
// public void removeEdge(Vertex dest) {
// edges.remove(dest);
// }
//
// public boolean accept(Propagation propagation, Vertex src) {
// return propagation.getGraph().propagateVertex(propagation, this, src);
// }
//
// public boolean isFree() {
// return node == null;
// }
//
// @Override
// public String toString() {
// return typeSet.toString();
// }
//
// public static String getName(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof INameNode) {
// return ((INameNode) node).getName();
// } else {
// return null;
// }
// }
//
// public static Integer getFixnum(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof FixnumNode) {
// return Integer.valueOf((int) ((FixnumNode) node).getValue());
// } else {
// return null;
// }
// }
//
// public static String getString(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof StrNode) {
// return ((StrNode) node).getValue().toString();
// } else {
// return null;
// }
// }
//
// public static String getSymbol(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof SymbolNode) {
// return ((SymbolNode) node).getName();
// } else {
// return null;
// }
// }
//
// public static String getStringOrSymbol(Vertex vertex) {
// String value = getString(vertex);
// return value != null ? value : getSymbol(vertex);
// }
// }
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Propagation.java
import java.util.Set;
import java.util.HashSet;
import org.cx4a.rsense.typing.vertex.Vertex;
package org.cx4a.rsense.typing;
public class Propagation {
private Graph graph;
private Set<Object> visited;
private int refCount;
public Propagation(Graph graph) {
this.graph = graph;
this.refCount = 0;
}
public Graph getGraph() {
return graph;
}
| public boolean isVisited(Vertex vertex) { |
eandrejko/RSense.tmbundle | Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/YieldVertex.java | // Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Propagation.java
// public class Propagation {
// private Graph graph;
// private Set<Object> visited;
// private int refCount;
//
// public Propagation(Graph graph) {
// this.graph = graph;
// this.refCount = 0;
// }
//
// public Graph getGraph() {
// return graph;
// }
//
// public boolean isVisited(Vertex vertex) {
// return visited != null ? visited.contains(getVisitTag(vertex)) : false;
// }
//
// public void addVisited(Vertex vertex) {
// if (visited == null) {
// // lazy allocation
// visited = new HashSet<Object>();
// }
// visited.add(getVisitTag(vertex));
// }
//
// public boolean checkVisited(Vertex vertex) {
// if (isVisited(vertex)) {
// return true;
// } else {
// addVisited(vertex);
// return false;
// }
// }
//
// public void retain() {
// refCount++;
// }
//
// public boolean release() {
// return --refCount == 0;
// }
//
// private Object getVisitTag(Vertex vertex) {
// return vertex.getNode() != null ? vertex.getNode() : vertex;
// }
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Template.java
// public class Template {
// private Method method;
// private TemplateAttribute attr;
// private Vertex returnVertex;
// private Frame frame;
// private Scope scope;
//
// public Template(Method method, Frame frame, Scope scope, TemplateAttribute attr) {
// this.method = method;
// this.attr = attr;
// this.frame = frame;
// this.scope = scope;
// this.returnVertex = new Vertex();
// }
//
// public Method getMethod() {
// return method;
// }
//
// public TemplateAttribute getAttribute() {
// return attr;
// }
//
// public Vertex getReturnVertex() {
// return returnVertex;
// }
//
// public Frame getFrame() {
// return frame;
// }
//
// public Scope getScope() {
// return scope;
// }
//
// public void reproduceSideEffect(Graph graph, IRubyObject receiver, IRubyObject[] args, Block block) {
// reproduceSideEffect(graph, attr.getMutableReceiver(false), receiver);
// for (int i = 0; i < attr.getArgs().length && i < args.length; i++) {
// reproduceSideEffect(graph, attr.getMutableArg(i, false), args[i]);
// }
// reproduceYield(graph, receiver, args, block);
// }
//
// private void reproduceSideEffect(Graph graph, IRubyObject from, IRubyObject to) {
// if (from instanceof MonomorphicObject && to instanceof MonomorphicObject) {
// MonomorphicObject a = (MonomorphicObject) from;
// MonomorphicObject b = (MonomorphicObject) to;
// for (Map.Entry<TypeVariable, Vertex> entry : a.getTypeVarMap().entrySet()) {
// Vertex src = entry.getValue();
// Vertex dest = b.getTypeVarMap().get(entry.getKey());
// if (dest != null) {
// graph.propagateEdge(src, dest);
// }
// }
// }
// }
//
// private void reproduceYield(Graph graph, IRubyObject receiver, IRubyObject[] args, Block block) {
// Proc templateProc = (Proc) attr.getBlock();
// if (templateProc != null && block != null) {
// Proc proc = (Proc) block;
// for (YieldVertex vertex : templateProc.getYields()) {
// RuntimeHelper.yield(graph, new YieldVertex(vertex.getNode(), this, block, vertex.getArgsVertex(), vertex.getExpandArguments()));
// }
// }
// }
// }
| import org.jruby.ast.Node;
import org.cx4a.rsense.ruby.Block;
import org.cx4a.rsense.typing.Propagation;
import org.cx4a.rsense.typing.Template; | package org.cx4a.rsense.typing.vertex;
public class YieldVertex extends Vertex {
private Template template;
private Block block;
private Vertex argsVertex;
private boolean expandArguments;
public YieldVertex(Node node, Template template, Block block, Vertex argsVertex, boolean expandArguments) {
super(node);
this.template = template;
this.block = block;
this.argsVertex = argsVertex;
this.expandArguments = expandArguments;
if (argsVertex != null) {
argsVertex.addEdge(this);
}
}
public Template getTemplate() {
return template;
}
public Block getBlock() {
return block;
}
public Vertex getArgsVertex() {
return argsVertex;
}
public boolean getExpandArguments() {
return expandArguments;
}
@Override | // Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Propagation.java
// public class Propagation {
// private Graph graph;
// private Set<Object> visited;
// private int refCount;
//
// public Propagation(Graph graph) {
// this.graph = graph;
// this.refCount = 0;
// }
//
// public Graph getGraph() {
// return graph;
// }
//
// public boolean isVisited(Vertex vertex) {
// return visited != null ? visited.contains(getVisitTag(vertex)) : false;
// }
//
// public void addVisited(Vertex vertex) {
// if (visited == null) {
// // lazy allocation
// visited = new HashSet<Object>();
// }
// visited.add(getVisitTag(vertex));
// }
//
// public boolean checkVisited(Vertex vertex) {
// if (isVisited(vertex)) {
// return true;
// } else {
// addVisited(vertex);
// return false;
// }
// }
//
// public void retain() {
// refCount++;
// }
//
// public boolean release() {
// return --refCount == 0;
// }
//
// private Object getVisitTag(Vertex vertex) {
// return vertex.getNode() != null ? vertex.getNode() : vertex;
// }
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Template.java
// public class Template {
// private Method method;
// private TemplateAttribute attr;
// private Vertex returnVertex;
// private Frame frame;
// private Scope scope;
//
// public Template(Method method, Frame frame, Scope scope, TemplateAttribute attr) {
// this.method = method;
// this.attr = attr;
// this.frame = frame;
// this.scope = scope;
// this.returnVertex = new Vertex();
// }
//
// public Method getMethod() {
// return method;
// }
//
// public TemplateAttribute getAttribute() {
// return attr;
// }
//
// public Vertex getReturnVertex() {
// return returnVertex;
// }
//
// public Frame getFrame() {
// return frame;
// }
//
// public Scope getScope() {
// return scope;
// }
//
// public void reproduceSideEffect(Graph graph, IRubyObject receiver, IRubyObject[] args, Block block) {
// reproduceSideEffect(graph, attr.getMutableReceiver(false), receiver);
// for (int i = 0; i < attr.getArgs().length && i < args.length; i++) {
// reproduceSideEffect(graph, attr.getMutableArg(i, false), args[i]);
// }
// reproduceYield(graph, receiver, args, block);
// }
//
// private void reproduceSideEffect(Graph graph, IRubyObject from, IRubyObject to) {
// if (from instanceof MonomorphicObject && to instanceof MonomorphicObject) {
// MonomorphicObject a = (MonomorphicObject) from;
// MonomorphicObject b = (MonomorphicObject) to;
// for (Map.Entry<TypeVariable, Vertex> entry : a.getTypeVarMap().entrySet()) {
// Vertex src = entry.getValue();
// Vertex dest = b.getTypeVarMap().get(entry.getKey());
// if (dest != null) {
// graph.propagateEdge(src, dest);
// }
// }
// }
// }
//
// private void reproduceYield(Graph graph, IRubyObject receiver, IRubyObject[] args, Block block) {
// Proc templateProc = (Proc) attr.getBlock();
// if (templateProc != null && block != null) {
// Proc proc = (Proc) block;
// for (YieldVertex vertex : templateProc.getYields()) {
// RuntimeHelper.yield(graph, new YieldVertex(vertex.getNode(), this, block, vertex.getArgsVertex(), vertex.getExpandArguments()));
// }
// }
// }
// }
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/YieldVertex.java
import org.jruby.ast.Node;
import org.cx4a.rsense.ruby.Block;
import org.cx4a.rsense.typing.Propagation;
import org.cx4a.rsense.typing.Template;
package org.cx4a.rsense.typing.vertex;
public class YieldVertex extends Vertex {
private Template template;
private Block block;
private Vertex argsVertex;
private boolean expandArguments;
public YieldVertex(Node node, Template template, Block block, Vertex argsVertex, boolean expandArguments) {
super(node);
this.template = template;
this.block = block;
this.argsVertex = argsVertex;
this.expandArguments = expandArguments;
if (argsVertex != null) {
argsVertex.addEdge(this);
}
}
public Template getTemplate() {
return template;
}
public Block getBlock() {
return block;
}
public Vertex getArgsVertex() {
return argsVertex;
}
public boolean getExpandArguments() {
return expandArguments;
}
@Override | public boolean accept(Propagation propagation, Vertex src) { |
eandrejko/RSense.tmbundle | Support/rsense-0.2/src/org/cx4a/rsense/Main.java | // Path: Support/rsense-0.2/src/org/cx4a/rsense/ruby/IRubyObject.java
// public interface IRubyObject {
// public Ruby getRuntime();
// public RubyClass getMetaClass();
// public void setMetaClass(RubyClass metaClass);
// public RubyClass getSingletonClass();
// public RubyClass makeMetaClass(RubyClass superClass);
// public IRubyObject getInstVar(String name);
// public void setInstVar(String name, IRubyObject value);
// public boolean isNil();
// public boolean isInstanceOf(RubyModule klass);
// public boolean isKindOf(RubyModule klass);
// public Object getTag();
// public void setTag(Object tag);
// }
| import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;
import java.util.Properties;
import java.io.File;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.io.Reader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
import org.jruby.Ruby;
import org.jruby.ast.Node;
import org.cx4a.rsense.ruby.IRubyObject;
import org.cx4a.rsense.util.Logger;
import org.cx4a.rsense.util.HereDocReader; | codeAssistError(result, options);
}
}
} catch (Exception e) {
commandException(e, options);
}
}
private void commandTypeInference(Options options) {
try {
TypeInferenceResult result;
Project project = codeAssist.getProject(options);
if (options.isFileStdin()) {
result = codeAssist.typeInference(project,
new File("(stdin)"),
options.getHereDocReader(inReader),
options.getLocation());
} else {
result = codeAssist.typeInference(project,
options.getFile(),
options.getEncoding(),
options.getLocation());
}
if (options.isPrintAST()) {
Logger.debug("AST:\n%s", result.getAST());
}
if (options.isTest()) {
Set<String> data = new HashSet<String>(); | // Path: Support/rsense-0.2/src/org/cx4a/rsense/ruby/IRubyObject.java
// public interface IRubyObject {
// public Ruby getRuntime();
// public RubyClass getMetaClass();
// public void setMetaClass(RubyClass metaClass);
// public RubyClass getSingletonClass();
// public RubyClass makeMetaClass(RubyClass superClass);
// public IRubyObject getInstVar(String name);
// public void setInstVar(String name, IRubyObject value);
// public boolean isNil();
// public boolean isInstanceOf(RubyModule klass);
// public boolean isKindOf(RubyModule klass);
// public Object getTag();
// public void setTag(Object tag);
// }
// Path: Support/rsense-0.2/src/org/cx4a/rsense/Main.java
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;
import java.util.Properties;
import java.io.File;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.io.Reader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
import org.jruby.Ruby;
import org.jruby.ast.Node;
import org.cx4a.rsense.ruby.IRubyObject;
import org.cx4a.rsense.util.Logger;
import org.cx4a.rsense.util.HereDocReader;
codeAssistError(result, options);
}
}
} catch (Exception e) {
commandException(e, options);
}
}
private void commandTypeInference(Options options) {
try {
TypeInferenceResult result;
Project project = codeAssist.getProject(options);
if (options.isFileStdin()) {
result = codeAssist.typeInference(project,
new File("(stdin)"),
options.getHereDocReader(inReader),
options.getLocation());
} else {
result = codeAssist.typeInference(project,
options.getFile(),
options.getEncoding(),
options.getLocation());
}
if (options.isPrintAST()) {
Logger.debug("AST:\n%s", result.getAST());
}
if (options.isTest()) {
Set<String> data = new HashSet<String>(); | for (IRubyObject klass : result.getTypeSet()) { |
eandrejko/RSense.tmbundle | Support/rsense-0.2/src/org/cx4a/rsense/util/SourceLocation.java | // Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/Vertex.java
// public class Vertex {
// protected Node node;
// protected TypeSet typeSet;
// protected List<Vertex> edges;
//
// public Vertex() {
// this(null);
// }
//
// public Vertex(Node node) {
// this(node, new TypeSet());
// }
//
// public Vertex(Node node, TypeSet typeSet) {
// this.node = node;
// this.typeSet = typeSet;
// edges = new ArrayList<Vertex>();
// }
//
// public Node getNode() {
// return node;
// }
//
// public TypeSet getTypeSet() {
// return typeSet;
// }
//
// public List<Vertex> getEdges() {
// return edges;
// }
//
// public boolean isEmpty() {
// return typeSet.isEmpty();
// }
//
// public void addType(IRubyObject type) {
// typeSet.add(type);
// }
//
// public void addTypeSet(TypeSet typeSet) {
// this.typeSet.addAll(typeSet);
// }
//
// public void copyTypeSet(Vertex other) {
// typeSet.addAll(other.getTypeSet());
// }
//
// public IRubyObject singleType() {
// if (typeSet.size() != 1) {
// return null;
// }
// return typeSet.iterator().next();
// }
//
// public void addEdge(Vertex dest) {
// edges.add(dest);
// }
//
// public void removeEdge(Vertex dest) {
// edges.remove(dest);
// }
//
// public boolean accept(Propagation propagation, Vertex src) {
// return propagation.getGraph().propagateVertex(propagation, this, src);
// }
//
// public boolean isFree() {
// return node == null;
// }
//
// @Override
// public String toString() {
// return typeSet.toString();
// }
//
// public static String getName(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof INameNode) {
// return ((INameNode) node).getName();
// } else {
// return null;
// }
// }
//
// public static Integer getFixnum(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof FixnumNode) {
// return Integer.valueOf((int) ((FixnumNode) node).getValue());
// } else {
// return null;
// }
// }
//
// public static String getString(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof StrNode) {
// return ((StrNode) node).getValue().toString();
// } else {
// return null;
// }
// }
//
// public static String getSymbol(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof SymbolNode) {
// return ((SymbolNode) node).getName();
// } else {
// return null;
// }
// }
//
// public static String getStringOrSymbol(Vertex vertex) {
// String value = getString(vertex);
// return value != null ? value : getSymbol(vertex);
// }
// }
| import org.jruby.ast.Node;
import org.jruby.lexer.yacc.ISourcePosition;
import org.cx4a.rsense.typing.vertex.Vertex; | package org.cx4a.rsense.util;
public class SourceLocation {
private String file;
private int line;
public SourceLocation(String file, int line) {
this.file = file;
this.line = line;
}
public String getFile() {
return file;
}
public int getLine() {
return line;
}
@Override
public String toString() {
return file + ":" + line;
}
public static SourceLocation of(Node node) {
ISourcePosition pos = node.getPosition();
if (pos != null && pos != ISourcePosition.INVALID_POSITION) {
return new SourceLocation(pos.getFile(), pos.getStartLine() + 1);
} else {
return null;
}
}
| // Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/Vertex.java
// public class Vertex {
// protected Node node;
// protected TypeSet typeSet;
// protected List<Vertex> edges;
//
// public Vertex() {
// this(null);
// }
//
// public Vertex(Node node) {
// this(node, new TypeSet());
// }
//
// public Vertex(Node node, TypeSet typeSet) {
// this.node = node;
// this.typeSet = typeSet;
// edges = new ArrayList<Vertex>();
// }
//
// public Node getNode() {
// return node;
// }
//
// public TypeSet getTypeSet() {
// return typeSet;
// }
//
// public List<Vertex> getEdges() {
// return edges;
// }
//
// public boolean isEmpty() {
// return typeSet.isEmpty();
// }
//
// public void addType(IRubyObject type) {
// typeSet.add(type);
// }
//
// public void addTypeSet(TypeSet typeSet) {
// this.typeSet.addAll(typeSet);
// }
//
// public void copyTypeSet(Vertex other) {
// typeSet.addAll(other.getTypeSet());
// }
//
// public IRubyObject singleType() {
// if (typeSet.size() != 1) {
// return null;
// }
// return typeSet.iterator().next();
// }
//
// public void addEdge(Vertex dest) {
// edges.add(dest);
// }
//
// public void removeEdge(Vertex dest) {
// edges.remove(dest);
// }
//
// public boolean accept(Propagation propagation, Vertex src) {
// return propagation.getGraph().propagateVertex(propagation, this, src);
// }
//
// public boolean isFree() {
// return node == null;
// }
//
// @Override
// public String toString() {
// return typeSet.toString();
// }
//
// public static String getName(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof INameNode) {
// return ((INameNode) node).getName();
// } else {
// return null;
// }
// }
//
// public static Integer getFixnum(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof FixnumNode) {
// return Integer.valueOf((int) ((FixnumNode) node).getValue());
// } else {
// return null;
// }
// }
//
// public static String getString(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof StrNode) {
// return ((StrNode) node).getValue().toString();
// } else {
// return null;
// }
// }
//
// public static String getSymbol(Vertex vertex) {
// Node node = vertex.getNode();
// if (node instanceof SymbolNode) {
// return ((SymbolNode) node).getName();
// } else {
// return null;
// }
// }
//
// public static String getStringOrSymbol(Vertex vertex) {
// String value = getString(vertex);
// return value != null ? value : getSymbol(vertex);
// }
// }
// Path: Support/rsense-0.2/src/org/cx4a/rsense/util/SourceLocation.java
import org.jruby.ast.Node;
import org.jruby.lexer.yacc.ISourcePosition;
import org.cx4a.rsense.typing.vertex.Vertex;
package org.cx4a.rsense.util;
public class SourceLocation {
private String file;
private int line;
public SourceLocation(String file, int line) {
this.file = file;
this.line = line;
}
public String getFile() {
return file;
}
public int getLine() {
return line;
}
@Override
public String toString() {
return file + ":" + line;
}
public static SourceLocation of(Node node) {
ISourcePosition pos = node.getPosition();
if (pos != null && pos != ISourcePosition.INVALID_POSITION) {
return new SourceLocation(pos.getFile(), pos.getStartLine() + 1);
} else {
return null;
}
}
| public static SourceLocation of(Vertex vertex) { |
eandrejko/RSense.tmbundle | Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/CallVertex.java | // Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Propagation.java
// public class Propagation {
// private Graph graph;
// private Set<Object> visited;
// private int refCount;
//
// public Propagation(Graph graph) {
// this.graph = graph;
// this.refCount = 0;
// }
//
// public Graph getGraph() {
// return graph;
// }
//
// public boolean isVisited(Vertex vertex) {
// return visited != null ? visited.contains(getVisitTag(vertex)) : false;
// }
//
// public void addVisited(Vertex vertex) {
// if (visited == null) {
// // lazy allocation
// visited = new HashSet<Object>();
// }
// visited.add(getVisitTag(vertex));
// }
//
// public boolean checkVisited(Vertex vertex) {
// if (isVisited(vertex)) {
// return true;
// } else {
// addVisited(vertex);
// return false;
// }
// }
//
// public void retain() {
// refCount++;
// }
//
// public boolean release() {
// return --refCount == 0;
// }
//
// private Object getVisitTag(Vertex vertex) {
// return vertex.getNode() != null ? vertex.getNode() : vertex;
// }
// }
| import org.jruby.RubyClass;
import org.jruby.ast.Node;
import org.jruby.ast.types.INameNode;
import org.cx4a.rsense.ruby.Block;
import org.cx4a.rsense.typing.Propagation; | public Block getBlock() {
return block;
}
public boolean hasPrivateVisibility() {
return privateVisibility;
}
public void setPrivateVisibility(boolean privateVisibility) {
this.privateVisibility = privateVisibility;
}
public boolean isApplicable() {
if (receiverVertex == null || receiverVertex.isEmpty()) {
return false;
}
boolean applicable = true;
if (argVertices != null) {
for (Vertex v : argVertices) {
if (v.isEmpty()) {
applicable = false;
break;
}
}
}
return applicable;
}
@Override | // Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Propagation.java
// public class Propagation {
// private Graph graph;
// private Set<Object> visited;
// private int refCount;
//
// public Propagation(Graph graph) {
// this.graph = graph;
// this.refCount = 0;
// }
//
// public Graph getGraph() {
// return graph;
// }
//
// public boolean isVisited(Vertex vertex) {
// return visited != null ? visited.contains(getVisitTag(vertex)) : false;
// }
//
// public void addVisited(Vertex vertex) {
// if (visited == null) {
// // lazy allocation
// visited = new HashSet<Object>();
// }
// visited.add(getVisitTag(vertex));
// }
//
// public boolean checkVisited(Vertex vertex) {
// if (isVisited(vertex)) {
// return true;
// } else {
// addVisited(vertex);
// return false;
// }
// }
//
// public void retain() {
// refCount++;
// }
//
// public boolean release() {
// return --refCount == 0;
// }
//
// private Object getVisitTag(Vertex vertex) {
// return vertex.getNode() != null ? vertex.getNode() : vertex;
// }
// }
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/CallVertex.java
import org.jruby.RubyClass;
import org.jruby.ast.Node;
import org.jruby.ast.types.INameNode;
import org.cx4a.rsense.ruby.Block;
import org.cx4a.rsense.typing.Propagation;
public Block getBlock() {
return block;
}
public boolean hasPrivateVisibility() {
return privateVisibility;
}
public void setPrivateVisibility(boolean privateVisibility) {
this.privateVisibility = privateVisibility;
}
public boolean isApplicable() {
if (receiverVertex == null || receiverVertex.isEmpty()) {
return false;
}
boolean applicable = true;
if (argVertices != null) {
for (Vertex v : argVertices) {
if (v.isEmpty()) {
applicable = false;
break;
}
}
}
return applicable;
}
@Override | public boolean accept(Propagation propagation, Vertex src) { |
eandrejko/RSense.tmbundle | Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/Vertex.java | // Path: Support/rsense-0.2/src/org/cx4a/rsense/ruby/IRubyObject.java
// public interface IRubyObject {
// public Ruby getRuntime();
// public RubyClass getMetaClass();
// public void setMetaClass(RubyClass metaClass);
// public RubyClass getSingletonClass();
// public RubyClass makeMetaClass(RubyClass superClass);
// public IRubyObject getInstVar(String name);
// public void setInstVar(String name, IRubyObject value);
// public boolean isNil();
// public boolean isInstanceOf(RubyModule klass);
// public boolean isKindOf(RubyModule klass);
// public Object getTag();
// public void setTag(Object tag);
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/TypeSet.java
// public class TypeSet extends HashSet<IRubyObject> {
// private static final long serialVersionUID = 0L;
// public static final int MEGAMORPHIC_THRESHOLD = 5;
// public static final TypeSet EMPTY = new TypeSet();
//
// private boolean megamorphic;
//
// public TypeSet() {
// super();
// }
//
// public TypeSet(TypeSet other) {
// super(other);
// }
//
// public boolean add(IRubyObject e) {
// if (megamorphic) return false;
//
// if (size() >= MEGAMORPHIC_THRESHOLD) {
// megamorphic = true;
// // FIXME simple way
// Logger.warn("megamorphic detected");
// clear();
// return super.add(new RubyObject(e.getRuntime(), e.getRuntime().getObject()));
// } else {
// return super.add(e);
// }
// }
//
// public boolean addAll(Collection<? extends IRubyObject> c) {
// boolean changed = false;
// for (IRubyObject e : c) {
// if (add(e)) {
// changed = true;
// }
// }
// return changed;
// }
//
// public boolean isMegamorphic() {
// return megamorphic;
// }
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Propagation.java
// public class Propagation {
// private Graph graph;
// private Set<Object> visited;
// private int refCount;
//
// public Propagation(Graph graph) {
// this.graph = graph;
// this.refCount = 0;
// }
//
// public Graph getGraph() {
// return graph;
// }
//
// public boolean isVisited(Vertex vertex) {
// return visited != null ? visited.contains(getVisitTag(vertex)) : false;
// }
//
// public void addVisited(Vertex vertex) {
// if (visited == null) {
// // lazy allocation
// visited = new HashSet<Object>();
// }
// visited.add(getVisitTag(vertex));
// }
//
// public boolean checkVisited(Vertex vertex) {
// if (isVisited(vertex)) {
// return true;
// } else {
// addVisited(vertex);
// return false;
// }
// }
//
// public void retain() {
// refCount++;
// }
//
// public boolean release() {
// return --refCount == 0;
// }
//
// private Object getVisitTag(Vertex vertex) {
// return vertex.getNode() != null ? vertex.getNode() : vertex;
// }
// }
| import java.util.List;
import java.util.ArrayList;
import org.jruby.ast.Node;
import org.jruby.ast.FixnumNode;
import org.jruby.ast.StrNode;
import org.jruby.ast.SymbolNode;
import org.jruby.ast.types.INameNode;
import org.cx4a.rsense.ruby.IRubyObject;
import org.cx4a.rsense.typing.TypeSet;
import org.cx4a.rsense.typing.Propagation; | package org.cx4a.rsense.typing.vertex;
public class Vertex {
protected Node node; | // Path: Support/rsense-0.2/src/org/cx4a/rsense/ruby/IRubyObject.java
// public interface IRubyObject {
// public Ruby getRuntime();
// public RubyClass getMetaClass();
// public void setMetaClass(RubyClass metaClass);
// public RubyClass getSingletonClass();
// public RubyClass makeMetaClass(RubyClass superClass);
// public IRubyObject getInstVar(String name);
// public void setInstVar(String name, IRubyObject value);
// public boolean isNil();
// public boolean isInstanceOf(RubyModule klass);
// public boolean isKindOf(RubyModule klass);
// public Object getTag();
// public void setTag(Object tag);
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/TypeSet.java
// public class TypeSet extends HashSet<IRubyObject> {
// private static final long serialVersionUID = 0L;
// public static final int MEGAMORPHIC_THRESHOLD = 5;
// public static final TypeSet EMPTY = new TypeSet();
//
// private boolean megamorphic;
//
// public TypeSet() {
// super();
// }
//
// public TypeSet(TypeSet other) {
// super(other);
// }
//
// public boolean add(IRubyObject e) {
// if (megamorphic) return false;
//
// if (size() >= MEGAMORPHIC_THRESHOLD) {
// megamorphic = true;
// // FIXME simple way
// Logger.warn("megamorphic detected");
// clear();
// return super.add(new RubyObject(e.getRuntime(), e.getRuntime().getObject()));
// } else {
// return super.add(e);
// }
// }
//
// public boolean addAll(Collection<? extends IRubyObject> c) {
// boolean changed = false;
// for (IRubyObject e : c) {
// if (add(e)) {
// changed = true;
// }
// }
// return changed;
// }
//
// public boolean isMegamorphic() {
// return megamorphic;
// }
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Propagation.java
// public class Propagation {
// private Graph graph;
// private Set<Object> visited;
// private int refCount;
//
// public Propagation(Graph graph) {
// this.graph = graph;
// this.refCount = 0;
// }
//
// public Graph getGraph() {
// return graph;
// }
//
// public boolean isVisited(Vertex vertex) {
// return visited != null ? visited.contains(getVisitTag(vertex)) : false;
// }
//
// public void addVisited(Vertex vertex) {
// if (visited == null) {
// // lazy allocation
// visited = new HashSet<Object>();
// }
// visited.add(getVisitTag(vertex));
// }
//
// public boolean checkVisited(Vertex vertex) {
// if (isVisited(vertex)) {
// return true;
// } else {
// addVisited(vertex);
// return false;
// }
// }
//
// public void retain() {
// refCount++;
// }
//
// public boolean release() {
// return --refCount == 0;
// }
//
// private Object getVisitTag(Vertex vertex) {
// return vertex.getNode() != null ? vertex.getNode() : vertex;
// }
// }
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/Vertex.java
import java.util.List;
import java.util.ArrayList;
import org.jruby.ast.Node;
import org.jruby.ast.FixnumNode;
import org.jruby.ast.StrNode;
import org.jruby.ast.SymbolNode;
import org.jruby.ast.types.INameNode;
import org.cx4a.rsense.ruby.IRubyObject;
import org.cx4a.rsense.typing.TypeSet;
import org.cx4a.rsense.typing.Propagation;
package org.cx4a.rsense.typing.vertex;
public class Vertex {
protected Node node; | protected TypeSet typeSet; |
eandrejko/RSense.tmbundle | Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/Vertex.java | // Path: Support/rsense-0.2/src/org/cx4a/rsense/ruby/IRubyObject.java
// public interface IRubyObject {
// public Ruby getRuntime();
// public RubyClass getMetaClass();
// public void setMetaClass(RubyClass metaClass);
// public RubyClass getSingletonClass();
// public RubyClass makeMetaClass(RubyClass superClass);
// public IRubyObject getInstVar(String name);
// public void setInstVar(String name, IRubyObject value);
// public boolean isNil();
// public boolean isInstanceOf(RubyModule klass);
// public boolean isKindOf(RubyModule klass);
// public Object getTag();
// public void setTag(Object tag);
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/TypeSet.java
// public class TypeSet extends HashSet<IRubyObject> {
// private static final long serialVersionUID = 0L;
// public static final int MEGAMORPHIC_THRESHOLD = 5;
// public static final TypeSet EMPTY = new TypeSet();
//
// private boolean megamorphic;
//
// public TypeSet() {
// super();
// }
//
// public TypeSet(TypeSet other) {
// super(other);
// }
//
// public boolean add(IRubyObject e) {
// if (megamorphic) return false;
//
// if (size() >= MEGAMORPHIC_THRESHOLD) {
// megamorphic = true;
// // FIXME simple way
// Logger.warn("megamorphic detected");
// clear();
// return super.add(new RubyObject(e.getRuntime(), e.getRuntime().getObject()));
// } else {
// return super.add(e);
// }
// }
//
// public boolean addAll(Collection<? extends IRubyObject> c) {
// boolean changed = false;
// for (IRubyObject e : c) {
// if (add(e)) {
// changed = true;
// }
// }
// return changed;
// }
//
// public boolean isMegamorphic() {
// return megamorphic;
// }
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Propagation.java
// public class Propagation {
// private Graph graph;
// private Set<Object> visited;
// private int refCount;
//
// public Propagation(Graph graph) {
// this.graph = graph;
// this.refCount = 0;
// }
//
// public Graph getGraph() {
// return graph;
// }
//
// public boolean isVisited(Vertex vertex) {
// return visited != null ? visited.contains(getVisitTag(vertex)) : false;
// }
//
// public void addVisited(Vertex vertex) {
// if (visited == null) {
// // lazy allocation
// visited = new HashSet<Object>();
// }
// visited.add(getVisitTag(vertex));
// }
//
// public boolean checkVisited(Vertex vertex) {
// if (isVisited(vertex)) {
// return true;
// } else {
// addVisited(vertex);
// return false;
// }
// }
//
// public void retain() {
// refCount++;
// }
//
// public boolean release() {
// return --refCount == 0;
// }
//
// private Object getVisitTag(Vertex vertex) {
// return vertex.getNode() != null ? vertex.getNode() : vertex;
// }
// }
| import java.util.List;
import java.util.ArrayList;
import org.jruby.ast.Node;
import org.jruby.ast.FixnumNode;
import org.jruby.ast.StrNode;
import org.jruby.ast.SymbolNode;
import org.jruby.ast.types.INameNode;
import org.cx4a.rsense.ruby.IRubyObject;
import org.cx4a.rsense.typing.TypeSet;
import org.cx4a.rsense.typing.Propagation; | package org.cx4a.rsense.typing.vertex;
public class Vertex {
protected Node node;
protected TypeSet typeSet;
protected List<Vertex> edges;
public Vertex() {
this(null);
}
public Vertex(Node node) {
this(node, new TypeSet());
}
public Vertex(Node node, TypeSet typeSet) {
this.node = node;
this.typeSet = typeSet;
edges = new ArrayList<Vertex>();
}
public Node getNode() {
return node;
}
public TypeSet getTypeSet() {
return typeSet;
}
public List<Vertex> getEdges() {
return edges;
}
public boolean isEmpty() {
return typeSet.isEmpty();
}
| // Path: Support/rsense-0.2/src/org/cx4a/rsense/ruby/IRubyObject.java
// public interface IRubyObject {
// public Ruby getRuntime();
// public RubyClass getMetaClass();
// public void setMetaClass(RubyClass metaClass);
// public RubyClass getSingletonClass();
// public RubyClass makeMetaClass(RubyClass superClass);
// public IRubyObject getInstVar(String name);
// public void setInstVar(String name, IRubyObject value);
// public boolean isNil();
// public boolean isInstanceOf(RubyModule klass);
// public boolean isKindOf(RubyModule klass);
// public Object getTag();
// public void setTag(Object tag);
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/TypeSet.java
// public class TypeSet extends HashSet<IRubyObject> {
// private static final long serialVersionUID = 0L;
// public static final int MEGAMORPHIC_THRESHOLD = 5;
// public static final TypeSet EMPTY = new TypeSet();
//
// private boolean megamorphic;
//
// public TypeSet() {
// super();
// }
//
// public TypeSet(TypeSet other) {
// super(other);
// }
//
// public boolean add(IRubyObject e) {
// if (megamorphic) return false;
//
// if (size() >= MEGAMORPHIC_THRESHOLD) {
// megamorphic = true;
// // FIXME simple way
// Logger.warn("megamorphic detected");
// clear();
// return super.add(new RubyObject(e.getRuntime(), e.getRuntime().getObject()));
// } else {
// return super.add(e);
// }
// }
//
// public boolean addAll(Collection<? extends IRubyObject> c) {
// boolean changed = false;
// for (IRubyObject e : c) {
// if (add(e)) {
// changed = true;
// }
// }
// return changed;
// }
//
// public boolean isMegamorphic() {
// return megamorphic;
// }
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Propagation.java
// public class Propagation {
// private Graph graph;
// private Set<Object> visited;
// private int refCount;
//
// public Propagation(Graph graph) {
// this.graph = graph;
// this.refCount = 0;
// }
//
// public Graph getGraph() {
// return graph;
// }
//
// public boolean isVisited(Vertex vertex) {
// return visited != null ? visited.contains(getVisitTag(vertex)) : false;
// }
//
// public void addVisited(Vertex vertex) {
// if (visited == null) {
// // lazy allocation
// visited = new HashSet<Object>();
// }
// visited.add(getVisitTag(vertex));
// }
//
// public boolean checkVisited(Vertex vertex) {
// if (isVisited(vertex)) {
// return true;
// } else {
// addVisited(vertex);
// return false;
// }
// }
//
// public void retain() {
// refCount++;
// }
//
// public boolean release() {
// return --refCount == 0;
// }
//
// private Object getVisitTag(Vertex vertex) {
// return vertex.getNode() != null ? vertex.getNode() : vertex;
// }
// }
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/Vertex.java
import java.util.List;
import java.util.ArrayList;
import org.jruby.ast.Node;
import org.jruby.ast.FixnumNode;
import org.jruby.ast.StrNode;
import org.jruby.ast.SymbolNode;
import org.jruby.ast.types.INameNode;
import org.cx4a.rsense.ruby.IRubyObject;
import org.cx4a.rsense.typing.TypeSet;
import org.cx4a.rsense.typing.Propagation;
package org.cx4a.rsense.typing.vertex;
public class Vertex {
protected Node node;
protected TypeSet typeSet;
protected List<Vertex> edges;
public Vertex() {
this(null);
}
public Vertex(Node node) {
this(node, new TypeSet());
}
public Vertex(Node node, TypeSet typeSet) {
this.node = node;
this.typeSet = typeSet;
edges = new ArrayList<Vertex>();
}
public Node getNode() {
return node;
}
public TypeSet getTypeSet() {
return typeSet;
}
public List<Vertex> getEdges() {
return edges;
}
public boolean isEmpty() {
return typeSet.isEmpty();
}
| public void addType(IRubyObject type) { |
eandrejko/RSense.tmbundle | Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/Vertex.java | // Path: Support/rsense-0.2/src/org/cx4a/rsense/ruby/IRubyObject.java
// public interface IRubyObject {
// public Ruby getRuntime();
// public RubyClass getMetaClass();
// public void setMetaClass(RubyClass metaClass);
// public RubyClass getSingletonClass();
// public RubyClass makeMetaClass(RubyClass superClass);
// public IRubyObject getInstVar(String name);
// public void setInstVar(String name, IRubyObject value);
// public boolean isNil();
// public boolean isInstanceOf(RubyModule klass);
// public boolean isKindOf(RubyModule klass);
// public Object getTag();
// public void setTag(Object tag);
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/TypeSet.java
// public class TypeSet extends HashSet<IRubyObject> {
// private static final long serialVersionUID = 0L;
// public static final int MEGAMORPHIC_THRESHOLD = 5;
// public static final TypeSet EMPTY = new TypeSet();
//
// private boolean megamorphic;
//
// public TypeSet() {
// super();
// }
//
// public TypeSet(TypeSet other) {
// super(other);
// }
//
// public boolean add(IRubyObject e) {
// if (megamorphic) return false;
//
// if (size() >= MEGAMORPHIC_THRESHOLD) {
// megamorphic = true;
// // FIXME simple way
// Logger.warn("megamorphic detected");
// clear();
// return super.add(new RubyObject(e.getRuntime(), e.getRuntime().getObject()));
// } else {
// return super.add(e);
// }
// }
//
// public boolean addAll(Collection<? extends IRubyObject> c) {
// boolean changed = false;
// for (IRubyObject e : c) {
// if (add(e)) {
// changed = true;
// }
// }
// return changed;
// }
//
// public boolean isMegamorphic() {
// return megamorphic;
// }
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Propagation.java
// public class Propagation {
// private Graph graph;
// private Set<Object> visited;
// private int refCount;
//
// public Propagation(Graph graph) {
// this.graph = graph;
// this.refCount = 0;
// }
//
// public Graph getGraph() {
// return graph;
// }
//
// public boolean isVisited(Vertex vertex) {
// return visited != null ? visited.contains(getVisitTag(vertex)) : false;
// }
//
// public void addVisited(Vertex vertex) {
// if (visited == null) {
// // lazy allocation
// visited = new HashSet<Object>();
// }
// visited.add(getVisitTag(vertex));
// }
//
// public boolean checkVisited(Vertex vertex) {
// if (isVisited(vertex)) {
// return true;
// } else {
// addVisited(vertex);
// return false;
// }
// }
//
// public void retain() {
// refCount++;
// }
//
// public boolean release() {
// return --refCount == 0;
// }
//
// private Object getVisitTag(Vertex vertex) {
// return vertex.getNode() != null ? vertex.getNode() : vertex;
// }
// }
| import java.util.List;
import java.util.ArrayList;
import org.jruby.ast.Node;
import org.jruby.ast.FixnumNode;
import org.jruby.ast.StrNode;
import org.jruby.ast.SymbolNode;
import org.jruby.ast.types.INameNode;
import org.cx4a.rsense.ruby.IRubyObject;
import org.cx4a.rsense.typing.TypeSet;
import org.cx4a.rsense.typing.Propagation; | return typeSet.isEmpty();
}
public void addType(IRubyObject type) {
typeSet.add(type);
}
public void addTypeSet(TypeSet typeSet) {
this.typeSet.addAll(typeSet);
}
public void copyTypeSet(Vertex other) {
typeSet.addAll(other.getTypeSet());
}
public IRubyObject singleType() {
if (typeSet.size() != 1) {
return null;
}
return typeSet.iterator().next();
}
public void addEdge(Vertex dest) {
edges.add(dest);
}
public void removeEdge(Vertex dest) {
edges.remove(dest);
}
| // Path: Support/rsense-0.2/src/org/cx4a/rsense/ruby/IRubyObject.java
// public interface IRubyObject {
// public Ruby getRuntime();
// public RubyClass getMetaClass();
// public void setMetaClass(RubyClass metaClass);
// public RubyClass getSingletonClass();
// public RubyClass makeMetaClass(RubyClass superClass);
// public IRubyObject getInstVar(String name);
// public void setInstVar(String name, IRubyObject value);
// public boolean isNil();
// public boolean isInstanceOf(RubyModule klass);
// public boolean isKindOf(RubyModule klass);
// public Object getTag();
// public void setTag(Object tag);
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/TypeSet.java
// public class TypeSet extends HashSet<IRubyObject> {
// private static final long serialVersionUID = 0L;
// public static final int MEGAMORPHIC_THRESHOLD = 5;
// public static final TypeSet EMPTY = new TypeSet();
//
// private boolean megamorphic;
//
// public TypeSet() {
// super();
// }
//
// public TypeSet(TypeSet other) {
// super(other);
// }
//
// public boolean add(IRubyObject e) {
// if (megamorphic) return false;
//
// if (size() >= MEGAMORPHIC_THRESHOLD) {
// megamorphic = true;
// // FIXME simple way
// Logger.warn("megamorphic detected");
// clear();
// return super.add(new RubyObject(e.getRuntime(), e.getRuntime().getObject()));
// } else {
// return super.add(e);
// }
// }
//
// public boolean addAll(Collection<? extends IRubyObject> c) {
// boolean changed = false;
// for (IRubyObject e : c) {
// if (add(e)) {
// changed = true;
// }
// }
// return changed;
// }
//
// public boolean isMegamorphic() {
// return megamorphic;
// }
// }
//
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/Propagation.java
// public class Propagation {
// private Graph graph;
// private Set<Object> visited;
// private int refCount;
//
// public Propagation(Graph graph) {
// this.graph = graph;
// this.refCount = 0;
// }
//
// public Graph getGraph() {
// return graph;
// }
//
// public boolean isVisited(Vertex vertex) {
// return visited != null ? visited.contains(getVisitTag(vertex)) : false;
// }
//
// public void addVisited(Vertex vertex) {
// if (visited == null) {
// // lazy allocation
// visited = new HashSet<Object>();
// }
// visited.add(getVisitTag(vertex));
// }
//
// public boolean checkVisited(Vertex vertex) {
// if (isVisited(vertex)) {
// return true;
// } else {
// addVisited(vertex);
// return false;
// }
// }
//
// public void retain() {
// refCount++;
// }
//
// public boolean release() {
// return --refCount == 0;
// }
//
// private Object getVisitTag(Vertex vertex) {
// return vertex.getNode() != null ? vertex.getNode() : vertex;
// }
// }
// Path: Support/rsense-0.2/src/org/cx4a/rsense/typing/vertex/Vertex.java
import java.util.List;
import java.util.ArrayList;
import org.jruby.ast.Node;
import org.jruby.ast.FixnumNode;
import org.jruby.ast.StrNode;
import org.jruby.ast.SymbolNode;
import org.jruby.ast.types.INameNode;
import org.cx4a.rsense.ruby.IRubyObject;
import org.cx4a.rsense.typing.TypeSet;
import org.cx4a.rsense.typing.Propagation;
return typeSet.isEmpty();
}
public void addType(IRubyObject type) {
typeSet.add(type);
}
public void addTypeSet(TypeSet typeSet) {
this.typeSet.addAll(typeSet);
}
public void copyTypeSet(Vertex other) {
typeSet.addAll(other.getTypeSet());
}
public IRubyObject singleType() {
if (typeSet.size() != 1) {
return null;
}
return typeSet.iterator().next();
}
public void addEdge(Vertex dest) {
edges.add(dest);
}
public void removeEdge(Vertex dest) {
edges.remove(dest);
}
| public boolean accept(Propagation propagation, Vertex src) { |
pcdv/jocket | src/test/java/jocket/sample/TestClient.java | // Path: src/main/java/jocket/net/JocketSocket.java
// public class JocketSocket {
//
// private static Thread hook;
//
// private static final Vector<JocketSocket> sockets = new Vector<JocketSocket>();
//
// private final JocketReader reader;
//
// private final JocketWriter writer;
//
// private final JocketOutputStream output;
//
// private final JocketInputStream input;
//
// JocketSocket(JocketReader reader, JocketWriter writer) {
// this.reader = reader;
// this.writer = writer;
// this.output = new JocketOutputStream(writer);
// this.input = new JocketInputStream(reader);
// addShutdownHook(this);
// }
//
// /**
// * Connects to specified port on local host (loopback interface) and returns
// * a pseudo-socket using shared memory to communicate.
// *
// * @param port
// * @throws IOException
// */
// public JocketSocket(int port) throws IOException {
// // FIXME: getLoopackAddress() == @since 1.7
// Socket s = new Socket(InetAddress.getByName(null), port);
// // allows to wakeup if server never does the handshake
// s.setSoTimeout(5000);
//
// DataOutputStream out = new DataOutputStream(s.getOutputStream());
// out.writeInt(ServerJocket.MAGIC);
// out.flush();
//
// DataInputStream in = new DataInputStream(s.getInputStream());
// int magic = 0;
// try {
// magic = in.readInt();
// }
// catch (SocketTimeoutException timeout) {
// }
//
// if (magic != ServerJocket.MAGIC) {
// s.close();
// throw new IOException("Server does not support Jocket protocol");
// }
//
// File r = new File(in.readUTF());
// File w = new File(in.readUTF());
//
// JocketFile jfr = new JocketFile(r);
// JocketFile jfw = new JocketFile(w);
//
// jfr.deleteFile();
// jfw.deleteFile();
//
// out.writeInt(0);
// s.close();
//
// this.reader = jfr.reader();
// this.writer = jfw.writer();
//
// if (Futex.isAvailable()) {
// writer.useFutex();
// reader.useFutex();
// }
//
// this.output = new JocketOutputStream(writer);
// this.input = new JocketInputStream(reader);
//
// addShutdownHook(this);
// }
//
// private synchronized static void addShutdownHook(JocketSocket s) {
//
// if (hook == null) {
// hook = new Thread("Jocket-shutdown") {
// @Override
// public void run() {
// for (JocketSocket s : sockets) {
// s.close();
// }
// }
// };
// Runtime.getRuntime().addShutdownHook(hook);
// }
// sockets.add(s);
// }
//
// public JocketReader getReader() {
// return reader;
// }
//
// public JocketWriter getWriter() {
// return writer;
// }
//
// public OutputStream getOutputStream() {
// return output;
// }
//
// public InputStream getInputStream() {
// return input;
// }
//
// public void close() {
// reader.close();
// writer.close();
// }
//
// }
| import java.io.IOException;
import jocket.net.JocketSocket; | package jocket.sample;
public class TestClient {
public static void main(String[] args) throws NumberFormatException,
IOException { | // Path: src/main/java/jocket/net/JocketSocket.java
// public class JocketSocket {
//
// private static Thread hook;
//
// private static final Vector<JocketSocket> sockets = new Vector<JocketSocket>();
//
// private final JocketReader reader;
//
// private final JocketWriter writer;
//
// private final JocketOutputStream output;
//
// private final JocketInputStream input;
//
// JocketSocket(JocketReader reader, JocketWriter writer) {
// this.reader = reader;
// this.writer = writer;
// this.output = new JocketOutputStream(writer);
// this.input = new JocketInputStream(reader);
// addShutdownHook(this);
// }
//
// /**
// * Connects to specified port on local host (loopback interface) and returns
// * a pseudo-socket using shared memory to communicate.
// *
// * @param port
// * @throws IOException
// */
// public JocketSocket(int port) throws IOException {
// // FIXME: getLoopackAddress() == @since 1.7
// Socket s = new Socket(InetAddress.getByName(null), port);
// // allows to wakeup if server never does the handshake
// s.setSoTimeout(5000);
//
// DataOutputStream out = new DataOutputStream(s.getOutputStream());
// out.writeInt(ServerJocket.MAGIC);
// out.flush();
//
// DataInputStream in = new DataInputStream(s.getInputStream());
// int magic = 0;
// try {
// magic = in.readInt();
// }
// catch (SocketTimeoutException timeout) {
// }
//
// if (magic != ServerJocket.MAGIC) {
// s.close();
// throw new IOException("Server does not support Jocket protocol");
// }
//
// File r = new File(in.readUTF());
// File w = new File(in.readUTF());
//
// JocketFile jfr = new JocketFile(r);
// JocketFile jfw = new JocketFile(w);
//
// jfr.deleteFile();
// jfw.deleteFile();
//
// out.writeInt(0);
// s.close();
//
// this.reader = jfr.reader();
// this.writer = jfw.writer();
//
// if (Futex.isAvailable()) {
// writer.useFutex();
// reader.useFutex();
// }
//
// this.output = new JocketOutputStream(writer);
// this.input = new JocketInputStream(reader);
//
// addShutdownHook(this);
// }
//
// private synchronized static void addShutdownHook(JocketSocket s) {
//
// if (hook == null) {
// hook = new Thread("Jocket-shutdown") {
// @Override
// public void run() {
// for (JocketSocket s : sockets) {
// s.close();
// }
// }
// };
// Runtime.getRuntime().addShutdownHook(hook);
// }
// sockets.add(s);
// }
//
// public JocketReader getReader() {
// return reader;
// }
//
// public JocketWriter getWriter() {
// return writer;
// }
//
// public OutputStream getOutputStream() {
// return output;
// }
//
// public InputStream getInputStream() {
// return input;
// }
//
// public void close() {
// reader.close();
// writer.close();
// }
//
// }
// Path: src/test/java/jocket/sample/TestClient.java
import java.io.IOException;
import jocket.net.JocketSocket;
package jocket.sample;
public class TestClient {
public static void main(String[] args) throws NumberFormatException,
IOException { | TestServer.pipeToStdInOut(new JocketSocket(Integer.parseInt(args[0]))); |
pcdv/jocket | src/main/java/jocket/impl/JocketOutputStream.java | // Path: src/main/java/jocket/wait/BusyYieldSleep.java
// public class BusyYieldSleep implements WaitStrategy {
//
// public static final int SPIN = 1000000;
//
// public static final int YIELD = SPIN + 1;
//
// public static final int SLEEP = YIELD + 1;
//
// private int counter;
//
// @Override
// public void pauseWhile(int seq) {
// int counter = this.counter++;
// if (counter < SPIN)
// return;
// else if (counter < YIELD)
// Thread.yield();
// else if (counter < SLEEP)
// LockSupport.parkNanos(1);
// else {
// this.counter = 0;
// }
// }
//
// @Override
// public void reset() {
// counter = 0;
// }
// }
//
// Path: src/main/java/jocket/wait/WaitStrategy.java
// public interface WaitStrategy {
//
// /**
// * Pauses for some time.
// * @param seq TODO
// */
// void pauseWhile(int seq);
//
// /**
// * Resets the strategy. Called when data has been read or written
// * successfully.
// */
// void reset();
//
// }
| import java.io.OutputStream;
import jocket.wait.BusyYieldSleep;
import jocket.wait.WaitStrategy; | package jocket.impl;
public class JocketOutputStream extends OutputStream {
private final JocketWriter writer; | // Path: src/main/java/jocket/wait/BusyYieldSleep.java
// public class BusyYieldSleep implements WaitStrategy {
//
// public static final int SPIN = 1000000;
//
// public static final int YIELD = SPIN + 1;
//
// public static final int SLEEP = YIELD + 1;
//
// private int counter;
//
// @Override
// public void pauseWhile(int seq) {
// int counter = this.counter++;
// if (counter < SPIN)
// return;
// else if (counter < YIELD)
// Thread.yield();
// else if (counter < SLEEP)
// LockSupport.parkNanos(1);
// else {
// this.counter = 0;
// }
// }
//
// @Override
// public void reset() {
// counter = 0;
// }
// }
//
// Path: src/main/java/jocket/wait/WaitStrategy.java
// public interface WaitStrategy {
//
// /**
// * Pauses for some time.
// * @param seq TODO
// */
// void pauseWhile(int seq);
//
// /**
// * Resets the strategy. Called when data has been read or written
// * successfully.
// */
// void reset();
//
// }
// Path: src/main/java/jocket/impl/JocketOutputStream.java
import java.io.OutputStream;
import jocket.wait.BusyYieldSleep;
import jocket.wait.WaitStrategy;
package jocket.impl;
public class JocketOutputStream extends OutputStream {
private final JocketWriter writer; | private final WaitStrategy wait; |
pcdv/jocket | src/main/java/jocket/impl/JocketOutputStream.java | // Path: src/main/java/jocket/wait/BusyYieldSleep.java
// public class BusyYieldSleep implements WaitStrategy {
//
// public static final int SPIN = 1000000;
//
// public static final int YIELD = SPIN + 1;
//
// public static final int SLEEP = YIELD + 1;
//
// private int counter;
//
// @Override
// public void pauseWhile(int seq) {
// int counter = this.counter++;
// if (counter < SPIN)
// return;
// else if (counter < YIELD)
// Thread.yield();
// else if (counter < SLEEP)
// LockSupport.parkNanos(1);
// else {
// this.counter = 0;
// }
// }
//
// @Override
// public void reset() {
// counter = 0;
// }
// }
//
// Path: src/main/java/jocket/wait/WaitStrategy.java
// public interface WaitStrategy {
//
// /**
// * Pauses for some time.
// * @param seq TODO
// */
// void pauseWhile(int seq);
//
// /**
// * Resets the strategy. Called when data has been read or written
// * successfully.
// */
// void reset();
//
// }
| import java.io.OutputStream;
import jocket.wait.BusyYieldSleep;
import jocket.wait.WaitStrategy; | package jocket.impl;
public class JocketOutputStream extends OutputStream {
private final JocketWriter writer;
private final WaitStrategy wait;
public JocketOutputStream(JocketWriter writer, WaitStrategy wait) {
this.writer = writer;
this.wait = wait;
}
public JocketOutputStream(JocketWriter writer) { | // Path: src/main/java/jocket/wait/BusyYieldSleep.java
// public class BusyYieldSleep implements WaitStrategy {
//
// public static final int SPIN = 1000000;
//
// public static final int YIELD = SPIN + 1;
//
// public static final int SLEEP = YIELD + 1;
//
// private int counter;
//
// @Override
// public void pauseWhile(int seq) {
// int counter = this.counter++;
// if (counter < SPIN)
// return;
// else if (counter < YIELD)
// Thread.yield();
// else if (counter < SLEEP)
// LockSupport.parkNanos(1);
// else {
// this.counter = 0;
// }
// }
//
// @Override
// public void reset() {
// counter = 0;
// }
// }
//
// Path: src/main/java/jocket/wait/WaitStrategy.java
// public interface WaitStrategy {
//
// /**
// * Pauses for some time.
// * @param seq TODO
// */
// void pauseWhile(int seq);
//
// /**
// * Resets the strategy. Called when data has been read or written
// * successfully.
// */
// void reset();
//
// }
// Path: src/main/java/jocket/impl/JocketOutputStream.java
import java.io.OutputStream;
import jocket.wait.BusyYieldSleep;
import jocket.wait.WaitStrategy;
package jocket.impl;
public class JocketOutputStream extends OutputStream {
private final JocketWriter writer;
private final WaitStrategy wait;
public JocketOutputStream(JocketWriter writer, WaitStrategy wait) {
this.writer = writer;
this.wait = wait;
}
public JocketOutputStream(JocketWriter writer) { | this(writer, new BusyYieldSleep()); |
pcdv/jocket | src/main/java/jocket/impl/AbstractJocketBuffer.java | // Path: src/main/java/jocket/futex/Futex.java
// public class Futex implements WaitStrategy {
//
// private static boolean libAvailable;
//
// private final long futAddr;
//
// private final long seqAddr;
//
// private final MappedByteBuffer buf;
//
// private final int seqPos;
//
// /**
// * @param b a mapped byte buffer
// * @param futexPos position of the futex variable in buffer
// * @param seqPos position where the writer writes its latest sequence number
// */
// public Futex(MappedByteBuffer b, int futexPos, int seqPos) {
// this.buf = b;
// this.seqPos = seqPos;
// this.futAddr = computeAddress(b, futexPos);
// this.seqAddr = computeAddress(b, seqPos);
// }
//
// /**
// * Blocks until the writer posts a packet with a seqnum higher than specified.
// */
// @Override
// public void pauseWhile(int currentSeq) {
// pause(futAddr, seqAddr, currentSeq);
// }
//
// private static native void pause(long futAddr, long seqAddr, int seq);
//
// @Override
// public void reset() {
// }
//
// private static long computeAddress(MappedByteBuffer b, int pos) {
// try {
// return getAddress(b) + pos;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public int getInt(int pos) {
// return getInt0(computeAddress(buf, pos));
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public void setInt(int pos, int value) {
// setInt0(computeAddress(buf, pos), value);
// }
//
// private static native int getInt0(long addr);
//
// private static native void setInt0(long addr, int value);
//
// /**
// * Signals the reader that a new packet is available. Happens mainly during
// * flush(). It includes the cost of a JNI call and a native CAS. A FUTEX_CALL
// * syscall is performed only if necessary (i.e. the reader is waiting for
// * data).
// *
// * @param seq
// */
// public void signal(int seq) {
// signal0(futAddr);
// }
//
// @Deprecated
// public void await() {
// await0(futAddr);
// }
//
// public static native long getAddress(MappedByteBuffer b);
//
// private static native void signal0(long addr);
//
// @Deprecated
// private static native void await0(long addr);
//
// public static native long rdtsc();
//
// static {
// try {
// LibLoader.loadLibrary("JocketFutex");
// libAvailable = true;
// } catch (Throwable e) {
// libAvailable = false;
// System.err.println("WARN: JNI futex lib is NOT available: " + e);
// }
// }
//
// public static boolean isAvailable() {
// return libAvailable;
// }
// }
| import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.util.concurrent.atomic.AtomicBoolean;
import jocket.futex.Futex; | package jocket.impl;
/**
* Base class for JocketReader and JocketWriter.
*
* @author pcdv
*/
public abstract class AbstractJocketBuffer implements Const {
protected final ByteBuffer buf;
/**
* Number of data bytes that can be stored in buffer. Must be a power of 2.
*/
protected final int capacity;
/**
* Equals (capacity - 1). Allows to perform quick modulo with binary AND.
*/
protected final int dataMask;
/**
* Maximum number of packets that can be written but not read.
*/
protected final int npackets;
/**
* Equals (npackets - 1). Allows to perform quick modulo with binary AND.
*/
protected final int packetMask;
private final AtomicBoolean barrier = new AtomicBoolean();
protected final int dataOffset;
protected int resetSeqNum = Integer.MAX_VALUE >> 1;
protected boolean closed;
/**
* This indirection allows to shave off a few nanos by using Unsafe when
* possible.
*/
protected final ByteBufferAccessor acc;
public AbstractJocketBuffer(ByteBuffer buf, int npackets) {
if (Integer.bitCount(npackets) != 1)
throw new IllegalArgumentException("npackets must be a power of 2");
| // Path: src/main/java/jocket/futex/Futex.java
// public class Futex implements WaitStrategy {
//
// private static boolean libAvailable;
//
// private final long futAddr;
//
// private final long seqAddr;
//
// private final MappedByteBuffer buf;
//
// private final int seqPos;
//
// /**
// * @param b a mapped byte buffer
// * @param futexPos position of the futex variable in buffer
// * @param seqPos position where the writer writes its latest sequence number
// */
// public Futex(MappedByteBuffer b, int futexPos, int seqPos) {
// this.buf = b;
// this.seqPos = seqPos;
// this.futAddr = computeAddress(b, futexPos);
// this.seqAddr = computeAddress(b, seqPos);
// }
//
// /**
// * Blocks until the writer posts a packet with a seqnum higher than specified.
// */
// @Override
// public void pauseWhile(int currentSeq) {
// pause(futAddr, seqAddr, currentSeq);
// }
//
// private static native void pause(long futAddr, long seqAddr, int seq);
//
// @Override
// public void reset() {
// }
//
// private static long computeAddress(MappedByteBuffer b, int pos) {
// try {
// return getAddress(b) + pos;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public int getInt(int pos) {
// return getInt0(computeAddress(buf, pos));
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public void setInt(int pos, int value) {
// setInt0(computeAddress(buf, pos), value);
// }
//
// private static native int getInt0(long addr);
//
// private static native void setInt0(long addr, int value);
//
// /**
// * Signals the reader that a new packet is available. Happens mainly during
// * flush(). It includes the cost of a JNI call and a native CAS. A FUTEX_CALL
// * syscall is performed only if necessary (i.e. the reader is waiting for
// * data).
// *
// * @param seq
// */
// public void signal(int seq) {
// signal0(futAddr);
// }
//
// @Deprecated
// public void await() {
// await0(futAddr);
// }
//
// public static native long getAddress(MappedByteBuffer b);
//
// private static native void signal0(long addr);
//
// @Deprecated
// private static native void await0(long addr);
//
// public static native long rdtsc();
//
// static {
// try {
// LibLoader.loadLibrary("JocketFutex");
// libAvailable = true;
// } catch (Throwable e) {
// libAvailable = false;
// System.err.println("WARN: JNI futex lib is NOT available: " + e);
// }
// }
//
// public static boolean isAvailable() {
// return libAvailable;
// }
// }
// Path: src/main/java/jocket/impl/AbstractJocketBuffer.java
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.util.concurrent.atomic.AtomicBoolean;
import jocket.futex.Futex;
package jocket.impl;
/**
* Base class for JocketReader and JocketWriter.
*
* @author pcdv
*/
public abstract class AbstractJocketBuffer implements Const {
protected final ByteBuffer buf;
/**
* Number of data bytes that can be stored in buffer. Must be a power of 2.
*/
protected final int capacity;
/**
* Equals (capacity - 1). Allows to perform quick modulo with binary AND.
*/
protected final int dataMask;
/**
* Maximum number of packets that can be written but not read.
*/
protected final int npackets;
/**
* Equals (npackets - 1). Allows to perform quick modulo with binary AND.
*/
protected final int packetMask;
private final AtomicBoolean barrier = new AtomicBoolean();
protected final int dataOffset;
protected int resetSeqNum = Integer.MAX_VALUE >> 1;
protected boolean closed;
/**
* This indirection allows to shave off a few nanos by using Unsafe when
* possible.
*/
protected final ByteBufferAccessor acc;
public AbstractJocketBuffer(ByteBuffer buf, int npackets) {
if (Integer.bitCount(npackets) != 1)
throw new IllegalArgumentException("npackets must be a power of 2");
| if (buf instanceof MappedByteBuffer && Futex.isAvailable()) |
pcdv/jocket | src/main/java/jocket/impl/JocketReader.java | // Path: src/main/java/jocket/futex/Futex.java
// public class Futex implements WaitStrategy {
//
// private static boolean libAvailable;
//
// private final long futAddr;
//
// private final long seqAddr;
//
// private final MappedByteBuffer buf;
//
// private final int seqPos;
//
// /**
// * @param b a mapped byte buffer
// * @param futexPos position of the futex variable in buffer
// * @param seqPos position where the writer writes its latest sequence number
// */
// public Futex(MappedByteBuffer b, int futexPos, int seqPos) {
// this.buf = b;
// this.seqPos = seqPos;
// this.futAddr = computeAddress(b, futexPos);
// this.seqAddr = computeAddress(b, seqPos);
// }
//
// /**
// * Blocks until the writer posts a packet with a seqnum higher than specified.
// */
// @Override
// public void pauseWhile(int currentSeq) {
// pause(futAddr, seqAddr, currentSeq);
// }
//
// private static native void pause(long futAddr, long seqAddr, int seq);
//
// @Override
// public void reset() {
// }
//
// private static long computeAddress(MappedByteBuffer b, int pos) {
// try {
// return getAddress(b) + pos;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public int getInt(int pos) {
// return getInt0(computeAddress(buf, pos));
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public void setInt(int pos, int value) {
// setInt0(computeAddress(buf, pos), value);
// }
//
// private static native int getInt0(long addr);
//
// private static native void setInt0(long addr, int value);
//
// /**
// * Signals the reader that a new packet is available. Happens mainly during
// * flush(). It includes the cost of a JNI call and a native CAS. A FUTEX_CALL
// * syscall is performed only if necessary (i.e. the reader is waiting for
// * data).
// *
// * @param seq
// */
// public void signal(int seq) {
// signal0(futAddr);
// }
//
// @Deprecated
// public void await() {
// await0(futAddr);
// }
//
// public static native long getAddress(MappedByteBuffer b);
//
// private static native void signal0(long addr);
//
// @Deprecated
// private static native void await0(long addr);
//
// public static native long rdtsc();
//
// static {
// try {
// LibLoader.loadLibrary("JocketFutex");
// libAvailable = true;
// } catch (Throwable e) {
// libAvailable = false;
// System.err.println("WARN: JNI futex lib is NOT available: " + e);
// }
// }
//
// public static boolean isAvailable() {
// return libAvailable;
// }
// }
//
// Path: src/main/java/jocket/wait/BusyYieldSleep.java
// public class BusyYieldSleep implements WaitStrategy {
//
// public static final int SPIN = 1000000;
//
// public static final int YIELD = SPIN + 1;
//
// public static final int SLEEP = YIELD + 1;
//
// private int counter;
//
// @Override
// public void pauseWhile(int seq) {
// int counter = this.counter++;
// if (counter < SPIN)
// return;
// else if (counter < YIELD)
// Thread.yield();
// else if (counter < SLEEP)
// LockSupport.parkNanos(1);
// else {
// this.counter = 0;
// }
// }
//
// @Override
// public void reset() {
// counter = 0;
// }
// }
//
// Path: src/main/java/jocket/wait/WaitStrategy.java
// public interface WaitStrategy {
//
// /**
// * Pauses for some time.
// * @param seq TODO
// */
// void pauseWhile(int seq);
//
// /**
// * Resets the strategy. Called when data has been read or written
// * successfully.
// */
// void reset();
//
// }
| import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import jocket.futex.Futex;
import jocket.wait.BusyYieldSleep;
import jocket.wait.WaitStrategy; | package jocket.impl;
public class JocketReader extends AbstractJocketBuffer {
private int rseq;
private int wseq;
| // Path: src/main/java/jocket/futex/Futex.java
// public class Futex implements WaitStrategy {
//
// private static boolean libAvailable;
//
// private final long futAddr;
//
// private final long seqAddr;
//
// private final MappedByteBuffer buf;
//
// private final int seqPos;
//
// /**
// * @param b a mapped byte buffer
// * @param futexPos position of the futex variable in buffer
// * @param seqPos position where the writer writes its latest sequence number
// */
// public Futex(MappedByteBuffer b, int futexPos, int seqPos) {
// this.buf = b;
// this.seqPos = seqPos;
// this.futAddr = computeAddress(b, futexPos);
// this.seqAddr = computeAddress(b, seqPos);
// }
//
// /**
// * Blocks until the writer posts a packet with a seqnum higher than specified.
// */
// @Override
// public void pauseWhile(int currentSeq) {
// pause(futAddr, seqAddr, currentSeq);
// }
//
// private static native void pause(long futAddr, long seqAddr, int seq);
//
// @Override
// public void reset() {
// }
//
// private static long computeAddress(MappedByteBuffer b, int pos) {
// try {
// return getAddress(b) + pos;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public int getInt(int pos) {
// return getInt0(computeAddress(buf, pos));
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public void setInt(int pos, int value) {
// setInt0(computeAddress(buf, pos), value);
// }
//
// private static native int getInt0(long addr);
//
// private static native void setInt0(long addr, int value);
//
// /**
// * Signals the reader that a new packet is available. Happens mainly during
// * flush(). It includes the cost of a JNI call and a native CAS. A FUTEX_CALL
// * syscall is performed only if necessary (i.e. the reader is waiting for
// * data).
// *
// * @param seq
// */
// public void signal(int seq) {
// signal0(futAddr);
// }
//
// @Deprecated
// public void await() {
// await0(futAddr);
// }
//
// public static native long getAddress(MappedByteBuffer b);
//
// private static native void signal0(long addr);
//
// @Deprecated
// private static native void await0(long addr);
//
// public static native long rdtsc();
//
// static {
// try {
// LibLoader.loadLibrary("JocketFutex");
// libAvailable = true;
// } catch (Throwable e) {
// libAvailable = false;
// System.err.println("WARN: JNI futex lib is NOT available: " + e);
// }
// }
//
// public static boolean isAvailable() {
// return libAvailable;
// }
// }
//
// Path: src/main/java/jocket/wait/BusyYieldSleep.java
// public class BusyYieldSleep implements WaitStrategy {
//
// public static final int SPIN = 1000000;
//
// public static final int YIELD = SPIN + 1;
//
// public static final int SLEEP = YIELD + 1;
//
// private int counter;
//
// @Override
// public void pauseWhile(int seq) {
// int counter = this.counter++;
// if (counter < SPIN)
// return;
// else if (counter < YIELD)
// Thread.yield();
// else if (counter < SLEEP)
// LockSupport.parkNanos(1);
// else {
// this.counter = 0;
// }
// }
//
// @Override
// public void reset() {
// counter = 0;
// }
// }
//
// Path: src/main/java/jocket/wait/WaitStrategy.java
// public interface WaitStrategy {
//
// /**
// * Pauses for some time.
// * @param seq TODO
// */
// void pauseWhile(int seq);
//
// /**
// * Resets the strategy. Called when data has been read or written
// * successfully.
// */
// void reset();
//
// }
// Path: src/main/java/jocket/impl/JocketReader.java
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import jocket.futex.Futex;
import jocket.wait.BusyYieldSleep;
import jocket.wait.WaitStrategy;
package jocket.impl;
public class JocketReader extends AbstractJocketBuffer {
private int rseq;
private int wseq;
| private WaitStrategy waiter = new BusyYieldSleep(); |
pcdv/jocket | src/main/java/jocket/impl/JocketReader.java | // Path: src/main/java/jocket/futex/Futex.java
// public class Futex implements WaitStrategy {
//
// private static boolean libAvailable;
//
// private final long futAddr;
//
// private final long seqAddr;
//
// private final MappedByteBuffer buf;
//
// private final int seqPos;
//
// /**
// * @param b a mapped byte buffer
// * @param futexPos position of the futex variable in buffer
// * @param seqPos position where the writer writes its latest sequence number
// */
// public Futex(MappedByteBuffer b, int futexPos, int seqPos) {
// this.buf = b;
// this.seqPos = seqPos;
// this.futAddr = computeAddress(b, futexPos);
// this.seqAddr = computeAddress(b, seqPos);
// }
//
// /**
// * Blocks until the writer posts a packet with a seqnum higher than specified.
// */
// @Override
// public void pauseWhile(int currentSeq) {
// pause(futAddr, seqAddr, currentSeq);
// }
//
// private static native void pause(long futAddr, long seqAddr, int seq);
//
// @Override
// public void reset() {
// }
//
// private static long computeAddress(MappedByteBuffer b, int pos) {
// try {
// return getAddress(b) + pos;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public int getInt(int pos) {
// return getInt0(computeAddress(buf, pos));
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public void setInt(int pos, int value) {
// setInt0(computeAddress(buf, pos), value);
// }
//
// private static native int getInt0(long addr);
//
// private static native void setInt0(long addr, int value);
//
// /**
// * Signals the reader that a new packet is available. Happens mainly during
// * flush(). It includes the cost of a JNI call and a native CAS. A FUTEX_CALL
// * syscall is performed only if necessary (i.e. the reader is waiting for
// * data).
// *
// * @param seq
// */
// public void signal(int seq) {
// signal0(futAddr);
// }
//
// @Deprecated
// public void await() {
// await0(futAddr);
// }
//
// public static native long getAddress(MappedByteBuffer b);
//
// private static native void signal0(long addr);
//
// @Deprecated
// private static native void await0(long addr);
//
// public static native long rdtsc();
//
// static {
// try {
// LibLoader.loadLibrary("JocketFutex");
// libAvailable = true;
// } catch (Throwable e) {
// libAvailable = false;
// System.err.println("WARN: JNI futex lib is NOT available: " + e);
// }
// }
//
// public static boolean isAvailable() {
// return libAvailable;
// }
// }
//
// Path: src/main/java/jocket/wait/BusyYieldSleep.java
// public class BusyYieldSleep implements WaitStrategy {
//
// public static final int SPIN = 1000000;
//
// public static final int YIELD = SPIN + 1;
//
// public static final int SLEEP = YIELD + 1;
//
// private int counter;
//
// @Override
// public void pauseWhile(int seq) {
// int counter = this.counter++;
// if (counter < SPIN)
// return;
// else if (counter < YIELD)
// Thread.yield();
// else if (counter < SLEEP)
// LockSupport.parkNanos(1);
// else {
// this.counter = 0;
// }
// }
//
// @Override
// public void reset() {
// counter = 0;
// }
// }
//
// Path: src/main/java/jocket/wait/WaitStrategy.java
// public interface WaitStrategy {
//
// /**
// * Pauses for some time.
// * @param seq TODO
// */
// void pauseWhile(int seq);
//
// /**
// * Resets the strategy. Called when data has been read or written
// * successfully.
// */
// void reset();
//
// }
| import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import jocket.futex.Futex;
import jocket.wait.BusyYieldSleep;
import jocket.wait.WaitStrategy; | package jocket.impl;
public class JocketReader extends AbstractJocketBuffer {
private int rseq;
private int wseq;
| // Path: src/main/java/jocket/futex/Futex.java
// public class Futex implements WaitStrategy {
//
// private static boolean libAvailable;
//
// private final long futAddr;
//
// private final long seqAddr;
//
// private final MappedByteBuffer buf;
//
// private final int seqPos;
//
// /**
// * @param b a mapped byte buffer
// * @param futexPos position of the futex variable in buffer
// * @param seqPos position where the writer writes its latest sequence number
// */
// public Futex(MappedByteBuffer b, int futexPos, int seqPos) {
// this.buf = b;
// this.seqPos = seqPos;
// this.futAddr = computeAddress(b, futexPos);
// this.seqAddr = computeAddress(b, seqPos);
// }
//
// /**
// * Blocks until the writer posts a packet with a seqnum higher than specified.
// */
// @Override
// public void pauseWhile(int currentSeq) {
// pause(futAddr, seqAddr, currentSeq);
// }
//
// private static native void pause(long futAddr, long seqAddr, int seq);
//
// @Override
// public void reset() {
// }
//
// private static long computeAddress(MappedByteBuffer b, int pos) {
// try {
// return getAddress(b) + pos;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public int getInt(int pos) {
// return getInt0(computeAddress(buf, pos));
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public void setInt(int pos, int value) {
// setInt0(computeAddress(buf, pos), value);
// }
//
// private static native int getInt0(long addr);
//
// private static native void setInt0(long addr, int value);
//
// /**
// * Signals the reader that a new packet is available. Happens mainly during
// * flush(). It includes the cost of a JNI call and a native CAS. A FUTEX_CALL
// * syscall is performed only if necessary (i.e. the reader is waiting for
// * data).
// *
// * @param seq
// */
// public void signal(int seq) {
// signal0(futAddr);
// }
//
// @Deprecated
// public void await() {
// await0(futAddr);
// }
//
// public static native long getAddress(MappedByteBuffer b);
//
// private static native void signal0(long addr);
//
// @Deprecated
// private static native void await0(long addr);
//
// public static native long rdtsc();
//
// static {
// try {
// LibLoader.loadLibrary("JocketFutex");
// libAvailable = true;
// } catch (Throwable e) {
// libAvailable = false;
// System.err.println("WARN: JNI futex lib is NOT available: " + e);
// }
// }
//
// public static boolean isAvailable() {
// return libAvailable;
// }
// }
//
// Path: src/main/java/jocket/wait/BusyYieldSleep.java
// public class BusyYieldSleep implements WaitStrategy {
//
// public static final int SPIN = 1000000;
//
// public static final int YIELD = SPIN + 1;
//
// public static final int SLEEP = YIELD + 1;
//
// private int counter;
//
// @Override
// public void pauseWhile(int seq) {
// int counter = this.counter++;
// if (counter < SPIN)
// return;
// else if (counter < YIELD)
// Thread.yield();
// else if (counter < SLEEP)
// LockSupport.parkNanos(1);
// else {
// this.counter = 0;
// }
// }
//
// @Override
// public void reset() {
// counter = 0;
// }
// }
//
// Path: src/main/java/jocket/wait/WaitStrategy.java
// public interface WaitStrategy {
//
// /**
// * Pauses for some time.
// * @param seq TODO
// */
// void pauseWhile(int seq);
//
// /**
// * Resets the strategy. Called when data has been read or written
// * successfully.
// */
// void reset();
//
// }
// Path: src/main/java/jocket/impl/JocketReader.java
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import jocket.futex.Futex;
import jocket.wait.BusyYieldSleep;
import jocket.wait.WaitStrategy;
package jocket.impl;
public class JocketReader extends AbstractJocketBuffer {
private int rseq;
private int wseq;
| private WaitStrategy waiter = new BusyYieldSleep(); |
pcdv/jocket | src/main/java/jocket/impl/JocketReader.java | // Path: src/main/java/jocket/futex/Futex.java
// public class Futex implements WaitStrategy {
//
// private static boolean libAvailable;
//
// private final long futAddr;
//
// private final long seqAddr;
//
// private final MappedByteBuffer buf;
//
// private final int seqPos;
//
// /**
// * @param b a mapped byte buffer
// * @param futexPos position of the futex variable in buffer
// * @param seqPos position where the writer writes its latest sequence number
// */
// public Futex(MappedByteBuffer b, int futexPos, int seqPos) {
// this.buf = b;
// this.seqPos = seqPos;
// this.futAddr = computeAddress(b, futexPos);
// this.seqAddr = computeAddress(b, seqPos);
// }
//
// /**
// * Blocks until the writer posts a packet with a seqnum higher than specified.
// */
// @Override
// public void pauseWhile(int currentSeq) {
// pause(futAddr, seqAddr, currentSeq);
// }
//
// private static native void pause(long futAddr, long seqAddr, int seq);
//
// @Override
// public void reset() {
// }
//
// private static long computeAddress(MappedByteBuffer b, int pos) {
// try {
// return getAddress(b) + pos;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public int getInt(int pos) {
// return getInt0(computeAddress(buf, pos));
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public void setInt(int pos, int value) {
// setInt0(computeAddress(buf, pos), value);
// }
//
// private static native int getInt0(long addr);
//
// private static native void setInt0(long addr, int value);
//
// /**
// * Signals the reader that a new packet is available. Happens mainly during
// * flush(). It includes the cost of a JNI call and a native CAS. A FUTEX_CALL
// * syscall is performed only if necessary (i.e. the reader is waiting for
// * data).
// *
// * @param seq
// */
// public void signal(int seq) {
// signal0(futAddr);
// }
//
// @Deprecated
// public void await() {
// await0(futAddr);
// }
//
// public static native long getAddress(MappedByteBuffer b);
//
// private static native void signal0(long addr);
//
// @Deprecated
// private static native void await0(long addr);
//
// public static native long rdtsc();
//
// static {
// try {
// LibLoader.loadLibrary("JocketFutex");
// libAvailable = true;
// } catch (Throwable e) {
// libAvailable = false;
// System.err.println("WARN: JNI futex lib is NOT available: " + e);
// }
// }
//
// public static boolean isAvailable() {
// return libAvailable;
// }
// }
//
// Path: src/main/java/jocket/wait/BusyYieldSleep.java
// public class BusyYieldSleep implements WaitStrategy {
//
// public static final int SPIN = 1000000;
//
// public static final int YIELD = SPIN + 1;
//
// public static final int SLEEP = YIELD + 1;
//
// private int counter;
//
// @Override
// public void pauseWhile(int seq) {
// int counter = this.counter++;
// if (counter < SPIN)
// return;
// else if (counter < YIELD)
// Thread.yield();
// else if (counter < SLEEP)
// LockSupport.parkNanos(1);
// else {
// this.counter = 0;
// }
// }
//
// @Override
// public void reset() {
// counter = 0;
// }
// }
//
// Path: src/main/java/jocket/wait/WaitStrategy.java
// public interface WaitStrategy {
//
// /**
// * Pauses for some time.
// * @param seq TODO
// */
// void pauseWhile(int seq);
//
// /**
// * Resets the strategy. Called when data has been read or written
// * successfully.
// */
// void reset();
//
// }
| import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import jocket.futex.Futex;
import jocket.wait.BusyYieldSleep;
import jocket.wait.WaitStrategy; | else {
final int pktInfo = PACKET_INFO + (rseq & packetMask) * LEN_PACKET_INFO;
acc.putInt(pktInfo + 4, packet.remaining());
acc.putInt(pktInfo, packet.position());
}
}
private void readWseq() {
wseq = acc.getInt(WSEQ);
}
public int available() {
int wseq = acc.getInt(WSEQ);
if (wseq <= rseq)
return 0;
int windex = (wseq - 1) & packetMask; // last packet written
int rindex = rseq & packetMask; // first packet written
int start = acc.getInt(PACKET_INFO + rindex * LEN_PACKET_INFO);
int end = acc.getInt(PACKET_INFO + windex * LEN_PACKET_INFO)
+ acc.getInt(PACKET_INFO + windex * LEN_PACKET_INFO + 4);
if (start <= end)
return end - start;
else
return capacity - (start - end);
}
public void useFutex() { | // Path: src/main/java/jocket/futex/Futex.java
// public class Futex implements WaitStrategy {
//
// private static boolean libAvailable;
//
// private final long futAddr;
//
// private final long seqAddr;
//
// private final MappedByteBuffer buf;
//
// private final int seqPos;
//
// /**
// * @param b a mapped byte buffer
// * @param futexPos position of the futex variable in buffer
// * @param seqPos position where the writer writes its latest sequence number
// */
// public Futex(MappedByteBuffer b, int futexPos, int seqPos) {
// this.buf = b;
// this.seqPos = seqPos;
// this.futAddr = computeAddress(b, futexPos);
// this.seqAddr = computeAddress(b, seqPos);
// }
//
// /**
// * Blocks until the writer posts a packet with a seqnum higher than specified.
// */
// @Override
// public void pauseWhile(int currentSeq) {
// pause(futAddr, seqAddr, currentSeq);
// }
//
// private static native void pause(long futAddr, long seqAddr, int seq);
//
// @Override
// public void reset() {
// }
//
// private static long computeAddress(MappedByteBuffer b, int pos) {
// try {
// return getAddress(b) + pos;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public int getInt(int pos) {
// return getInt0(computeAddress(buf, pos));
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public void setInt(int pos, int value) {
// setInt0(computeAddress(buf, pos), value);
// }
//
// private static native int getInt0(long addr);
//
// private static native void setInt0(long addr, int value);
//
// /**
// * Signals the reader that a new packet is available. Happens mainly during
// * flush(). It includes the cost of a JNI call and a native CAS. A FUTEX_CALL
// * syscall is performed only if necessary (i.e. the reader is waiting for
// * data).
// *
// * @param seq
// */
// public void signal(int seq) {
// signal0(futAddr);
// }
//
// @Deprecated
// public void await() {
// await0(futAddr);
// }
//
// public static native long getAddress(MappedByteBuffer b);
//
// private static native void signal0(long addr);
//
// @Deprecated
// private static native void await0(long addr);
//
// public static native long rdtsc();
//
// static {
// try {
// LibLoader.loadLibrary("JocketFutex");
// libAvailable = true;
// } catch (Throwable e) {
// libAvailable = false;
// System.err.println("WARN: JNI futex lib is NOT available: " + e);
// }
// }
//
// public static boolean isAvailable() {
// return libAvailable;
// }
// }
//
// Path: src/main/java/jocket/wait/BusyYieldSleep.java
// public class BusyYieldSleep implements WaitStrategy {
//
// public static final int SPIN = 1000000;
//
// public static final int YIELD = SPIN + 1;
//
// public static final int SLEEP = YIELD + 1;
//
// private int counter;
//
// @Override
// public void pauseWhile(int seq) {
// int counter = this.counter++;
// if (counter < SPIN)
// return;
// else if (counter < YIELD)
// Thread.yield();
// else if (counter < SLEEP)
// LockSupport.parkNanos(1);
// else {
// this.counter = 0;
// }
// }
//
// @Override
// public void reset() {
// counter = 0;
// }
// }
//
// Path: src/main/java/jocket/wait/WaitStrategy.java
// public interface WaitStrategy {
//
// /**
// * Pauses for some time.
// * @param seq TODO
// */
// void pauseWhile(int seq);
//
// /**
// * Resets the strategy. Called when data has been read or written
// * successfully.
// */
// void reset();
//
// }
// Path: src/main/java/jocket/impl/JocketReader.java
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import jocket.futex.Futex;
import jocket.wait.BusyYieldSleep;
import jocket.wait.WaitStrategy;
else {
final int pktInfo = PACKET_INFO + (rseq & packetMask) * LEN_PACKET_INFO;
acc.putInt(pktInfo + 4, packet.remaining());
acc.putInt(pktInfo, packet.position());
}
}
private void readWseq() {
wseq = acc.getInt(WSEQ);
}
public int available() {
int wseq = acc.getInt(WSEQ);
if (wseq <= rseq)
return 0;
int windex = (wseq - 1) & packetMask; // last packet written
int rindex = rseq & packetMask; // first packet written
int start = acc.getInt(PACKET_INFO + rindex * LEN_PACKET_INFO);
int end = acc.getInt(PACKET_INFO + windex * LEN_PACKET_INFO)
+ acc.getInt(PACKET_INFO + windex * LEN_PACKET_INFO + 4);
if (start <= end)
return end - start;
else
return capacity - (start - end);
}
public void useFutex() { | this.waiter = new Futex((MappedByteBuffer) buf, FUTEX, WSEQ); |
pcdv/jocket | src/test/java/jocket/bench/BenchClient2.java | // Path: src/main/java/jocket/net/JocketSocket.java
// public class JocketSocket {
//
// private static Thread hook;
//
// private static final Vector<JocketSocket> sockets = new Vector<JocketSocket>();
//
// private final JocketReader reader;
//
// private final JocketWriter writer;
//
// private final JocketOutputStream output;
//
// private final JocketInputStream input;
//
// JocketSocket(JocketReader reader, JocketWriter writer) {
// this.reader = reader;
// this.writer = writer;
// this.output = new JocketOutputStream(writer);
// this.input = new JocketInputStream(reader);
// addShutdownHook(this);
// }
//
// /**
// * Connects to specified port on local host (loopback interface) and returns
// * a pseudo-socket using shared memory to communicate.
// *
// * @param port
// * @throws IOException
// */
// public JocketSocket(int port) throws IOException {
// // FIXME: getLoopackAddress() == @since 1.7
// Socket s = new Socket(InetAddress.getByName(null), port);
// // allows to wakeup if server never does the handshake
// s.setSoTimeout(5000);
//
// DataOutputStream out = new DataOutputStream(s.getOutputStream());
// out.writeInt(ServerJocket.MAGIC);
// out.flush();
//
// DataInputStream in = new DataInputStream(s.getInputStream());
// int magic = 0;
// try {
// magic = in.readInt();
// }
// catch (SocketTimeoutException timeout) {
// }
//
// if (magic != ServerJocket.MAGIC) {
// s.close();
// throw new IOException("Server does not support Jocket protocol");
// }
//
// File r = new File(in.readUTF());
// File w = new File(in.readUTF());
//
// JocketFile jfr = new JocketFile(r);
// JocketFile jfw = new JocketFile(w);
//
// jfr.deleteFile();
// jfw.deleteFile();
//
// out.writeInt(0);
// s.close();
//
// this.reader = jfr.reader();
// this.writer = jfw.writer();
//
// if (Futex.isAvailable()) {
// writer.useFutex();
// reader.useFutex();
// }
//
// this.output = new JocketOutputStream(writer);
// this.input = new JocketInputStream(reader);
//
// addShutdownHook(this);
// }
//
// private synchronized static void addShutdownHook(JocketSocket s) {
//
// if (hook == null) {
// hook = new Thread("Jocket-shutdown") {
// @Override
// public void run() {
// for (JocketSocket s : sockets) {
// s.close();
// }
// }
// };
// Runtime.getRuntime().addShutdownHook(hook);
// }
// sockets.add(s);
// }
//
// public JocketReader getReader() {
// return reader;
// }
//
// public JocketWriter getWriter() {
// return writer;
// }
//
// public OutputStream getOutputStream() {
// return output;
// }
//
// public InputStream getInputStream() {
// return input;
// }
//
// public void close() {
// reader.close();
// writer.close();
// }
//
// }
| import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import jocket.net.JocketSocket; | package jocket.bench;
/**
* Infinite benchmark, meant for profiling.
*
* @author pcdv
*/
public final class BenchClient2 implements Settings {
private final byte[] buf;
private final DataInputStream in;
private final DataOutputStream out;
public BenchClient2() throws IOException {
this.buf = new byte[REPLY_SIZE]; | // Path: src/main/java/jocket/net/JocketSocket.java
// public class JocketSocket {
//
// private static Thread hook;
//
// private static final Vector<JocketSocket> sockets = new Vector<JocketSocket>();
//
// private final JocketReader reader;
//
// private final JocketWriter writer;
//
// private final JocketOutputStream output;
//
// private final JocketInputStream input;
//
// JocketSocket(JocketReader reader, JocketWriter writer) {
// this.reader = reader;
// this.writer = writer;
// this.output = new JocketOutputStream(writer);
// this.input = new JocketInputStream(reader);
// addShutdownHook(this);
// }
//
// /**
// * Connects to specified port on local host (loopback interface) and returns
// * a pseudo-socket using shared memory to communicate.
// *
// * @param port
// * @throws IOException
// */
// public JocketSocket(int port) throws IOException {
// // FIXME: getLoopackAddress() == @since 1.7
// Socket s = new Socket(InetAddress.getByName(null), port);
// // allows to wakeup if server never does the handshake
// s.setSoTimeout(5000);
//
// DataOutputStream out = new DataOutputStream(s.getOutputStream());
// out.writeInt(ServerJocket.MAGIC);
// out.flush();
//
// DataInputStream in = new DataInputStream(s.getInputStream());
// int magic = 0;
// try {
// magic = in.readInt();
// }
// catch (SocketTimeoutException timeout) {
// }
//
// if (magic != ServerJocket.MAGIC) {
// s.close();
// throw new IOException("Server does not support Jocket protocol");
// }
//
// File r = new File(in.readUTF());
// File w = new File(in.readUTF());
//
// JocketFile jfr = new JocketFile(r);
// JocketFile jfw = new JocketFile(w);
//
// jfr.deleteFile();
// jfw.deleteFile();
//
// out.writeInt(0);
// s.close();
//
// this.reader = jfr.reader();
// this.writer = jfw.writer();
//
// if (Futex.isAvailable()) {
// writer.useFutex();
// reader.useFutex();
// }
//
// this.output = new JocketOutputStream(writer);
// this.input = new JocketInputStream(reader);
//
// addShutdownHook(this);
// }
//
// private synchronized static void addShutdownHook(JocketSocket s) {
//
// if (hook == null) {
// hook = new Thread("Jocket-shutdown") {
// @Override
// public void run() {
// for (JocketSocket s : sockets) {
// s.close();
// }
// }
// };
// Runtime.getRuntime().addShutdownHook(hook);
// }
// sockets.add(s);
// }
//
// public JocketReader getReader() {
// return reader;
// }
//
// public JocketWriter getWriter() {
// return writer;
// }
//
// public OutputStream getOutputStream() {
// return output;
// }
//
// public InputStream getInputStream() {
// return input;
// }
//
// public void close() {
// reader.close();
// writer.close();
// }
//
// }
// Path: src/test/java/jocket/bench/BenchClient2.java
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import jocket.net.JocketSocket;
package jocket.bench;
/**
* Infinite benchmark, meant for profiling.
*
* @author pcdv
*/
public final class BenchClient2 implements Settings {
private final byte[] buf;
private final DataInputStream in;
private final DataOutputStream out;
public BenchClient2() throws IOException {
this.buf = new byte[REPLY_SIZE]; | JocketSocket s = new JocketSocket(PORT); |
pcdv/jocket | src/test/java/jocket/bench/BenchClient.java | // Path: src/main/java/jocket/net/JocketSocket.java
// public class JocketSocket {
//
// private static Thread hook;
//
// private static final Vector<JocketSocket> sockets = new Vector<JocketSocket>();
//
// private final JocketReader reader;
//
// private final JocketWriter writer;
//
// private final JocketOutputStream output;
//
// private final JocketInputStream input;
//
// JocketSocket(JocketReader reader, JocketWriter writer) {
// this.reader = reader;
// this.writer = writer;
// this.output = new JocketOutputStream(writer);
// this.input = new JocketInputStream(reader);
// addShutdownHook(this);
// }
//
// /**
// * Connects to specified port on local host (loopback interface) and returns
// * a pseudo-socket using shared memory to communicate.
// *
// * @param port
// * @throws IOException
// */
// public JocketSocket(int port) throws IOException {
// // FIXME: getLoopackAddress() == @since 1.7
// Socket s = new Socket(InetAddress.getByName(null), port);
// // allows to wakeup if server never does the handshake
// s.setSoTimeout(5000);
//
// DataOutputStream out = new DataOutputStream(s.getOutputStream());
// out.writeInt(ServerJocket.MAGIC);
// out.flush();
//
// DataInputStream in = new DataInputStream(s.getInputStream());
// int magic = 0;
// try {
// magic = in.readInt();
// }
// catch (SocketTimeoutException timeout) {
// }
//
// if (magic != ServerJocket.MAGIC) {
// s.close();
// throw new IOException("Server does not support Jocket protocol");
// }
//
// File r = new File(in.readUTF());
// File w = new File(in.readUTF());
//
// JocketFile jfr = new JocketFile(r);
// JocketFile jfw = new JocketFile(w);
//
// jfr.deleteFile();
// jfw.deleteFile();
//
// out.writeInt(0);
// s.close();
//
// this.reader = jfr.reader();
// this.writer = jfw.writer();
//
// if (Futex.isAvailable()) {
// writer.useFutex();
// reader.useFutex();
// }
//
// this.output = new JocketOutputStream(writer);
// this.input = new JocketInputStream(reader);
//
// addShutdownHook(this);
// }
//
// private synchronized static void addShutdownHook(JocketSocket s) {
//
// if (hook == null) {
// hook = new Thread("Jocket-shutdown") {
// @Override
// public void run() {
// for (JocketSocket s : sockets) {
// s.close();
// }
// }
// };
// Runtime.getRuntime().addShutdownHook(hook);
// }
// sockets.add(s);
// }
//
// public JocketReader getReader() {
// return reader;
// }
//
// public JocketWriter getWriter() {
// return writer;
// }
//
// public OutputStream getOutputStream() {
// return output;
// }
//
// public InputStream getInputStream() {
// return input;
// }
//
// public void close() {
// reader.close();
// writer.close();
// }
//
// }
| import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Arrays;
import java.util.concurrent.locks.LockSupport;
import jocket.net.JocketSocket; | package jocket.bench;
/**
* Client (and master) part of the client/server benchmark.
*
* @author pcdv
*/
public final class BenchClient implements Settings {
private final byte[] buf;
private final long[] nanos;
private DataInputStream in;
private DataOutputStream out;
public BenchClient() throws IOException {
this.nanos = new long[NOSTATS ? 0 : REPS];
this.buf = new byte[Math.max(REPLY_SIZE, 4)];
if (USE_JOCKET) { | // Path: src/main/java/jocket/net/JocketSocket.java
// public class JocketSocket {
//
// private static Thread hook;
//
// private static final Vector<JocketSocket> sockets = new Vector<JocketSocket>();
//
// private final JocketReader reader;
//
// private final JocketWriter writer;
//
// private final JocketOutputStream output;
//
// private final JocketInputStream input;
//
// JocketSocket(JocketReader reader, JocketWriter writer) {
// this.reader = reader;
// this.writer = writer;
// this.output = new JocketOutputStream(writer);
// this.input = new JocketInputStream(reader);
// addShutdownHook(this);
// }
//
// /**
// * Connects to specified port on local host (loopback interface) and returns
// * a pseudo-socket using shared memory to communicate.
// *
// * @param port
// * @throws IOException
// */
// public JocketSocket(int port) throws IOException {
// // FIXME: getLoopackAddress() == @since 1.7
// Socket s = new Socket(InetAddress.getByName(null), port);
// // allows to wakeup if server never does the handshake
// s.setSoTimeout(5000);
//
// DataOutputStream out = new DataOutputStream(s.getOutputStream());
// out.writeInt(ServerJocket.MAGIC);
// out.flush();
//
// DataInputStream in = new DataInputStream(s.getInputStream());
// int magic = 0;
// try {
// magic = in.readInt();
// }
// catch (SocketTimeoutException timeout) {
// }
//
// if (magic != ServerJocket.MAGIC) {
// s.close();
// throw new IOException("Server does not support Jocket protocol");
// }
//
// File r = new File(in.readUTF());
// File w = new File(in.readUTF());
//
// JocketFile jfr = new JocketFile(r);
// JocketFile jfw = new JocketFile(w);
//
// jfr.deleteFile();
// jfw.deleteFile();
//
// out.writeInt(0);
// s.close();
//
// this.reader = jfr.reader();
// this.writer = jfw.writer();
//
// if (Futex.isAvailable()) {
// writer.useFutex();
// reader.useFutex();
// }
//
// this.output = new JocketOutputStream(writer);
// this.input = new JocketInputStream(reader);
//
// addShutdownHook(this);
// }
//
// private synchronized static void addShutdownHook(JocketSocket s) {
//
// if (hook == null) {
// hook = new Thread("Jocket-shutdown") {
// @Override
// public void run() {
// for (JocketSocket s : sockets) {
// s.close();
// }
// }
// };
// Runtime.getRuntime().addShutdownHook(hook);
// }
// sockets.add(s);
// }
//
// public JocketReader getReader() {
// return reader;
// }
//
// public JocketWriter getWriter() {
// return writer;
// }
//
// public OutputStream getOutputStream() {
// return output;
// }
//
// public InputStream getInputStream() {
// return input;
// }
//
// public void close() {
// reader.close();
// writer.close();
// }
//
// }
// Path: src/test/java/jocket/bench/BenchClient.java
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Arrays;
import java.util.concurrent.locks.LockSupport;
import jocket.net.JocketSocket;
package jocket.bench;
/**
* Client (and master) part of the client/server benchmark.
*
* @author pcdv
*/
public final class BenchClient implements Settings {
private final byte[] buf;
private final long[] nanos;
private DataInputStream in;
private DataOutputStream out;
public BenchClient() throws IOException {
this.nanos = new long[NOSTATS ? 0 : REPS];
this.buf = new byte[Math.max(REPLY_SIZE, 4)];
if (USE_JOCKET) { | JocketSocket s = new JocketSocket(PORT); |
pcdv/jocket | src/main/java/jocket/impl/DefaultAccessor.java | // Path: src/main/java/jocket/net/JocketFile.java
// public class JocketFile implements Const {
//
// private final MappedByteBuffer buf;
//
// private final RandomAccessFile io;
//
// private final JocketReader reader;
//
// private final JocketWriter writer;
//
// private final File file;
//
// /**
// * Creates a new exchange file and associated reader and writer.
// */
// public JocketFile(int maxPackets, int capacity) throws IOException {
// this(createTempFile(), true, maxPackets, capacity);
// }
//
// /**
// * Opens and wrap specified exchange file with a reader and writer.
// */
// public JocketFile(File file) throws IOException {
// this(file, false, -1, -1);
// }
//
// private JocketFile(File file, boolean create, int maxPackets, int capacity) throws IOException {
// if (!create && !file.exists())
// throw new FileNotFoundException("File does not exist");
//
// this.file = file;
// this.io = new RandomAccessFile(file, "rw");
//
// if (create) {
// int size = capacity + PACKET_INFO + maxPackets * LEN_PACKET_INFO;
// io.setLength(0);
//
// // append data instead of just setting the size: in case we are using
// // a real filesystem, this could avoid getting a fragmented file
// // (or not)
// for (int i = 0; i < size; i += 1024) {
// io.write(new byte[1024]);
// }
// io.setLength(size);
// }
//
// FileChannel channel = io.getChannel();
// buf = channel.map(MapMode.READ_WRITE, 0, io.length());
// buf.order(ByteOrder.nativeOrder());
// buf.load();
// channel.close();
//
// if (create) {
// buf.putInt(META_MAX_PACKETS, maxPackets);
// buf.putInt(META_CAPACITY, capacity);
// buf.force();
// }
// else {
// maxPackets = buf.getInt(META_MAX_PACKETS);
// }
//
// reader = new JocketReader(buf, maxPackets);
// writer = new JocketWriter(buf, maxPackets);
//
// file.deleteOnExit();
// }
//
// public JocketReader reader() {
// return reader;
// }
//
// public JocketWriter writer() {
// return writer;
// }
//
// public String getPath() {
// return file.getAbsolutePath();
// }
//
// /**
// * Deletes the file to make it harder to sniff stream. Can be called (at
// * least under linux) after both endpoints have opened the file.
// */
// public void deleteFile() {
// file.delete();
// }
//
// private static File createTempFile() throws IOException {
// try {
// // under linux, try to use tmpfs
// File dir = new File("/dev/shm");
// if (dir.exists()) {
// File file =
// new File(dir, "jocket-" + new Random().nextInt(Integer.MAX_VALUE));
// new FileOutputStream(file).close();
// return file;
// }
// }
// catch (Exception ex) {
// }
// System.err.println("Could not create file in /dev/shm");
// return File.createTempFile("jocket", "");
// }
//
// public MappedByteBuffer getBuffer() {
// return buf;
// }
//
// public static void unmap(MappedByteBuffer buffer)
// {
// sun.misc.Cleaner cleaner = ((DirectBuffer) buffer).cleaner();
// cleaner.clean();
// }
// }
| import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import jocket.net.JocketFile; | return buf.get(pos);
}
public void put(int pos, byte val) {
buf.put(pos, val);
}
public void position(int pos) {
buf.position(pos);
}
public void put(byte[] data, int off, int bytes) {
buf.put(data, off, bytes);
}
public void get(byte[] data, int off, int available) {
buf.get(data, off, available);
}
public ByteBuffer getBuffer() {
return buf;
}
public void limit(int limit) {
buf.limit(limit);
}
@Override
public void unmap() {
if (buf instanceof MappedByteBuffer) | // Path: src/main/java/jocket/net/JocketFile.java
// public class JocketFile implements Const {
//
// private final MappedByteBuffer buf;
//
// private final RandomAccessFile io;
//
// private final JocketReader reader;
//
// private final JocketWriter writer;
//
// private final File file;
//
// /**
// * Creates a new exchange file and associated reader and writer.
// */
// public JocketFile(int maxPackets, int capacity) throws IOException {
// this(createTempFile(), true, maxPackets, capacity);
// }
//
// /**
// * Opens and wrap specified exchange file with a reader and writer.
// */
// public JocketFile(File file) throws IOException {
// this(file, false, -1, -1);
// }
//
// private JocketFile(File file, boolean create, int maxPackets, int capacity) throws IOException {
// if (!create && !file.exists())
// throw new FileNotFoundException("File does not exist");
//
// this.file = file;
// this.io = new RandomAccessFile(file, "rw");
//
// if (create) {
// int size = capacity + PACKET_INFO + maxPackets * LEN_PACKET_INFO;
// io.setLength(0);
//
// // append data instead of just setting the size: in case we are using
// // a real filesystem, this could avoid getting a fragmented file
// // (or not)
// for (int i = 0; i < size; i += 1024) {
// io.write(new byte[1024]);
// }
// io.setLength(size);
// }
//
// FileChannel channel = io.getChannel();
// buf = channel.map(MapMode.READ_WRITE, 0, io.length());
// buf.order(ByteOrder.nativeOrder());
// buf.load();
// channel.close();
//
// if (create) {
// buf.putInt(META_MAX_PACKETS, maxPackets);
// buf.putInt(META_CAPACITY, capacity);
// buf.force();
// }
// else {
// maxPackets = buf.getInt(META_MAX_PACKETS);
// }
//
// reader = new JocketReader(buf, maxPackets);
// writer = new JocketWriter(buf, maxPackets);
//
// file.deleteOnExit();
// }
//
// public JocketReader reader() {
// return reader;
// }
//
// public JocketWriter writer() {
// return writer;
// }
//
// public String getPath() {
// return file.getAbsolutePath();
// }
//
// /**
// * Deletes the file to make it harder to sniff stream. Can be called (at
// * least under linux) after both endpoints have opened the file.
// */
// public void deleteFile() {
// file.delete();
// }
//
// private static File createTempFile() throws IOException {
// try {
// // under linux, try to use tmpfs
// File dir = new File("/dev/shm");
// if (dir.exists()) {
// File file =
// new File(dir, "jocket-" + new Random().nextInt(Integer.MAX_VALUE));
// new FileOutputStream(file).close();
// return file;
// }
// }
// catch (Exception ex) {
// }
// System.err.println("Could not create file in /dev/shm");
// return File.createTempFile("jocket", "");
// }
//
// public MappedByteBuffer getBuffer() {
// return buf;
// }
//
// public static void unmap(MappedByteBuffer buffer)
// {
// sun.misc.Cleaner cleaner = ((DirectBuffer) buffer).cleaner();
// cleaner.clean();
// }
// }
// Path: src/main/java/jocket/impl/DefaultAccessor.java
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import jocket.net.JocketFile;
return buf.get(pos);
}
public void put(int pos, byte val) {
buf.put(pos, val);
}
public void position(int pos) {
buf.position(pos);
}
public void put(byte[] data, int off, int bytes) {
buf.put(data, off, bytes);
}
public void get(byte[] data, int off, int available) {
buf.get(data, off, available);
}
public ByteBuffer getBuffer() {
return buf;
}
public void limit(int limit) {
buf.limit(limit);
}
@Override
public void unmap() {
if (buf instanceof MappedByteBuffer) | JocketFile.unmap((MappedByteBuffer) buf); |
pcdv/jocket | src/main/java/jocket/impl/JocketWriter.java | // Path: src/main/java/jocket/futex/Futex.java
// public class Futex implements WaitStrategy {
//
// private static boolean libAvailable;
//
// private final long futAddr;
//
// private final long seqAddr;
//
// private final MappedByteBuffer buf;
//
// private final int seqPos;
//
// /**
// * @param b a mapped byte buffer
// * @param futexPos position of the futex variable in buffer
// * @param seqPos position where the writer writes its latest sequence number
// */
// public Futex(MappedByteBuffer b, int futexPos, int seqPos) {
// this.buf = b;
// this.seqPos = seqPos;
// this.futAddr = computeAddress(b, futexPos);
// this.seqAddr = computeAddress(b, seqPos);
// }
//
// /**
// * Blocks until the writer posts a packet with a seqnum higher than specified.
// */
// @Override
// public void pauseWhile(int currentSeq) {
// pause(futAddr, seqAddr, currentSeq);
// }
//
// private static native void pause(long futAddr, long seqAddr, int seq);
//
// @Override
// public void reset() {
// }
//
// private static long computeAddress(MappedByteBuffer b, int pos) {
// try {
// return getAddress(b) + pos;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public int getInt(int pos) {
// return getInt0(computeAddress(buf, pos));
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public void setInt(int pos, int value) {
// setInt0(computeAddress(buf, pos), value);
// }
//
// private static native int getInt0(long addr);
//
// private static native void setInt0(long addr, int value);
//
// /**
// * Signals the reader that a new packet is available. Happens mainly during
// * flush(). It includes the cost of a JNI call and a native CAS. A FUTEX_CALL
// * syscall is performed only if necessary (i.e. the reader is waiting for
// * data).
// *
// * @param seq
// */
// public void signal(int seq) {
// signal0(futAddr);
// }
//
// @Deprecated
// public void await() {
// await0(futAddr);
// }
//
// public static native long getAddress(MappedByteBuffer b);
//
// private static native void signal0(long addr);
//
// @Deprecated
// private static native void await0(long addr);
//
// public static native long rdtsc();
//
// static {
// try {
// LibLoader.loadLibrary("JocketFutex");
// libAvailable = true;
// } catch (Throwable e) {
// libAvailable = false;
// System.err.println("WARN: JNI futex lib is NOT available: " + e);
// }
// }
//
// public static boolean isAvailable() {
// return libAvailable;
// }
// }
| import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import jocket.futex.Futex; | package jocket.impl;
public class JocketWriter extends AbstractJocketBuffer {
/** The sequence number of the next packet to write. */
private int wseq;
/** Pending packet's absolute start and end positions. */
private int pstart, pend;
/**
* Equivalent to (pend > pstart) but looks like it is faster to store this
* information in a dedicated boolean.
*/
private boolean dirty;
/**
* Optional packet alignment. By default we align on cache lines to avoid
* having several packets in the same cache line, which would cause false
* sharing (reader and writer threads would access the same line
* concurrently).
*/
private int align = _CACHELINE;
/**
* Used to modulo on align size.
*/
private int alignMask = _CACHELINE - 1;
| // Path: src/main/java/jocket/futex/Futex.java
// public class Futex implements WaitStrategy {
//
// private static boolean libAvailable;
//
// private final long futAddr;
//
// private final long seqAddr;
//
// private final MappedByteBuffer buf;
//
// private final int seqPos;
//
// /**
// * @param b a mapped byte buffer
// * @param futexPos position of the futex variable in buffer
// * @param seqPos position where the writer writes its latest sequence number
// */
// public Futex(MappedByteBuffer b, int futexPos, int seqPos) {
// this.buf = b;
// this.seqPos = seqPos;
// this.futAddr = computeAddress(b, futexPos);
// this.seqAddr = computeAddress(b, seqPos);
// }
//
// /**
// * Blocks until the writer posts a packet with a seqnum higher than specified.
// */
// @Override
// public void pauseWhile(int currentSeq) {
// pause(futAddr, seqAddr, currentSeq);
// }
//
// private static native void pause(long futAddr, long seqAddr, int seq);
//
// @Override
// public void reset() {
// }
//
// private static long computeAddress(MappedByteBuffer b, int pos) {
// try {
// return getAddress(b) + pos;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public int getInt(int pos) {
// return getInt0(computeAddress(buf, pos));
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public void setInt(int pos, int value) {
// setInt0(computeAddress(buf, pos), value);
// }
//
// private static native int getInt0(long addr);
//
// private static native void setInt0(long addr, int value);
//
// /**
// * Signals the reader that a new packet is available. Happens mainly during
// * flush(). It includes the cost of a JNI call and a native CAS. A FUTEX_CALL
// * syscall is performed only if necessary (i.e. the reader is waiting for
// * data).
// *
// * @param seq
// */
// public void signal(int seq) {
// signal0(futAddr);
// }
//
// @Deprecated
// public void await() {
// await0(futAddr);
// }
//
// public static native long getAddress(MappedByteBuffer b);
//
// private static native void signal0(long addr);
//
// @Deprecated
// private static native void await0(long addr);
//
// public static native long rdtsc();
//
// static {
// try {
// LibLoader.loadLibrary("JocketFutex");
// libAvailable = true;
// } catch (Throwable e) {
// libAvailable = false;
// System.err.println("WARN: JNI futex lib is NOT available: " + e);
// }
// }
//
// public static boolean isAvailable() {
// return libAvailable;
// }
// }
// Path: src/main/java/jocket/impl/JocketWriter.java
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import jocket.futex.Futex;
package jocket.impl;
public class JocketWriter extends AbstractJocketBuffer {
/** The sequence number of the next packet to write. */
private int wseq;
/** Pending packet's absolute start and end positions. */
private int pstart, pend;
/**
* Equivalent to (pend > pstart) but looks like it is faster to store this
* information in a dedicated boolean.
*/
private boolean dirty;
/**
* Optional packet alignment. By default we align on cache lines to avoid
* having several packets in the same cache line, which would cause false
* sharing (reader and writer threads would access the same line
* concurrently).
*/
private int align = _CACHELINE;
/**
* Used to modulo on align size.
*/
private int alignMask = _CACHELINE - 1;
| private Futex futex; |
pcdv/jocket | src/test/java/jocket/test/TestJocketSocket.java | // Path: src/main/java/jocket/impl/ClosedException.java
// @SuppressWarnings("serial")
// public class ClosedException extends RuntimeException {
//
// public ClosedException(String message) {
// super(message);
// }
// }
| import static org.junit.Assert.*;
import java.io.DataInputStream;
import java.io.OutputStream;
import jocket.impl.ClosedException;
import org.junit.Test; | package jocket.test;
public class TestJocketSocket extends AbstractJocketSocketTest {
@Test
public void testWriteRead() throws Exception {
OutputStream out = c.getOutputStream();
out.write("hello".getBytes());
out.flush();
byte[] buf = new byte[100];
int len = s.getInputStream().read(buf);
assertEquals(5, len);
assertEquals("hello", new String(buf, 0, 5));
}
@Test
public void testCloseOutput() throws Exception {
c.getOutputStream().close();
assertEquals(-1, s.getInputStream().read());
}
@Test
public void testCloseInput() throws Exception {
c.getInputStream().close();
try {
s.getOutputStream().write(22);
fail(""); | // Path: src/main/java/jocket/impl/ClosedException.java
// @SuppressWarnings("serial")
// public class ClosedException extends RuntimeException {
//
// public ClosedException(String message) {
// super(message);
// }
// }
// Path: src/test/java/jocket/test/TestJocketSocket.java
import static org.junit.Assert.*;
import java.io.DataInputStream;
import java.io.OutputStream;
import jocket.impl.ClosedException;
import org.junit.Test;
package jocket.test;
public class TestJocketSocket extends AbstractJocketSocketTest {
@Test
public void testWriteRead() throws Exception {
OutputStream out = c.getOutputStream();
out.write("hello".getBytes());
out.flush();
byte[] buf = new byte[100];
int len = s.getInputStream().read(buf);
assertEquals(5, len);
assertEquals("hello", new String(buf, 0, 5));
}
@Test
public void testCloseOutput() throws Exception {
c.getOutputStream().close();
assertEquals(-1, s.getInputStream().read());
}
@Test
public void testCloseInput() throws Exception {
c.getInputStream().close();
try {
s.getOutputStream().write(22);
fail(""); | } catch (ClosedException e) { |
pcdv/jocket | src/main/java/jocket/net/ServerJocket.java | // Path: src/main/java/jocket/futex/Futex.java
// public class Futex implements WaitStrategy {
//
// private static boolean libAvailable;
//
// private final long futAddr;
//
// private final long seqAddr;
//
// private final MappedByteBuffer buf;
//
// private final int seqPos;
//
// /**
// * @param b a mapped byte buffer
// * @param futexPos position of the futex variable in buffer
// * @param seqPos position where the writer writes its latest sequence number
// */
// public Futex(MappedByteBuffer b, int futexPos, int seqPos) {
// this.buf = b;
// this.seqPos = seqPos;
// this.futAddr = computeAddress(b, futexPos);
// this.seqAddr = computeAddress(b, seqPos);
// }
//
// /**
// * Blocks until the writer posts a packet with a seqnum higher than specified.
// */
// @Override
// public void pauseWhile(int currentSeq) {
// pause(futAddr, seqAddr, currentSeq);
// }
//
// private static native void pause(long futAddr, long seqAddr, int seq);
//
// @Override
// public void reset() {
// }
//
// private static long computeAddress(MappedByteBuffer b, int pos) {
// try {
// return getAddress(b) + pos;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public int getInt(int pos) {
// return getInt0(computeAddress(buf, pos));
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public void setInt(int pos, int value) {
// setInt0(computeAddress(buf, pos), value);
// }
//
// private static native int getInt0(long addr);
//
// private static native void setInt0(long addr, int value);
//
// /**
// * Signals the reader that a new packet is available. Happens mainly during
// * flush(). It includes the cost of a JNI call and a native CAS. A FUTEX_CALL
// * syscall is performed only if necessary (i.e. the reader is waiting for
// * data).
// *
// * @param seq
// */
// public void signal(int seq) {
// signal0(futAddr);
// }
//
// @Deprecated
// public void await() {
// await0(futAddr);
// }
//
// public static native long getAddress(MappedByteBuffer b);
//
// private static native void signal0(long addr);
//
// @Deprecated
// private static native void await0(long addr);
//
// public static native long rdtsc();
//
// static {
// try {
// LibLoader.loadLibrary("JocketFutex");
// libAvailable = true;
// } catch (Throwable e) {
// libAvailable = false;
// System.err.println("WARN: JNI futex lib is NOT available: " + e);
// }
// }
//
// public static boolean isAvailable() {
// return libAvailable;
// }
// }
| import java.io.Closeable;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketTimeoutException;
import jocket.futex.Futex; |
if (closed)
throw new IllegalStateException("Closed");
Socket s = srv.accept();
// allows to wakeup if client never does the handshake
s.setSoTimeout(1000);
DataInputStream in = new DataInputStream(s.getInputStream());
DataOutputStream out = new DataOutputStream(s.getOutputStream());
out.writeInt(MAGIC);
out.flush();
int magic = 0;
try {
magic = in.readInt();
}
catch (SocketTimeoutException timeout) {
}
if (magic != MAGIC) {
s.close();
continue;
}
// TODO: make parameters configurable through ServerJocket
// TODO: write parameters in file header (+ misc meta data)
JocketFile fw = new JocketFile(maxPackets, capacity);
JocketFile fr = new JocketFile(maxPackets, capacity);
| // Path: src/main/java/jocket/futex/Futex.java
// public class Futex implements WaitStrategy {
//
// private static boolean libAvailable;
//
// private final long futAddr;
//
// private final long seqAddr;
//
// private final MappedByteBuffer buf;
//
// private final int seqPos;
//
// /**
// * @param b a mapped byte buffer
// * @param futexPos position of the futex variable in buffer
// * @param seqPos position where the writer writes its latest sequence number
// */
// public Futex(MappedByteBuffer b, int futexPos, int seqPos) {
// this.buf = b;
// this.seqPos = seqPos;
// this.futAddr = computeAddress(b, futexPos);
// this.seqAddr = computeAddress(b, seqPos);
// }
//
// /**
// * Blocks until the writer posts a packet with a seqnum higher than specified.
// */
// @Override
// public void pauseWhile(int currentSeq) {
// pause(futAddr, seqAddr, currentSeq);
// }
//
// private static native void pause(long futAddr, long seqAddr, int seq);
//
// @Override
// public void reset() {
// }
//
// private static long computeAddress(MappedByteBuffer b, int pos) {
// try {
// return getAddress(b) + pos;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public int getInt(int pos) {
// return getInt0(computeAddress(buf, pos));
// }
//
// /**
// * For test purposes. Unsafe. Do not use.
// */
// public void setInt(int pos, int value) {
// setInt0(computeAddress(buf, pos), value);
// }
//
// private static native int getInt0(long addr);
//
// private static native void setInt0(long addr, int value);
//
// /**
// * Signals the reader that a new packet is available. Happens mainly during
// * flush(). It includes the cost of a JNI call and a native CAS. A FUTEX_CALL
// * syscall is performed only if necessary (i.e. the reader is waiting for
// * data).
// *
// * @param seq
// */
// public void signal(int seq) {
// signal0(futAddr);
// }
//
// @Deprecated
// public void await() {
// await0(futAddr);
// }
//
// public static native long getAddress(MappedByteBuffer b);
//
// private static native void signal0(long addr);
//
// @Deprecated
// private static native void await0(long addr);
//
// public static native long rdtsc();
//
// static {
// try {
// LibLoader.loadLibrary("JocketFutex");
// libAvailable = true;
// } catch (Throwable e) {
// libAvailable = false;
// System.err.println("WARN: JNI futex lib is NOT available: " + e);
// }
// }
//
// public static boolean isAvailable() {
// return libAvailable;
// }
// }
// Path: src/main/java/jocket/net/ServerJocket.java
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketTimeoutException;
import jocket.futex.Futex;
if (closed)
throw new IllegalStateException("Closed");
Socket s = srv.accept();
// allows to wakeup if client never does the handshake
s.setSoTimeout(1000);
DataInputStream in = new DataInputStream(s.getInputStream());
DataOutputStream out = new DataOutputStream(s.getOutputStream());
out.writeInt(MAGIC);
out.flush();
int magic = 0;
try {
magic = in.readInt();
}
catch (SocketTimeoutException timeout) {
}
if (magic != MAGIC) {
s.close();
continue;
}
// TODO: make parameters configurable through ServerJocket
// TODO: write parameters in file header (+ misc meta data)
JocketFile fw = new JocketFile(maxPackets, capacity);
JocketFile fr = new JocketFile(maxPackets, capacity);
| if (Futex.isAvailable()) { |
opacapp/opacclient | opacclient/libopac/src/main/java/de/geeksfactory/opacclient/apis/ApacheBaseApi.java | // Path: opacclient/libopac/src/main/java/de/geeksfactory/opacclient/networking/HttpUtils.java
// public class HttpUtils {
// /**
// * Re-implementing EntityUtils.consume() as it is in different classes on Android and
// * non-Android due to the Android backporting process of HttpClient 4
// */
// public static void consume(HttpEntity entity) throws IOException {
// if (entity == null) {
// return;
// }
// if (entity.isStreaming()) {
// final InputStream instream = entity.getContent();
// if (instream != null) {
// instream.close();
// }
// }
// }
// }
| import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.List;
import de.geeksfactory.opacclient.i18n.DummyStringProvider;
import de.geeksfactory.opacclient.networking.HttpClientFactory;
import de.geeksfactory.opacclient.networking.HttpUtils;
import de.geeksfactory.opacclient.networking.NotReachableException;
import de.geeksfactory.opacclient.networking.SSLSecurityException;
import de.geeksfactory.opacclient.objects.CoverHolder;
import de.geeksfactory.opacclient.objects.Library; | * @param encoding Expected encoding of the response body
* @param ignore_errors If true, status codes above 400 do not raise an exception
* @param cookieStore If set, the given cookieStore is used instead of the built-in one.
* @return Answer content
* @throws NotReachableException Thrown when server returns a HTTP status code greater or equal
* than 400.
*/
public String httpGet(String url, String encoding, boolean ignore_errors,
CookieStore cookieStore) throws
IOException {
HttpGet httpget = new HttpGet(cleanUrl(url));
HttpResponse response;
String html;
httpget.setHeader("Accept", "*/*");
try {
if (cookieStore != null) {
// Create local HTTP context
HttpContext localContext = new BasicHttpContext();
// Bind custom cookie store to the local context
localContext.setAttribute(HttpClientContext.COOKIE_STORE,
cookieStore);
response = http_client.execute(httpget, localContext);
} else {
response = http_client.execute(httpget);
}
if (!ignore_errors && response.getStatusLine().getStatusCode() >= 400) { | // Path: opacclient/libopac/src/main/java/de/geeksfactory/opacclient/networking/HttpUtils.java
// public class HttpUtils {
// /**
// * Re-implementing EntityUtils.consume() as it is in different classes on Android and
// * non-Android due to the Android backporting process of HttpClient 4
// */
// public static void consume(HttpEntity entity) throws IOException {
// if (entity == null) {
// return;
// }
// if (entity.isStreaming()) {
// final InputStream instream = entity.getContent();
// if (instream != null) {
// instream.close();
// }
// }
// }
// }
// Path: opacclient/libopac/src/main/java/de/geeksfactory/opacclient/apis/ApacheBaseApi.java
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.List;
import de.geeksfactory.opacclient.i18n.DummyStringProvider;
import de.geeksfactory.opacclient.networking.HttpClientFactory;
import de.geeksfactory.opacclient.networking.HttpUtils;
import de.geeksfactory.opacclient.networking.NotReachableException;
import de.geeksfactory.opacclient.networking.SSLSecurityException;
import de.geeksfactory.opacclient.objects.CoverHolder;
import de.geeksfactory.opacclient.objects.Library;
* @param encoding Expected encoding of the response body
* @param ignore_errors If true, status codes above 400 do not raise an exception
* @param cookieStore If set, the given cookieStore is used instead of the built-in one.
* @return Answer content
* @throws NotReachableException Thrown when server returns a HTTP status code greater or equal
* than 400.
*/
public String httpGet(String url, String encoding, boolean ignore_errors,
CookieStore cookieStore) throws
IOException {
HttpGet httpget = new HttpGet(cleanUrl(url));
HttpResponse response;
String html;
httpget.setHeader("Accept", "*/*");
try {
if (cookieStore != null) {
// Create local HTTP context
HttpContext localContext = new BasicHttpContext();
// Bind custom cookie store to the local context
localContext.setAttribute(HttpClientContext.COOKIE_STORE,
cookieStore);
response = http_client.execute(httpget, localContext);
} else {
response = http_client.execute(httpget);
}
if (!ignore_errors && response.getStatusLine().getStatusCode() >= 400) { | HttpUtils.consume(response.getEntity()); |
opacapp/opacclient | opacclient/libopac/src/test/java/de/geeksfactory/opacclient/apis/SISISTest.java | // Path: opacclient/libopac/src/main/java/de/geeksfactory/opacclient/objects/Account.java
// public class Account {
// private long id;
// private String library;
//
// private String label;
// private String name;
// private String password;
// private long cached;
// private boolean password_known_valid = false;
// private boolean supportPolicyHintSeen = false;
//
// @Override
// public String toString() {
// return "Account [id=" + id + ", library=" + library + ", label="
// + label + ", name=" + name + ", cached=" + cached + ", " +
// "passwordValid=" + password_known_valid + "]";
// }
//
// /**
// * Get ID this account is stored with in <code>AccountDataStore</code>
// *
// * @return Account ID
// */
// public long getId() {
// return id;
// }
//
// /**
// * Set ID this account is stored with in <code>AccountDataStore</code>
// *
// * @param id Account ID
// */
// public void setId(long id) {
// this.id = id;
// }
//
// /**
// * Get library identifier this Account belongs to.
// *
// * @return Library identifier (see {@link Library#getIdent()})
// */
// public String getLibrary() {
// return library;
// }
//
// /**
// * Set library identifier this Account belongs to.
// *
// * @param library Library identifier (see {@link Library#getIdent()})
// */
// public void setLibrary(String library) {
// this.library = library;
// }
//
// /**
// * Get user-configured Account label.
// *
// * @return Label
// */
// public String getLabel() {
// return label;
// }
//
// /**
// * Set user-configured Account label.
// *
// * @param label Label
// */
// public void setLabel(String label) {
// this.label = label;
// }
//
// /**
// * Get user name / identification
// *
// * @return User name or ID
// */
// public String getName() {
// return name;
// }
//
// /**
// * Set user name / identification
// *
// * @param name User name or ID
// */
// public void setName(String name) {
// this.name = name;
// }
//
// /**
// * Set user password
// *
// * @return Password
// */
// public String getPassword() {
// return password;
// }
//
// /**
// * Get user password
// *
// * @param password Password
// */
// public void setPassword(String password) {
// this.password = password;
// }
//
// /**
// * Get date of last data update
// *
// * @return Timestamp in milliseconds
// */
// public long getCached() {
// return cached;
// }
//
// /**
// * Set date of last data update
// *
// * @param cached Timestamp in milliseconds (use
// * <code>System.currentTimeMillis</code>)
// */
// public void setCached(long cached) {
// this.cached = cached;
// }
//
// public boolean isPasswordKnownValid() {
// return password_known_valid;
// }
//
// public void setPasswordKnownValid(boolean password_known_valid) {
// this.password_known_valid = password_known_valid;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Account account = (Account) o;
//
// return id == account.id;
// }
//
// @Override
// public int hashCode() {
// return (int) (id ^ (id >>> 32));
// }
//
// public boolean isSupportPolicyHintSeen() {
// return supportPolicyHintSeen;
// }
//
// public void setSupportPolicyHintSeen(boolean supportPolicyHintSeen) {
// this.supportPolicyHintSeen = supportPolicyHintSeen;
// }
// }
| import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.geeksfactory.opacclient.objects.Account;
import de.geeksfactory.opacclient.objects.AccountData;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy; | package de.geeksfactory.opacclient.apis;
public class SISISTest extends BaseHtmlTest {
private SISIS sisis;
@Before
public void setUp() throws JSONException {
sisis = spy(SISIS.class);
sisis.opac_url = "https://opac.erfurt.de/webOPACClient";
sisis.data = new JSONObject("{\"baseurl\":\"" + sisis.opac_url + "\"}");
}
@Test
public void testLoadPages() throws IOException, OpacApi.OpacErrorException, JSONException { | // Path: opacclient/libopac/src/main/java/de/geeksfactory/opacclient/objects/Account.java
// public class Account {
// private long id;
// private String library;
//
// private String label;
// private String name;
// private String password;
// private long cached;
// private boolean password_known_valid = false;
// private boolean supportPolicyHintSeen = false;
//
// @Override
// public String toString() {
// return "Account [id=" + id + ", library=" + library + ", label="
// + label + ", name=" + name + ", cached=" + cached + ", " +
// "passwordValid=" + password_known_valid + "]";
// }
//
// /**
// * Get ID this account is stored with in <code>AccountDataStore</code>
// *
// * @return Account ID
// */
// public long getId() {
// return id;
// }
//
// /**
// * Set ID this account is stored with in <code>AccountDataStore</code>
// *
// * @param id Account ID
// */
// public void setId(long id) {
// this.id = id;
// }
//
// /**
// * Get library identifier this Account belongs to.
// *
// * @return Library identifier (see {@link Library#getIdent()})
// */
// public String getLibrary() {
// return library;
// }
//
// /**
// * Set library identifier this Account belongs to.
// *
// * @param library Library identifier (see {@link Library#getIdent()})
// */
// public void setLibrary(String library) {
// this.library = library;
// }
//
// /**
// * Get user-configured Account label.
// *
// * @return Label
// */
// public String getLabel() {
// return label;
// }
//
// /**
// * Set user-configured Account label.
// *
// * @param label Label
// */
// public void setLabel(String label) {
// this.label = label;
// }
//
// /**
// * Get user name / identification
// *
// * @return User name or ID
// */
// public String getName() {
// return name;
// }
//
// /**
// * Set user name / identification
// *
// * @param name User name or ID
// */
// public void setName(String name) {
// this.name = name;
// }
//
// /**
// * Set user password
// *
// * @return Password
// */
// public String getPassword() {
// return password;
// }
//
// /**
// * Get user password
// *
// * @param password Password
// */
// public void setPassword(String password) {
// this.password = password;
// }
//
// /**
// * Get date of last data update
// *
// * @return Timestamp in milliseconds
// */
// public long getCached() {
// return cached;
// }
//
// /**
// * Set date of last data update
// *
// * @param cached Timestamp in milliseconds (use
// * <code>System.currentTimeMillis</code>)
// */
// public void setCached(long cached) {
// this.cached = cached;
// }
//
// public boolean isPasswordKnownValid() {
// return password_known_valid;
// }
//
// public void setPasswordKnownValid(boolean password_known_valid) {
// this.password_known_valid = password_known_valid;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Account account = (Account) o;
//
// return id == account.id;
// }
//
// @Override
// public int hashCode() {
// return (int) (id ^ (id >>> 32));
// }
//
// public boolean isSupportPolicyHintSeen() {
// return supportPolicyHintSeen;
// }
//
// public void setSupportPolicyHintSeen(boolean supportPolicyHintSeen) {
// this.supportPolicyHintSeen = supportPolicyHintSeen;
// }
// }
// Path: opacclient/libopac/src/test/java/de/geeksfactory/opacclient/apis/SISISTest.java
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.geeksfactory.opacclient.objects.Account;
import de.geeksfactory.opacclient.objects.AccountData;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
package de.geeksfactory.opacclient.apis;
public class SISISTest extends BaseHtmlTest {
private SISIS sisis;
@Before
public void setUp() throws JSONException {
sisis = spy(SISIS.class);
sisis.opac_url = "https://opac.erfurt.de/webOPACClient";
sisis.data = new JSONObject("{\"baseurl\":\"" + sisis.opac_url + "\"}");
}
@Test
public void testLoadPages() throws IOException, OpacApi.OpacErrorException, JSONException { | Account acc = new Account(); |
opacapp/opacclient | opacclient/opacapp/src/main/java/de/geeksfactory/opacclient/webservice/UpdateHandler.java | // Path: opacclient/opacapp/src/main/java/de/geeksfactory/opacclient/storage/PreferenceDataSource.java
// public class PreferenceDataSource {
//
// private static final String LAST_LIBRARY_CONFIG_UPDATE = "last_library_config_update";
// private static final String LAST_LIBRARY_CONFIG_UPDATE_TRY = "last_library_config_update_try";
// private static final String LAST_LIBRARY_CONFIG_UPDATE_VERSION =
// "last_library_config_update_version";
// private static final String ACCOUNT_PTR_HINT_SHOWN = "account_ptr_hint_shown";
// protected SharedPreferences sp;
// protected Context context;
//
// private static final String LAST_LIBRARY_CONFIG_UPDATE_FILE = "last_library_config_update.txt";
//
// public PreferenceDataSource(Context context) {
// this.context = context;
// sp = PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public long getLastLibraryConfigUpdateTry() {
// return sp.getLong(LAST_LIBRARY_CONFIG_UPDATE_TRY, 0);
// }
//
// @Nullable
// public DateTime getLastLibraryConfigUpdate() {
// String lastUpdate = sp.getString(LAST_LIBRARY_CONFIG_UPDATE, null);
// if (lastUpdate == null || getLastLibraryConfigUpdateVersion() != BuildConfig.VERSION_CODE) {
// // last update only makes sense if done using the current app version
// try {
// InputStream is = context.getAssets().open(LAST_LIBRARY_CONFIG_UPDATE_FILE);
// return new DateTime(Utils.readStreamToString(is));
// } catch (IOException e) {
// return null;
// }
// }
// return new DateTime(lastUpdate);
// }
//
// @Nullable
// public DateTime getBundledConfigUpdateTime() {
// try {
// InputStream is = context.getAssets().open(LAST_LIBRARY_CONFIG_UPDATE_FILE);
// return new DateTime(Utils.readStreamToString(is));
// } catch (IOException e) {
// return null;
// }
// }
//
// public void setLastLibraryConfigUpdate(DateTime lastUpdate) {
// sp.edit().putString(LAST_LIBRARY_CONFIG_UPDATE, lastUpdate.toString()).apply();
// }
//
// public void setLastLibraryConfigUpdateTry(long lastUpdate) {
// sp.edit().putLong(LAST_LIBRARY_CONFIG_UPDATE_TRY, lastUpdate).apply();
// }
//
// public boolean hasBundledConfiguration() {
// return getBundledConfigUpdateTime() != null;
// }
//
// public void clearLastLibraryConfigUpdate() {
// sp.edit()
// .remove(LAST_LIBRARY_CONFIG_UPDATE)
// .remove(LAST_LIBRARY_CONFIG_UPDATE_TRY)
// .remove(LAST_LIBRARY_CONFIG_UPDATE_VERSION)
// .apply();
// }
//
// public int getLastLibraryConfigUpdateVersion() {
// return sp.getInt(LAST_LIBRARY_CONFIG_UPDATE_VERSION, 0);
// }
//
// public void setLastLibraryConfigUpdateVersion(int lastUpdateVersion) {
// sp.edit().putInt(LAST_LIBRARY_CONFIG_UPDATE_VERSION, lastUpdateVersion).apply();
// }
//
// public boolean isLoadCoversOnDataPreferenceSet() {
// return sp.getBoolean("on_data_load_covers", true);
// }
//
// public void setAccountPtrHintShown(int number) {
// sp.edit().putInt(ACCOUNT_PTR_HINT_SHOWN, number).apply();
// }
//
// public int getAccountPtrHintShown() {
// return sp.getInt(ACCOUNT_PTR_HINT_SHOWN, 0);
// }
// }
| import org.joda.time.DateTime;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.List;
import de.geeksfactory.opacclient.BuildConfig;
import de.geeksfactory.opacclient.objects.Library;
import de.geeksfactory.opacclient.storage.PreferenceDataSource;
import de.geeksfactory.opacclient.storage.SearchFieldDataSource;
import retrofit2.Response; | package de.geeksfactory.opacclient.webservice;
public class UpdateHandler {
protected Response<List<Library>> getServerResponse(WebService service, DateTime last_update)
throws IOException {
return service.getLibraryConfigs(last_update, BuildConfig.VERSION_CODE, 0, null)
.execute();
}
| // Path: opacclient/opacapp/src/main/java/de/geeksfactory/opacclient/storage/PreferenceDataSource.java
// public class PreferenceDataSource {
//
// private static final String LAST_LIBRARY_CONFIG_UPDATE = "last_library_config_update";
// private static final String LAST_LIBRARY_CONFIG_UPDATE_TRY = "last_library_config_update_try";
// private static final String LAST_LIBRARY_CONFIG_UPDATE_VERSION =
// "last_library_config_update_version";
// private static final String ACCOUNT_PTR_HINT_SHOWN = "account_ptr_hint_shown";
// protected SharedPreferences sp;
// protected Context context;
//
// private static final String LAST_LIBRARY_CONFIG_UPDATE_FILE = "last_library_config_update.txt";
//
// public PreferenceDataSource(Context context) {
// this.context = context;
// sp = PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public long getLastLibraryConfigUpdateTry() {
// return sp.getLong(LAST_LIBRARY_CONFIG_UPDATE_TRY, 0);
// }
//
// @Nullable
// public DateTime getLastLibraryConfigUpdate() {
// String lastUpdate = sp.getString(LAST_LIBRARY_CONFIG_UPDATE, null);
// if (lastUpdate == null || getLastLibraryConfigUpdateVersion() != BuildConfig.VERSION_CODE) {
// // last update only makes sense if done using the current app version
// try {
// InputStream is = context.getAssets().open(LAST_LIBRARY_CONFIG_UPDATE_FILE);
// return new DateTime(Utils.readStreamToString(is));
// } catch (IOException e) {
// return null;
// }
// }
// return new DateTime(lastUpdate);
// }
//
// @Nullable
// public DateTime getBundledConfigUpdateTime() {
// try {
// InputStream is = context.getAssets().open(LAST_LIBRARY_CONFIG_UPDATE_FILE);
// return new DateTime(Utils.readStreamToString(is));
// } catch (IOException e) {
// return null;
// }
// }
//
// public void setLastLibraryConfigUpdate(DateTime lastUpdate) {
// sp.edit().putString(LAST_LIBRARY_CONFIG_UPDATE, lastUpdate.toString()).apply();
// }
//
// public void setLastLibraryConfigUpdateTry(long lastUpdate) {
// sp.edit().putLong(LAST_LIBRARY_CONFIG_UPDATE_TRY, lastUpdate).apply();
// }
//
// public boolean hasBundledConfiguration() {
// return getBundledConfigUpdateTime() != null;
// }
//
// public void clearLastLibraryConfigUpdate() {
// sp.edit()
// .remove(LAST_LIBRARY_CONFIG_UPDATE)
// .remove(LAST_LIBRARY_CONFIG_UPDATE_TRY)
// .remove(LAST_LIBRARY_CONFIG_UPDATE_VERSION)
// .apply();
// }
//
// public int getLastLibraryConfigUpdateVersion() {
// return sp.getInt(LAST_LIBRARY_CONFIG_UPDATE_VERSION, 0);
// }
//
// public void setLastLibraryConfigUpdateVersion(int lastUpdateVersion) {
// sp.edit().putInt(LAST_LIBRARY_CONFIG_UPDATE_VERSION, lastUpdateVersion).apply();
// }
//
// public boolean isLoadCoversOnDataPreferenceSet() {
// return sp.getBoolean("on_data_load_covers", true);
// }
//
// public void setAccountPtrHintShown(int number) {
// sp.edit().putInt(ACCOUNT_PTR_HINT_SHOWN, number).apply();
// }
//
// public int getAccountPtrHintShown() {
// return sp.getInt(ACCOUNT_PTR_HINT_SHOWN, 0);
// }
// }
// Path: opacclient/opacapp/src/main/java/de/geeksfactory/opacclient/webservice/UpdateHandler.java
import org.joda.time.DateTime;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.List;
import de.geeksfactory.opacclient.BuildConfig;
import de.geeksfactory.opacclient.objects.Library;
import de.geeksfactory.opacclient.storage.PreferenceDataSource;
import de.geeksfactory.opacclient.storage.SearchFieldDataSource;
import retrofit2.Response;
package de.geeksfactory.opacclient.webservice;
public class UpdateHandler {
protected Response<List<Library>> getServerResponse(WebService service, DateTime last_update)
throws IOException {
return service.getLibraryConfigs(last_update, BuildConfig.VERSION_CODE, 0, null)
.execute();
}
| public int updateConfig(WebService service, PreferenceDataSource prefs, |
handexing/vipsnacks | snacks_service/src/main/java/com/snacks/menu/entity/Menu.java | // Path: snacks_common/src/main/java/com/snacks/common/util/CustomDateSerializer.java
// public class CustomDateSerializer extends JsonSerializer<Date> {
//
// @Override
// public void serialize(Date value, JsonGenerator jsonGenerator, SerializerProvider provider)
// throws IOException, JsonProcessingException {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// jsonGenerator.writeString(sdf.format(value));
// }
// }
| import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.snacks.common.util.CustomDateSerializer;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
| package com.snacks.menu.entity;
@Entity
@Table(name = "MENU")
public class Menu {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private Long id;
@Column(name = "NAME")
private String name;
@Column(name = "URL")
private String url;
@Column(name = "PID")
private Long pid;
@Column(name = "CREATE_TIME")
| // Path: snacks_common/src/main/java/com/snacks/common/util/CustomDateSerializer.java
// public class CustomDateSerializer extends JsonSerializer<Date> {
//
// @Override
// public void serialize(Date value, JsonGenerator jsonGenerator, SerializerProvider provider)
// throws IOException, JsonProcessingException {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// jsonGenerator.writeString(sdf.format(value));
// }
// }
// Path: snacks_service/src/main/java/com/snacks/menu/entity/Menu.java
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.snacks.common.util.CustomDateSerializer;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
package com.snacks.menu.entity;
@Entity
@Table(name = "MENU")
public class Menu {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private Long id;
@Column(name = "NAME")
private String name;
@Column(name = "URL")
private String url;
@Column(name = "PID")
private Long pid;
@Column(name = "CREATE_TIME")
| @JsonSerialize(using = CustomDateSerializer.class)
|
handexing/vipsnacks | snacks_service/src/test/java/com/snacks/user/service/UserServiceTest.java | // Path: snacks_service/src/test/java/com/snacks/service/BaseTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @ContextConfiguration(locations = "classpath*:spring-test/spring-*.xml")
// @ActiveProfiles("test")
// public abstract class BaseTest {
//
// }
//
// Path: snacks_service/src/main/java/com/snacks/user/entity/User.java
// @Entity
// @Table(name = "USER")
// public class User {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "USER_ID")
// private Long id;
// @Column(name = "USER_NAME")
// private String userName;
// @Column(name = "USER_PSW")
// private String psw;
// @Column(name = "PHONE")
// private String phone;
// @Column(name = "CREATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date createTime;
// @Column(name = "UPDATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date updateTime;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getPsw() {
// return psw;
// }
//
// public void setPsw(String psw) {
// this.psw = psw;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Date getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(Date createTime) {
// this.createTime = createTime;
// }
//
// public Date getUpdateTime() {
// return updateTime;
// }
//
// public void setUpdateTime(Date updateTime) {
// this.updateTime = updateTime;
// }
//
//
// }
| import com.snacks.service.BaseTest;
import com.snacks.user.entity.User;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
| package com.snacks.user.service;
public class UserServiceTest extends BaseTest {
@Autowired
UserService userService;
@Test
public void testSaveUser() {
| // Path: snacks_service/src/test/java/com/snacks/service/BaseTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @ContextConfiguration(locations = "classpath*:spring-test/spring-*.xml")
// @ActiveProfiles("test")
// public abstract class BaseTest {
//
// }
//
// Path: snacks_service/src/main/java/com/snacks/user/entity/User.java
// @Entity
// @Table(name = "USER")
// public class User {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "USER_ID")
// private Long id;
// @Column(name = "USER_NAME")
// private String userName;
// @Column(name = "USER_PSW")
// private String psw;
// @Column(name = "PHONE")
// private String phone;
// @Column(name = "CREATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date createTime;
// @Column(name = "UPDATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date updateTime;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getPsw() {
// return psw;
// }
//
// public void setPsw(String psw) {
// this.psw = psw;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Date getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(Date createTime) {
// this.createTime = createTime;
// }
//
// public Date getUpdateTime() {
// return updateTime;
// }
//
// public void setUpdateTime(Date updateTime) {
// this.updateTime = updateTime;
// }
//
//
// }
// Path: snacks_service/src/test/java/com/snacks/user/service/UserServiceTest.java
import com.snacks.service.BaseTest;
import com.snacks.user.entity.User;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
package com.snacks.user.service;
public class UserServiceTest extends BaseTest {
@Autowired
UserService userService;
@Test
public void testSaveUser() {
| User user = new User();
|
handexing/vipsnacks | snacks_service/src/test/java/com/snacks/menu/dao/MenuDaoTest.java | // Path: snacks_service/src/main/java/com/snacks/menu/entity/Menu.java
// @Entity
// @Table(name = "MENU")
// public class Menu {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "ID")
// private Long id;
// @Column(name = "NAME")
// private String name;
// @Column(name = "URL")
// private String url;
// @Column(name = "PID")
// private Long pid;
// @Column(name = "CREATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date createTime;
// @Column(name = "UPDATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date updateTime;
// @Column(name = "STATUS")
// private Integer status;
//
// @Transient
// private List<Menu> children;
// @Transient
// private String text;
//
// public List<Menu> getChildren() {
// return children;
// }
//
// public void setChildren(List<Menu> children) {
// this.children = children;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Long getPid() {
// return pid;
// }
//
// public void setPid(Long pid) {
// this.pid = pid;
// }
//
// public Date getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(Date createTime) {
// this.createTime = createTime;
// }
//
// public Date getUpdateTime() {
// return updateTime;
// }
//
// public void setUpdateTime(Date updateTime) {
// this.updateTime = updateTime;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
//
//
// }
//
// Path: snacks_service/src/test/java/com/snacks/service/BaseTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @ContextConfiguration(locations = "classpath*:spring-test/spring-*.xml")
// @ActiveProfiles("test")
// public abstract class BaseTest {
//
// }
| import com.alibaba.fastjson.JSONObject;
import com.snacks.menu.entity.Menu;
import com.snacks.service.BaseTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
| package com.snacks.menu.dao;
public class MenuDaoTest extends BaseTest {
@Autowired
MenuDao menuDao;
@Test
public void testMenuList() {
| // Path: snacks_service/src/main/java/com/snacks/menu/entity/Menu.java
// @Entity
// @Table(name = "MENU")
// public class Menu {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "ID")
// private Long id;
// @Column(name = "NAME")
// private String name;
// @Column(name = "URL")
// private String url;
// @Column(name = "PID")
// private Long pid;
// @Column(name = "CREATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date createTime;
// @Column(name = "UPDATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date updateTime;
// @Column(name = "STATUS")
// private Integer status;
//
// @Transient
// private List<Menu> children;
// @Transient
// private String text;
//
// public List<Menu> getChildren() {
// return children;
// }
//
// public void setChildren(List<Menu> children) {
// this.children = children;
// }
//
// public String getText() {
// return text;
// }
//
// public void setText(String text) {
// this.text = text;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public Long getPid() {
// return pid;
// }
//
// public void setPid(Long pid) {
// this.pid = pid;
// }
//
// public Date getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(Date createTime) {
// this.createTime = createTime;
// }
//
// public Date getUpdateTime() {
// return updateTime;
// }
//
// public void setUpdateTime(Date updateTime) {
// this.updateTime = updateTime;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
//
//
// }
//
// Path: snacks_service/src/test/java/com/snacks/service/BaseTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @ContextConfiguration(locations = "classpath*:spring-test/spring-*.xml")
// @ActiveProfiles("test")
// public abstract class BaseTest {
//
// }
// Path: snacks_service/src/test/java/com/snacks/menu/dao/MenuDaoTest.java
import com.alibaba.fastjson.JSONObject;
import com.snacks.menu.entity.Menu;
import com.snacks.service.BaseTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
package com.snacks.menu.dao;
public class MenuDaoTest extends BaseTest {
@Autowired
MenuDao menuDao;
@Test
public void testMenuList() {
| List<Menu> partnets = menuDao.findParentMenuByRoleId(1L);
|
handexing/vipsnacks | snacks_service/src/main/java/com/snacks/menu/entity/Role.java | // Path: snacks_common/src/main/java/com/snacks/common/util/CustomDateSerializer.java
// public class CustomDateSerializer extends JsonSerializer<Date> {
//
// @Override
// public void serialize(Date value, JsonGenerator jsonGenerator, SerializerProvider provider)
// throws IOException, JsonProcessingException {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// jsonGenerator.writeString(sdf.format(value));
// }
// }
| import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.snacks.common.util.CustomDateSerializer;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
| package com.snacks.menu.entity;
@Entity
@Table(name = "ROLE")
public class Role {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private Long id;
@Column(name = "NAME")
private String name;
@Column(name = "DESCRIBE")
private String describe;
@Column(name = "CREATE_TIME")
| // Path: snacks_common/src/main/java/com/snacks/common/util/CustomDateSerializer.java
// public class CustomDateSerializer extends JsonSerializer<Date> {
//
// @Override
// public void serialize(Date value, JsonGenerator jsonGenerator, SerializerProvider provider)
// throws IOException, JsonProcessingException {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// jsonGenerator.writeString(sdf.format(value));
// }
// }
// Path: snacks_service/src/main/java/com/snacks/menu/entity/Role.java
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.snacks.common.util.CustomDateSerializer;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
package com.snacks.menu.entity;
@Entity
@Table(name = "ROLE")
public class Role {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private Long id;
@Column(name = "NAME")
private String name;
@Column(name = "DESCRIBE")
private String describe;
@Column(name = "CREATE_TIME")
| @JsonSerialize(using = CustomDateSerializer.class)
|
handexing/vipsnacks | snacks_service/src/test/java/com/snacks/admin/dao/AdminDaoTest.java | // Path: snacks_service/src/main/java/com/snacks/admin/dao/AdminDao.java
// @Repository
// public interface AdminDao extends JpaRepository<Admin, Long> {
//
// public Admin findByNameAndPsw(String name,String psw);
// }
//
// Path: snacks_service/src/main/java/com/snacks/admin/entity/Admin.java
// @Entity
// @Table(name = "ADMIN")
// public class Admin {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "ID")
// private Long id;
// @Column(name = "NAME")
// private String name;
// @Column(name = "NICK")
// private String nick;
// @Column(name = "PSW")
// private String psw;
// @OneToOne(cascade = CascadeType.MERGE, fetch = FetchType.EAGER, optional = true)
// @JoinColumn(name = "ROLE_ID")
// private Role role;
//
// public Long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getNick() {
// return nick;
// }
//
// public String getPsw() {
// return psw;
// }
//
// public Role getRole() {
// return role;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setNick(String nick) {
// this.nick = nick;
// }
//
// public void setPsw(String psw) {
// this.psw = psw;
// }
//
// public void setRole(Role role) {
// this.role = role;
// }
//
//
// }
//
// Path: snacks_service/src/test/java/com/snacks/service/BaseTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @ContextConfiguration(locations = "classpath*:spring-test/spring-*.xml")
// @ActiveProfiles("test")
// public abstract class BaseTest {
//
// }
| import com.snacks.admin.dao.AdminDao;
import com.snacks.admin.entity.Admin;
import com.snacks.service.BaseTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
| package com.snacks.admin.dao;
public class AdminDaoTest extends BaseTest {
@Autowired
| // Path: snacks_service/src/main/java/com/snacks/admin/dao/AdminDao.java
// @Repository
// public interface AdminDao extends JpaRepository<Admin, Long> {
//
// public Admin findByNameAndPsw(String name,String psw);
// }
//
// Path: snacks_service/src/main/java/com/snacks/admin/entity/Admin.java
// @Entity
// @Table(name = "ADMIN")
// public class Admin {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "ID")
// private Long id;
// @Column(name = "NAME")
// private String name;
// @Column(name = "NICK")
// private String nick;
// @Column(name = "PSW")
// private String psw;
// @OneToOne(cascade = CascadeType.MERGE, fetch = FetchType.EAGER, optional = true)
// @JoinColumn(name = "ROLE_ID")
// private Role role;
//
// public Long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getNick() {
// return nick;
// }
//
// public String getPsw() {
// return psw;
// }
//
// public Role getRole() {
// return role;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setNick(String nick) {
// this.nick = nick;
// }
//
// public void setPsw(String psw) {
// this.psw = psw;
// }
//
// public void setRole(Role role) {
// this.role = role;
// }
//
//
// }
//
// Path: snacks_service/src/test/java/com/snacks/service/BaseTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @ContextConfiguration(locations = "classpath*:spring-test/spring-*.xml")
// @ActiveProfiles("test")
// public abstract class BaseTest {
//
// }
// Path: snacks_service/src/test/java/com/snacks/admin/dao/AdminDaoTest.java
import com.snacks.admin.dao.AdminDao;
import com.snacks.admin.entity.Admin;
import com.snacks.service.BaseTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
package com.snacks.admin.dao;
public class AdminDaoTest extends BaseTest {
@Autowired
| AdminDao adminDao;
|
handexing/vipsnacks | snacks_service/src/test/java/com/snacks/admin/dao/AdminDaoTest.java | // Path: snacks_service/src/main/java/com/snacks/admin/dao/AdminDao.java
// @Repository
// public interface AdminDao extends JpaRepository<Admin, Long> {
//
// public Admin findByNameAndPsw(String name,String psw);
// }
//
// Path: snacks_service/src/main/java/com/snacks/admin/entity/Admin.java
// @Entity
// @Table(name = "ADMIN")
// public class Admin {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "ID")
// private Long id;
// @Column(name = "NAME")
// private String name;
// @Column(name = "NICK")
// private String nick;
// @Column(name = "PSW")
// private String psw;
// @OneToOne(cascade = CascadeType.MERGE, fetch = FetchType.EAGER, optional = true)
// @JoinColumn(name = "ROLE_ID")
// private Role role;
//
// public Long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getNick() {
// return nick;
// }
//
// public String getPsw() {
// return psw;
// }
//
// public Role getRole() {
// return role;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setNick(String nick) {
// this.nick = nick;
// }
//
// public void setPsw(String psw) {
// this.psw = psw;
// }
//
// public void setRole(Role role) {
// this.role = role;
// }
//
//
// }
//
// Path: snacks_service/src/test/java/com/snacks/service/BaseTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @ContextConfiguration(locations = "classpath*:spring-test/spring-*.xml")
// @ActiveProfiles("test")
// public abstract class BaseTest {
//
// }
| import com.snacks.admin.dao.AdminDao;
import com.snacks.admin.entity.Admin;
import com.snacks.service.BaseTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
| package com.snacks.admin.dao;
public class AdminDaoTest extends BaseTest {
@Autowired
AdminDao adminDao;
@Test
public void testlogin() {
| // Path: snacks_service/src/main/java/com/snacks/admin/dao/AdminDao.java
// @Repository
// public interface AdminDao extends JpaRepository<Admin, Long> {
//
// public Admin findByNameAndPsw(String name,String psw);
// }
//
// Path: snacks_service/src/main/java/com/snacks/admin/entity/Admin.java
// @Entity
// @Table(name = "ADMIN")
// public class Admin {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "ID")
// private Long id;
// @Column(name = "NAME")
// private String name;
// @Column(name = "NICK")
// private String nick;
// @Column(name = "PSW")
// private String psw;
// @OneToOne(cascade = CascadeType.MERGE, fetch = FetchType.EAGER, optional = true)
// @JoinColumn(name = "ROLE_ID")
// private Role role;
//
// public Long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getNick() {
// return nick;
// }
//
// public String getPsw() {
// return psw;
// }
//
// public Role getRole() {
// return role;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setNick(String nick) {
// this.nick = nick;
// }
//
// public void setPsw(String psw) {
// this.psw = psw;
// }
//
// public void setRole(Role role) {
// this.role = role;
// }
//
//
// }
//
// Path: snacks_service/src/test/java/com/snacks/service/BaseTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @ContextConfiguration(locations = "classpath*:spring-test/spring-*.xml")
// @ActiveProfiles("test")
// public abstract class BaseTest {
//
// }
// Path: snacks_service/src/test/java/com/snacks/admin/dao/AdminDaoTest.java
import com.snacks.admin.dao.AdminDao;
import com.snacks.admin.entity.Admin;
import com.snacks.service.BaseTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
package com.snacks.admin.dao;
public class AdminDaoTest extends BaseTest {
@Autowired
AdminDao adminDao;
@Test
public void testlogin() {
| Admin admin = adminDao.findByNameAndPsw("handx", "123456");
|
handexing/vipsnacks | snacks_service/src/main/java/com/snacks/user/entity/User.java | // Path: snacks_common/src/main/java/com/snacks/common/util/CustomDateSerializer.java
// public class CustomDateSerializer extends JsonSerializer<Date> {
//
// @Override
// public void serialize(Date value, JsonGenerator jsonGenerator, SerializerProvider provider)
// throws IOException, JsonProcessingException {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// jsonGenerator.writeString(sdf.format(value));
// }
// }
| import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.snacks.common.util.CustomDateSerializer;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
| package com.snacks.user.entity;
@Entity
@Table(name = "USER")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "USER_ID")
private Long id;
@Column(name = "USER_NAME")
private String userName;
@Column(name = "USER_PSW")
private String psw;
@Column(name = "PHONE")
private String phone;
@Column(name = "CREATE_TIME")
| // Path: snacks_common/src/main/java/com/snacks/common/util/CustomDateSerializer.java
// public class CustomDateSerializer extends JsonSerializer<Date> {
//
// @Override
// public void serialize(Date value, JsonGenerator jsonGenerator, SerializerProvider provider)
// throws IOException, JsonProcessingException {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// jsonGenerator.writeString(sdf.format(value));
// }
// }
// Path: snacks_service/src/main/java/com/snacks/user/entity/User.java
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.snacks.common.util.CustomDateSerializer;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
package com.snacks.user.entity;
@Entity
@Table(name = "USER")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "USER_ID")
private Long id;
@Column(name = "USER_NAME")
private String userName;
@Column(name = "USER_PSW")
private String psw;
@Column(name = "PHONE")
private String phone;
@Column(name = "CREATE_TIME")
| @JsonSerialize(using = CustomDateSerializer.class)
|
handexing/vipsnacks | snacks_service/src/main/java/com/snacks/admin/entity/Admin.java | // Path: snacks_service/src/main/java/com/snacks/menu/entity/Role.java
// @Entity
// @Table(name = "ROLE")
// public class Role {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "ID")
// private Long id;
// @Column(name = "NAME")
// private String name;
// @Column(name = "DESCRIBE")
// private String describe;
// @Column(name = "CREATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date createTime;
// @Column(name = "UPDATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date updateTime;
// @Column(name = "STATUS")
// private Integer status;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescribe() {
// return describe;
// }
//
// public void setDescribe(String describe) {
// this.describe = describe;
// }
//
// public Date getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(Date createTime) {
// this.createTime = createTime;
// }
//
// public Date getUpdateTime() {
// return updateTime;
// }
//
// public void setUpdateTime(Date updateTime) {
// this.updateTime = updateTime;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
//
//
// }
| import com.snacks.menu.entity.Role;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
| package com.snacks.admin.entity;
@Entity
@Table(name = "ADMIN")
public class Admin {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private Long id;
@Column(name = "NAME")
private String name;
@Column(name = "NICK")
private String nick;
@Column(name = "PSW")
private String psw;
@OneToOne(cascade = CascadeType.MERGE, fetch = FetchType.EAGER, optional = true)
@JoinColumn(name = "ROLE_ID")
| // Path: snacks_service/src/main/java/com/snacks/menu/entity/Role.java
// @Entity
// @Table(name = "ROLE")
// public class Role {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "ID")
// private Long id;
// @Column(name = "NAME")
// private String name;
// @Column(name = "DESCRIBE")
// private String describe;
// @Column(name = "CREATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date createTime;
// @Column(name = "UPDATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date updateTime;
// @Column(name = "STATUS")
// private Integer status;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescribe() {
// return describe;
// }
//
// public void setDescribe(String describe) {
// this.describe = describe;
// }
//
// public Date getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(Date createTime) {
// this.createTime = createTime;
// }
//
// public Date getUpdateTime() {
// return updateTime;
// }
//
// public void setUpdateTime(Date updateTime) {
// this.updateTime = updateTime;
// }
//
// public Integer getStatus() {
// return status;
// }
//
// public void setStatus(Integer status) {
// this.status = status;
// }
//
//
//
// }
// Path: snacks_service/src/main/java/com/snacks/admin/entity/Admin.java
import com.snacks.menu.entity.Role;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
package com.snacks.admin.entity;
@Entity
@Table(name = "ADMIN")
public class Admin {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private Long id;
@Column(name = "NAME")
private String name;
@Column(name = "NICK")
private String nick;
@Column(name = "PSW")
private String psw;
@OneToOne(cascade = CascadeType.MERGE, fetch = FetchType.EAGER, optional = true)
@JoinColumn(name = "ROLE_ID")
| private Role role;
|
handexing/vipsnacks | snacks_service/src/main/java/com/snacks/user/service/UserService.java | // Path: snacks_service/src/main/java/com/snacks/user/dao/UserDao.java
// @Repository
// public interface UserDao extends JpaRepository<User, Long> {
//
// }
//
// Path: snacks_service/src/main/java/com/snacks/user/entity/User.java
// @Entity
// @Table(name = "USER")
// public class User {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "USER_ID")
// private Long id;
// @Column(name = "USER_NAME")
// private String userName;
// @Column(name = "USER_PSW")
// private String psw;
// @Column(name = "PHONE")
// private String phone;
// @Column(name = "CREATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date createTime;
// @Column(name = "UPDATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date updateTime;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getPsw() {
// return psw;
// }
//
// public void setPsw(String psw) {
// this.psw = psw;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Date getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(Date createTime) {
// this.createTime = createTime;
// }
//
// public Date getUpdateTime() {
// return updateTime;
// }
//
// public void setUpdateTime(Date updateTime) {
// this.updateTime = updateTime;
// }
//
//
// }
| import com.snacks.user.dao.UserDao;
import com.snacks.user.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
| package com.snacks.user.service;
@Service
public class UserService {
Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
| // Path: snacks_service/src/main/java/com/snacks/user/dao/UserDao.java
// @Repository
// public interface UserDao extends JpaRepository<User, Long> {
//
// }
//
// Path: snacks_service/src/main/java/com/snacks/user/entity/User.java
// @Entity
// @Table(name = "USER")
// public class User {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "USER_ID")
// private Long id;
// @Column(name = "USER_NAME")
// private String userName;
// @Column(name = "USER_PSW")
// private String psw;
// @Column(name = "PHONE")
// private String phone;
// @Column(name = "CREATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date createTime;
// @Column(name = "UPDATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date updateTime;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getPsw() {
// return psw;
// }
//
// public void setPsw(String psw) {
// this.psw = psw;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Date getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(Date createTime) {
// this.createTime = createTime;
// }
//
// public Date getUpdateTime() {
// return updateTime;
// }
//
// public void setUpdateTime(Date updateTime) {
// this.updateTime = updateTime;
// }
//
//
// }
// Path: snacks_service/src/main/java/com/snacks/user/service/UserService.java
import com.snacks.user.dao.UserDao;
import com.snacks.user.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
package com.snacks.user.service;
@Service
public class UserService {
Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
| UserDao userDao;
|
handexing/vipsnacks | snacks_service/src/main/java/com/snacks/user/service/UserService.java | // Path: snacks_service/src/main/java/com/snacks/user/dao/UserDao.java
// @Repository
// public interface UserDao extends JpaRepository<User, Long> {
//
// }
//
// Path: snacks_service/src/main/java/com/snacks/user/entity/User.java
// @Entity
// @Table(name = "USER")
// public class User {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "USER_ID")
// private Long id;
// @Column(name = "USER_NAME")
// private String userName;
// @Column(name = "USER_PSW")
// private String psw;
// @Column(name = "PHONE")
// private String phone;
// @Column(name = "CREATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date createTime;
// @Column(name = "UPDATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date updateTime;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getPsw() {
// return psw;
// }
//
// public void setPsw(String psw) {
// this.psw = psw;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Date getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(Date createTime) {
// this.createTime = createTime;
// }
//
// public Date getUpdateTime() {
// return updateTime;
// }
//
// public void setUpdateTime(Date updateTime) {
// this.updateTime = updateTime;
// }
//
//
// }
| import com.snacks.user.dao.UserDao;
import com.snacks.user.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
| package com.snacks.user.service;
@Service
public class UserService {
Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
UserDao userDao;
| // Path: snacks_service/src/main/java/com/snacks/user/dao/UserDao.java
// @Repository
// public interface UserDao extends JpaRepository<User, Long> {
//
// }
//
// Path: snacks_service/src/main/java/com/snacks/user/entity/User.java
// @Entity
// @Table(name = "USER")
// public class User {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "USER_ID")
// private Long id;
// @Column(name = "USER_NAME")
// private String userName;
// @Column(name = "USER_PSW")
// private String psw;
// @Column(name = "PHONE")
// private String phone;
// @Column(name = "CREATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date createTime;
// @Column(name = "UPDATE_TIME")
// @JsonSerialize(using = CustomDateSerializer.class)
// private Date updateTime;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getPsw() {
// return psw;
// }
//
// public void setPsw(String psw) {
// this.psw = psw;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Date getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(Date createTime) {
// this.createTime = createTime;
// }
//
// public Date getUpdateTime() {
// return updateTime;
// }
//
// public void setUpdateTime(Date updateTime) {
// this.updateTime = updateTime;
// }
//
//
// }
// Path: snacks_service/src/main/java/com/snacks/user/service/UserService.java
import com.snacks.user.dao.UserDao;
import com.snacks.user.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
package com.snacks.user.service;
@Service
public class UserService {
Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
UserDao userDao;
| public void saveUser(User user) {
|
RetailMeNot/TestRailSDK | src/main/java/com/rmn/testrail/entity/TestInstance.java | // Path: src/main/java/com/rmn/testrail/parameters/ApiFilterValue.java
// public class ApiFilterValue {
// private ApiFilter apiFilter;
// private String value;
// public ApiFilterValue(ApiFilter apiFilter, String value) {
// this.apiFilter = apiFilter;
// this.value = value;
// }
//
// public String append() {
// return "&" + this.apiFilter.getFilter() + "=" + value;
// }
// }
//
// Path: src/main/java/com/rmn/testrail/parameters/GetResultsFilter.java
// public enum GetResultsFilter implements ApiFilter {
// //Request filters for get_results
// LIMIT("limit"),
// OFFSET("offset"),
// STATUS_ID("status_id");
//
// private String filter;
// GetResultsFilter(String filter) { this.filter = filter; }
//
// public String getFilter() {
// return filter;
// }
// }
| import com.rmn.testrail.parameters.ApiFilterValue;
import com.rmn.testrail.parameters.GetResultsFilter;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import java.util.List; | private Integer assignedtoId;
public Integer getAssignedtoId() { return assignedtoId; }
public void setAssignedtoId(Integer assignedtoId) { this.assignedtoId = assignedtoId; }
@JsonProperty("run_id")
private Integer runId;
public Integer getRunId() { return runId; }
public void setRunId(Integer runId) { this.runId = runId; }
@JsonProperty("case_id")
private Integer caseId;
public Integer getCaseId() { return caseId; }
public void setCaseId(Integer caseId) { this.caseId = caseId; }
@JsonProperty("milestone_id")
private Integer milestoneId;
public Integer getMilestoneId() { return milestoneId; }
public void setMilestoneId(Integer milestoneId) { this.milestoneId = milestoneId; }
@JsonProperty("refs")
private String refs;
public String getRefs() { return refs; }
public void setRefs(String refs) { this.refs = refs; }
/**
* Returns the list of test results (most recent first) associated with this TestInstance
* @param limit A limit to the number of results you want to see (1 will give you the single most recent)
* @return The number of TestResults specified by the limit, in descending chron order (i.e. newest to oldest)
*/
public List<TestResult> getResults(int limit) { | // Path: src/main/java/com/rmn/testrail/parameters/ApiFilterValue.java
// public class ApiFilterValue {
// private ApiFilter apiFilter;
// private String value;
// public ApiFilterValue(ApiFilter apiFilter, String value) {
// this.apiFilter = apiFilter;
// this.value = value;
// }
//
// public String append() {
// return "&" + this.apiFilter.getFilter() + "=" + value;
// }
// }
//
// Path: src/main/java/com/rmn/testrail/parameters/GetResultsFilter.java
// public enum GetResultsFilter implements ApiFilter {
// //Request filters for get_results
// LIMIT("limit"),
// OFFSET("offset"),
// STATUS_ID("status_id");
//
// private String filter;
// GetResultsFilter(String filter) { this.filter = filter; }
//
// public String getFilter() {
// return filter;
// }
// }
// Path: src/main/java/com/rmn/testrail/entity/TestInstance.java
import com.rmn.testrail.parameters.ApiFilterValue;
import com.rmn.testrail.parameters.GetResultsFilter;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import java.util.List;
private Integer assignedtoId;
public Integer getAssignedtoId() { return assignedtoId; }
public void setAssignedtoId(Integer assignedtoId) { this.assignedtoId = assignedtoId; }
@JsonProperty("run_id")
private Integer runId;
public Integer getRunId() { return runId; }
public void setRunId(Integer runId) { this.runId = runId; }
@JsonProperty("case_id")
private Integer caseId;
public Integer getCaseId() { return caseId; }
public void setCaseId(Integer caseId) { this.caseId = caseId; }
@JsonProperty("milestone_id")
private Integer milestoneId;
public Integer getMilestoneId() { return milestoneId; }
public void setMilestoneId(Integer milestoneId) { this.milestoneId = milestoneId; }
@JsonProperty("refs")
private String refs;
public String getRefs() { return refs; }
public void setRefs(String refs) { this.refs = refs; }
/**
* Returns the list of test results (most recent first) associated with this TestInstance
* @param limit A limit to the number of results you want to see (1 will give you the single most recent)
* @return The number of TestResults specified by the limit, in descending chron order (i.e. newest to oldest)
*/
public List<TestResult> getResults(int limit) { | return getTestRailService().getTestResults(this.getId(), new ApiFilterValue(GetResultsFilter.LIMIT, Integer.toString(limit))); |
RetailMeNot/TestRailSDK | src/main/java/com/rmn/testrail/entity/TestInstance.java | // Path: src/main/java/com/rmn/testrail/parameters/ApiFilterValue.java
// public class ApiFilterValue {
// private ApiFilter apiFilter;
// private String value;
// public ApiFilterValue(ApiFilter apiFilter, String value) {
// this.apiFilter = apiFilter;
// this.value = value;
// }
//
// public String append() {
// return "&" + this.apiFilter.getFilter() + "=" + value;
// }
// }
//
// Path: src/main/java/com/rmn/testrail/parameters/GetResultsFilter.java
// public enum GetResultsFilter implements ApiFilter {
// //Request filters for get_results
// LIMIT("limit"),
// OFFSET("offset"),
// STATUS_ID("status_id");
//
// private String filter;
// GetResultsFilter(String filter) { this.filter = filter; }
//
// public String getFilter() {
// return filter;
// }
// }
| import com.rmn.testrail.parameters.ApiFilterValue;
import com.rmn.testrail.parameters.GetResultsFilter;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import java.util.List; | private Integer assignedtoId;
public Integer getAssignedtoId() { return assignedtoId; }
public void setAssignedtoId(Integer assignedtoId) { this.assignedtoId = assignedtoId; }
@JsonProperty("run_id")
private Integer runId;
public Integer getRunId() { return runId; }
public void setRunId(Integer runId) { this.runId = runId; }
@JsonProperty("case_id")
private Integer caseId;
public Integer getCaseId() { return caseId; }
public void setCaseId(Integer caseId) { this.caseId = caseId; }
@JsonProperty("milestone_id")
private Integer milestoneId;
public Integer getMilestoneId() { return milestoneId; }
public void setMilestoneId(Integer milestoneId) { this.milestoneId = milestoneId; }
@JsonProperty("refs")
private String refs;
public String getRefs() { return refs; }
public void setRefs(String refs) { this.refs = refs; }
/**
* Returns the list of test results (most recent first) associated with this TestInstance
* @param limit A limit to the number of results you want to see (1 will give you the single most recent)
* @return The number of TestResults specified by the limit, in descending chron order (i.e. newest to oldest)
*/
public List<TestResult> getResults(int limit) { | // Path: src/main/java/com/rmn/testrail/parameters/ApiFilterValue.java
// public class ApiFilterValue {
// private ApiFilter apiFilter;
// private String value;
// public ApiFilterValue(ApiFilter apiFilter, String value) {
// this.apiFilter = apiFilter;
// this.value = value;
// }
//
// public String append() {
// return "&" + this.apiFilter.getFilter() + "=" + value;
// }
// }
//
// Path: src/main/java/com/rmn/testrail/parameters/GetResultsFilter.java
// public enum GetResultsFilter implements ApiFilter {
// //Request filters for get_results
// LIMIT("limit"),
// OFFSET("offset"),
// STATUS_ID("status_id");
//
// private String filter;
// GetResultsFilter(String filter) { this.filter = filter; }
//
// public String getFilter() {
// return filter;
// }
// }
// Path: src/main/java/com/rmn/testrail/entity/TestInstance.java
import com.rmn.testrail.parameters.ApiFilterValue;
import com.rmn.testrail.parameters.GetResultsFilter;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import java.util.List;
private Integer assignedtoId;
public Integer getAssignedtoId() { return assignedtoId; }
public void setAssignedtoId(Integer assignedtoId) { this.assignedtoId = assignedtoId; }
@JsonProperty("run_id")
private Integer runId;
public Integer getRunId() { return runId; }
public void setRunId(Integer runId) { this.runId = runId; }
@JsonProperty("case_id")
private Integer caseId;
public Integer getCaseId() { return caseId; }
public void setCaseId(Integer caseId) { this.caseId = caseId; }
@JsonProperty("milestone_id")
private Integer milestoneId;
public Integer getMilestoneId() { return milestoneId; }
public void setMilestoneId(Integer milestoneId) { this.milestoneId = milestoneId; }
@JsonProperty("refs")
private String refs;
public String getRefs() { return refs; }
public void setRefs(String refs) { this.refs = refs; }
/**
* Returns the list of test results (most recent first) associated with this TestInstance
* @param limit A limit to the number of results you want to see (1 will give you the single most recent)
* @return The number of TestResults specified by the limit, in descending chron order (i.e. newest to oldest)
*/
public List<TestResult> getResults(int limit) { | return getTestRailService().getTestResults(this.getId(), new ApiFilterValue(GetResultsFilter.LIMIT, Integer.toString(limit))); |
pmonks/alfresco-bulk-import | amp/src/main/java/org/alfresco/extension/bulkimport/impl/BulkImporterImpl.java | // Path: api/src/main/java/org/alfresco/extension/bulkimport/source/BulkImportSource.java
// public interface BulkImportSource
// {
// /**
// * @return The human readable name of this bulk import source <i>(must not be null, empty or blank)</i>.
// */
// String getName();
//
//
// /**
// * @return A description of this bulk import source - may contain HTML tags <i>(may be null, empty or blank)</i>.
// */
// String getDescription();
//
//
// /**
// * @return The parameters used to initialise this import source, as human-readable text <i>(may be null or empty)</i>.
// */
// Map<String, String> getParameters();
//
//
// /**
// * @return The URI of the Web Script to display in the initiation form, when this source is selected <i>(may be null)</i>.
// */
// String getConfigWebScriptURI();
//
//
// /**
// * Called before anything else, so that the source can validate and parse its parameters. If the parameters are invalid,
// * sources should throw an <code>IllegalArgumentException</code> with details on which parameters were missing / invalid.
// *
// * @param status The status object to use to pre-register any source-side statistics <i>(will not be null)</li>.
// * @param parameters The parameters (if any) provided by the initiator of the import <i>(will not be null, but may be empty)</i>.
// */
// void init(BulkImportSourceStatus status, Map<String, List<String>> parameters);
//
//
// /**
// * Query to determine whether an "in-place" import is possible, given the provided parameters. Note that this doesn't imply
// * that all content in the source must be imported in-place - that can be decided by a source implementation on a file-by-file
// * basis. Instead this is indicative of whether any amount of in-place import is possible or not.
// *
// * @return True if an in-place import is possible with the given parameters, or false otherwise.
// */
// boolean inPlaceImportPossible();
//
//
// /**
// * Called when the folder scanning phase of a bulk import is commenced. Importable items should be submitted via the callback,
// * and status may (optionally) be provided via the status object.
// *
// * Notes:
// * <ol>
// * <li>Items must be submitted in dependency order i.e. parents before children.
// * Failure to do so will have a <b>severe</b> impact on performance (due to
// * transactional rollbacks, followed by retries).</li>
// * <li>This code <u>must not</u> use any Alfresco repository services whatsoever,
// * as this method is executed on a background thread that runs outside of both
// * an Alfresco authentication context and an Alfresco transaction.</li>
// * </ol>
// *
// * @param status The status object to use to report source-side statistics <i>(will not be null)</li>.
// * @param callback The callback into the bulk import engine with which to enqueue items discovered <i>(will not be null)</li>.
// * @throws InterruptedException Should be thrown if the thread running the scan is interrupted.
// */
// void scanFolders(BulkImportSourceStatus status, BulkImportCallback callback)
// throws InterruptedException;
//
//
// /**
// * Called when the file scanning phase of a bulk import is commenced. Importable items should be submitted via the callback,
// * and status may (optionally) be provided via the status object.
// *
// * Notes:
// * <ol>
// * <li>This code must <u>not</u> use any Alfresco repository services whatsoever,
// * as this method is executed on a background thread that runs outside of both
// * an Alfresco authentication context and an Alfresco transaction.</li>
// * </ol>
// *
// * @param status The status object to use to report source-side statistics <i>(will not be null)</li>.
// * @param callback The callback into the bulk import engine with which to enqueue items discovered <i>(will not be null)</li>.
// * @throws InterruptedException Should be thrown if the thread running the scan is interrupted.
// */
// void scanFiles(BulkImportSourceStatus status, BulkImportCallback callback)
// throws InterruptedException;
//
// }
| import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.alfresco.extension.bulkimport.util.ThreadPauser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.extension.bulkimport.BulkImportCompletionHandler;
import org.alfresco.extension.bulkimport.BulkImportStatus;
import org.alfresco.extension.bulkimport.BulkImporter;
import org.alfresco.extension.bulkimport.source.BulkImportSource;
import static org.alfresco.extension.bulkimport.util.LogUtils.*; | this.authenticationService = serviceRegistry.getAuthenticationService();
this.importStatus = importStatus;
this.pauser = pauser;
this.batchImporter = batchImporter;
this.batchWeight = batchWeight <= 0 ? DEFAULT_BATCH_WEIGHT : batchWeight;
this.completionHandlers = completionHandlers;
}
/**
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/
@Override
public void setApplicationContext(final ApplicationContext appContext)
throws BeansException
{
// PRECONDITIONS
assert appContext != null : "appContext must not be null.";
// Body
this.appContext = appContext;
}
/**
* @see org.alfresco.extension.bulkimport.BulkImporter#getBulkImportSources()
*/
@Override | // Path: api/src/main/java/org/alfresco/extension/bulkimport/source/BulkImportSource.java
// public interface BulkImportSource
// {
// /**
// * @return The human readable name of this bulk import source <i>(must not be null, empty or blank)</i>.
// */
// String getName();
//
//
// /**
// * @return A description of this bulk import source - may contain HTML tags <i>(may be null, empty or blank)</i>.
// */
// String getDescription();
//
//
// /**
// * @return The parameters used to initialise this import source, as human-readable text <i>(may be null or empty)</i>.
// */
// Map<String, String> getParameters();
//
//
// /**
// * @return The URI of the Web Script to display in the initiation form, when this source is selected <i>(may be null)</i>.
// */
// String getConfigWebScriptURI();
//
//
// /**
// * Called before anything else, so that the source can validate and parse its parameters. If the parameters are invalid,
// * sources should throw an <code>IllegalArgumentException</code> with details on which parameters were missing / invalid.
// *
// * @param status The status object to use to pre-register any source-side statistics <i>(will not be null)</li>.
// * @param parameters The parameters (if any) provided by the initiator of the import <i>(will not be null, but may be empty)</i>.
// */
// void init(BulkImportSourceStatus status, Map<String, List<String>> parameters);
//
//
// /**
// * Query to determine whether an "in-place" import is possible, given the provided parameters. Note that this doesn't imply
// * that all content in the source must be imported in-place - that can be decided by a source implementation on a file-by-file
// * basis. Instead this is indicative of whether any amount of in-place import is possible or not.
// *
// * @return True if an in-place import is possible with the given parameters, or false otherwise.
// */
// boolean inPlaceImportPossible();
//
//
// /**
// * Called when the folder scanning phase of a bulk import is commenced. Importable items should be submitted via the callback,
// * and status may (optionally) be provided via the status object.
// *
// * Notes:
// * <ol>
// * <li>Items must be submitted in dependency order i.e. parents before children.
// * Failure to do so will have a <b>severe</b> impact on performance (due to
// * transactional rollbacks, followed by retries).</li>
// * <li>This code <u>must not</u> use any Alfresco repository services whatsoever,
// * as this method is executed on a background thread that runs outside of both
// * an Alfresco authentication context and an Alfresco transaction.</li>
// * </ol>
// *
// * @param status The status object to use to report source-side statistics <i>(will not be null)</li>.
// * @param callback The callback into the bulk import engine with which to enqueue items discovered <i>(will not be null)</li>.
// * @throws InterruptedException Should be thrown if the thread running the scan is interrupted.
// */
// void scanFolders(BulkImportSourceStatus status, BulkImportCallback callback)
// throws InterruptedException;
//
//
// /**
// * Called when the file scanning phase of a bulk import is commenced. Importable items should be submitted via the callback,
// * and status may (optionally) be provided via the status object.
// *
// * Notes:
// * <ol>
// * <li>This code must <u>not</u> use any Alfresco repository services whatsoever,
// * as this method is executed on a background thread that runs outside of both
// * an Alfresco authentication context and an Alfresco transaction.</li>
// * </ol>
// *
// * @param status The status object to use to report source-side statistics <i>(will not be null)</li>.
// * @param callback The callback into the bulk import engine with which to enqueue items discovered <i>(will not be null)</li>.
// * @throws InterruptedException Should be thrown if the thread running the scan is interrupted.
// */
// void scanFiles(BulkImportSourceStatus status, BulkImportCallback callback)
// throws InterruptedException;
//
// }
// Path: amp/src/main/java/org/alfresco/extension/bulkimport/impl/BulkImporterImpl.java
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.alfresco.extension.bulkimport.util.ThreadPauser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.extension.bulkimport.BulkImportCompletionHandler;
import org.alfresco.extension.bulkimport.BulkImportStatus;
import org.alfresco.extension.bulkimport.BulkImporter;
import org.alfresco.extension.bulkimport.source.BulkImportSource;
import static org.alfresco.extension.bulkimport.util.LogUtils.*;
this.authenticationService = serviceRegistry.getAuthenticationService();
this.importStatus = importStatus;
this.pauser = pauser;
this.batchImporter = batchImporter;
this.batchWeight = batchWeight <= 0 ? DEFAULT_BATCH_WEIGHT : batchWeight;
this.completionHandlers = completionHandlers;
}
/**
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/
@Override
public void setApplicationContext(final ApplicationContext appContext)
throws BeansException
{
// PRECONDITIONS
assert appContext != null : "appContext must not be null.";
// Body
this.appContext = appContext;
}
/**
* @see org.alfresco.extension.bulkimport.BulkImporter#getBulkImportSources()
*/
@Override | public Map<String, BulkImportSource> getBulkImportSources() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.