repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
knowitall/openregex
src/main/java/edu/washington/cs/knowitall/regex/RegularExpression.java
RegularExpression.apply
@Override public boolean apply(List<E> tokens) { if (this.find(tokens) != null) { return true; } else { return false; } }
java
@Override public boolean apply(List<E> tokens) { if (this.find(tokens) != null) { return true; } else { return false; } }
[ "@", "Override", "public", "boolean", "apply", "(", "List", "<", "E", ">", "tokens", ")", "{", "if", "(", "this", ".", "find", "(", "tokens", ")", "!=", "null", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Apply the expression against a list of tokens. @return true iff the expression if found within the tokens.
[ "Apply", "the", "expression", "against", "a", "list", "of", "tokens", "." ]
6dffbcac884b5bd17f9feb7a3107052163f0497d
https://github.com/knowitall/openregex/blob/6dffbcac884b5bd17f9feb7a3107052163f0497d/src/main/java/edu/washington/cs/knowitall/regex/RegularExpression.java#L98-L105
train
knowitall/openregex
src/main/java/edu/washington/cs/knowitall/regex/RegularExpression.java
RegularExpression.find
public Match<E> find(List<E> tokens, int start) { Match<E> match; for (int i = start; i <= tokens.size() - auto.minMatchingLength(); i++) { match = this.lookingAt(tokens, i); if (match != null) { return match; } } return null; }
java
public Match<E> find(List<E> tokens, int start) { Match<E> match; for (int i = start; i <= tokens.size() - auto.minMatchingLength(); i++) { match = this.lookingAt(tokens, i); if (match != null) { return match; } } return null; }
[ "public", "Match", "<", "E", ">", "find", "(", "List", "<", "E", ">", "tokens", ",", "int", "start", ")", "{", "Match", "<", "E", ">", "match", ";", "for", "(", "int", "i", "=", "start", ";", "i", "<=", "tokens", ".", "size", "(", ")", "-", ...
Find the first match of the regular expression against tokens, starting at the specified index. @param tokens tokens to match against. @param start index to start looking for a match. @return an object representing the match, or null if no match is found.
[ "Find", "the", "first", "match", "of", "the", "regular", "expression", "against", "tokens", "starting", "at", "the", "specified", "index", "." ]
6dffbcac884b5bd17f9feb7a3107052163f0497d
https://github.com/knowitall/openregex/blob/6dffbcac884b5bd17f9feb7a3107052163f0497d/src/main/java/edu/washington/cs/knowitall/regex/RegularExpression.java#L138-L148
train
knowitall/openregex
src/main/java/edu/washington/cs/knowitall/regex/RegularExpression.java
RegularExpression.lookingAt
public Match<E> lookingAt(List<E> tokens, int start) { return auto.lookingAt(tokens, start); }
java
public Match<E> lookingAt(List<E> tokens, int start) { return auto.lookingAt(tokens, start); }
[ "public", "Match", "<", "E", ">", "lookingAt", "(", "List", "<", "E", ">", "tokens", ",", "int", "start", ")", "{", "return", "auto", ".", "lookingAt", "(", "tokens", ",", "start", ")", ";", "}" ]
Determine if the regular expression matches the supplied tokens, starting at the specified index. @param tokens the list of tokens to match. @param start the index where the match should begin. @return an object representing the match, or null if no match is found.
[ "Determine", "if", "the", "regular", "expression", "matches", "the", "supplied", "tokens", "starting", "at", "the", "specified", "index", "." ]
6dffbcac884b5bd17f9feb7a3107052163f0497d
https://github.com/knowitall/openregex/blob/6dffbcac884b5bd17f9feb7a3107052163f0497d/src/main/java/edu/washington/cs/knowitall/regex/RegularExpression.java#L169-L171
train
knowitall/openregex
src/main/java/edu/washington/cs/knowitall/regex/RegularExpression.java
RegularExpression.findAll
public List<Match<E>> findAll(List<E> tokens) { List<Match<E>> results = new ArrayList<Match<E>>(); int start = 0; Match<E> match; do { match = this.find(tokens, start); if (match != null) { start = match.endIndex(); // match may be empty query string has all optional parts if (!match.isEmpty()) { results.add(match); } } } while (match != null); return results; }
java
public List<Match<E>> findAll(List<E> tokens) { List<Match<E>> results = new ArrayList<Match<E>>(); int start = 0; Match<E> match; do { match = this.find(tokens, start); if (match != null) { start = match.endIndex(); // match may be empty query string has all optional parts if (!match.isEmpty()) { results.add(match); } } } while (match != null); return results; }
[ "public", "List", "<", "Match", "<", "E", ">", ">", "findAll", "(", "List", "<", "E", ">", "tokens", ")", "{", "List", "<", "Match", "<", "E", ">>", "results", "=", "new", "ArrayList", "<", "Match", "<", "E", ">", ">", "(", ")", ";", "int", "...
Find all non-overlapping matches of the regular expression against tokens. @param tokens @return an list of objects representing the match.
[ "Find", "all", "non", "-", "overlapping", "matches", "of", "the", "regular", "expression", "against", "tokens", "." ]
6dffbcac884b5bd17f9feb7a3107052163f0497d
https://github.com/knowitall/openregex/blob/6dffbcac884b5bd17f9feb7a3107052163f0497d/src/main/java/edu/washington/cs/knowitall/regex/RegularExpression.java#L189-L208
train
knowitall/openregex
src/main/java/edu/washington/cs/knowitall/regex/RegularExpression.java
RegularExpression.main
public static void main(String[] args) { Scanner scan = new Scanner(System.in); RegularExpression<String> regex = RegularExpressionParsers.word.parse(args[0]); System.out.println("regex: " + regex); System.out.println(); while (scan.hasNextLine()) { String line = scan.nextLine(); System.out.println("contains: " + regex.apply(Arrays.asList(line.split("\\s+")))); System.out.println("matches: " + regex.matches(Arrays.asList(line.split("\\s+")))); System.out.println(); } scan.close(); }
java
public static void main(String[] args) { Scanner scan = new Scanner(System.in); RegularExpression<String> regex = RegularExpressionParsers.word.parse(args[0]); System.out.println("regex: " + regex); System.out.println(); while (scan.hasNextLine()) { String line = scan.nextLine(); System.out.println("contains: " + regex.apply(Arrays.asList(line.split("\\s+")))); System.out.println("matches: " + regex.matches(Arrays.asList(line.split("\\s+")))); System.out.println(); } scan.close(); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Scanner", "scan", "=", "new", "Scanner", "(", "System", ".", "in", ")", ";", "RegularExpression", "<", "String", ">", "regex", "=", "RegularExpressionParsers", ".", "word", "...
An interactive program that compiles a word-based regular expression specified in arg1 and then reads strings from stdin, evaluating them against the regular expression. @param args
[ "An", "interactive", "program", "that", "compiles", "a", "word", "-", "based", "regular", "expression", "specified", "in", "arg1", "and", "then", "reads", "strings", "from", "stdin", "evaluating", "them", "against", "the", "regular", "expression", "." ]
6dffbcac884b5bd17f9feb7a3107052163f0497d
https://github.com/knowitall/openregex/blob/6dffbcac884b5bd17f9feb7a3107052163f0497d/src/main/java/edu/washington/cs/knowitall/regex/RegularExpression.java#L216-L232
train
houbie/lesscss
src/main/java/com/github/houbie/lesscss/builder/CompilationUnit.java
CompilationUnit.isEquivalent
public boolean isEquivalent(CompilationUnit other) { if (!destination.getAbsoluteFile().equals(other.destination.getAbsoluteFile())) return false; if (encoding != null ? !encoding.equals(other.encoding) : other.encoding != null) return false; if (resourceReader != null ? !resourceReader.equals(other.resourceReader) : other.resourceReader != null) return false; if (!options.equals(other.options)) return false; if (sourceMapFile != null ? !sourceMapFile.equals(other.sourceMapFile) : other.sourceMapFile != null) return false; return sourceLocation.equals(other.sourceLocation); }
java
public boolean isEquivalent(CompilationUnit other) { if (!destination.getAbsoluteFile().equals(other.destination.getAbsoluteFile())) return false; if (encoding != null ? !encoding.equals(other.encoding) : other.encoding != null) return false; if (resourceReader != null ? !resourceReader.equals(other.resourceReader) : other.resourceReader != null) return false; if (!options.equals(other.options)) return false; if (sourceMapFile != null ? !sourceMapFile.equals(other.sourceMapFile) : other.sourceMapFile != null) return false; return sourceLocation.equals(other.sourceLocation); }
[ "public", "boolean", "isEquivalent", "(", "CompilationUnit", "other", ")", "{", "if", "(", "!", "destination", ".", "getAbsoluteFile", "(", ")", ".", "equals", "(", "other", ".", "destination", ".", "getAbsoluteFile", "(", ")", ")", ")", "return", "false", ...
Checks whether two compilation units represent the same compilation. Only the imports may be different when they have not yet been set. @param other CompilationUnit to compare with @return true if the source, destination, encoding, options and resourceReader are the same.
[ "Checks", "whether", "two", "compilation", "units", "represent", "the", "same", "compilation", ".", "Only", "the", "imports", "may", "be", "different", "when", "they", "have", "not", "yet", "been", "set", "." ]
65196738939263d767e7933f34322536a0c7090f
https://github.com/houbie/lesscss/blob/65196738939263d767e7933f34322536a0c7090f/src/main/java/com/github/houbie/lesscss/builder/CompilationUnit.java#L213-L222
train
vRallev/ECC-25519
ECC-25519-Android/ecc-25519/src/main/java/com/github/dazoe/android/Ed25519.java
Ed25519.SHA512_Init
private static MessageDigest SHA512_Init() { Log.d("Ed25519", "SHA512_Init"); try { return MessageDigest.getInstance("SHA-512"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; }
java
private static MessageDigest SHA512_Init() { Log.d("Ed25519", "SHA512_Init"); try { return MessageDigest.getInstance("SHA-512"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; }
[ "private", "static", "MessageDigest", "SHA512_Init", "(", ")", "{", "Log", ".", "d", "(", "\"Ed25519\"", ",", "\"SHA512_Init\"", ")", ";", "try", "{", "return", "MessageDigest", ".", "getInstance", "(", "\"SHA-512\"", ")", ";", "}", "catch", "(", "NoSuchAlgo...
jni c code calls this for sha512.
[ "jni", "c", "code", "calls", "this", "for", "sha512", "." ]
5c4297933aabfa4fbe7675e36d6d923ffd22e2cb
https://github.com/vRallev/ECC-25519/blob/5c4297933aabfa4fbe7675e36d6d923ffd22e2cb/ECC-25519-Android/ecc-25519/src/main/java/com/github/dazoe/android/Ed25519.java#L45-L53
train
renepickhardt/metalcon
autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Retrieve/ProcessRetrieveResponse.java
ProcessRetrieveResponse.addIndexWarning
public void addIndexWarning(String noIndexGiven) { if (jsonResponse==null){ jsonResponse = new JSONObject(); } jsonResponse.put("warning:noIndexGiven", noIndexGiven); }
java
public void addIndexWarning(String noIndexGiven) { if (jsonResponse==null){ jsonResponse = new JSONObject(); } jsonResponse.put("warning:noIndexGiven", noIndexGiven); }
[ "public", "void", "addIndexWarning", "(", "String", "noIndexGiven", ")", "{", "if", "(", "jsonResponse", "==", "null", ")", "{", "jsonResponse", "=", "new", "JSONObject", "(", ")", ";", "}", "jsonResponse", ".", "put", "(", "\"warning:noIndexGiven\"", ",", "...
not implemented yet @param noIndexGiven
[ "not", "implemented", "yet" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Retrieve/ProcessRetrieveResponse.java#L53-L58
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/delete/follow/DeleteFollowRequest.java
DeleteFollowRequest.checkRequest
public static DeleteFollowRequest checkRequest( final HttpServletRequest request, final DeleteRequest deleteRequest, final DeleteFollowResponse deleteFollowResponse) { final Node user = checkUserIdentifier(request, deleteFollowResponse); if (user != null) { final Node followed = checkFollowedIdentifier(request, deleteFollowResponse); if (followed != null) { return new DeleteFollowRequest(deleteRequest.getType(), user, followed); } } return null; }
java
public static DeleteFollowRequest checkRequest( final HttpServletRequest request, final DeleteRequest deleteRequest, final DeleteFollowResponse deleteFollowResponse) { final Node user = checkUserIdentifier(request, deleteFollowResponse); if (user != null) { final Node followed = checkFollowedIdentifier(request, deleteFollowResponse); if (followed != null) { return new DeleteFollowRequest(deleteRequest.getType(), user, followed); } } return null; }
[ "public", "static", "DeleteFollowRequest", "checkRequest", "(", "final", "HttpServletRequest", "request", ",", "final", "DeleteRequest", "deleteRequest", ",", "final", "DeleteFollowResponse", "deleteFollowResponse", ")", "{", "final", "Node", "user", "=", "checkUserIdenti...
check a delete follow edge request for validity concerning NSSP @param request Tomcat servlet request @param deleteRequest basic delete request object @param deleteFollowResponse delete follow edge response object @return delete follow edge request object<br> <b>null</b> if the delete follow edge request is invalid
[ "check", "a", "delete", "follow", "edge", "request", "for", "validity", "concerning", "NSSP" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/delete/follow/DeleteFollowRequest.java#L75-L90
train
renepickhardt/metalcon
autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Retrieve/RetrieveServlet.java
RetrieveServlet.doGet
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { long start = System.nanoTime(); ProcessRetrieveResponse responseObject = ProcessRetrieveRequest.checkRequestParameter(request, this.getServletContext()); String resultJson = responseObject.buildJsonResonse(); response.setContentType("application/json"); PrintWriter out = response.getWriter(); long end = System.nanoTime(); //+ " " + (end - start)/1000 + " micro seconds" out.println(resultJson); out.flush(); }
java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { long start = System.nanoTime(); ProcessRetrieveResponse responseObject = ProcessRetrieveRequest.checkRequestParameter(request, this.getServletContext()); String resultJson = responseObject.buildJsonResonse(); response.setContentType("application/json"); PrintWriter out = response.getWriter(); long end = System.nanoTime(); //+ " " + (end - start)/1000 + " micro seconds" out.println(resultJson); out.flush(); }
[ "@", "Override", "protected", "void", "doGet", "(", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ")", "throws", "ServletException", ",", "IOException", "{", "long", "start", "=", "System", ".", "nanoTime", "(", ")", ";", "ProcessRetriev...
de.metalcon.autocompleteServer.Retrieve.RetrieveServlet @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
[ "de", ".", "metalcon", ".", "autocompleteServer", ".", "Retrieve", ".", "RetrieveServlet" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Retrieve/RetrieveServlet.java#L32-L45
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/create/CreateRequest.java
CreateRequest.checkType
private static CreateRequestType checkType(final FormItemList formItemList, final CreateResponse createResponse) { final String sType = formItemList .getField(ProtocolConstants.Parameters.Create.TYPE); if (sType != null) { if (CreateRequestType.USER.getIdentifier().equals(sType)) { return CreateRequestType.USER; } else if (CreateRequestType.FOLLOW.getIdentifier().equals(sType)) { return CreateRequestType.FOLLOW; } else if (CreateRequestType.STATUS_UPDATE.getIdentifier().equals( sType)) { return CreateRequestType.STATUS_UPDATE; } createResponse.typeInvalid(sType); } else { createResponse.typeMissing(); } return null; }
java
private static CreateRequestType checkType(final FormItemList formItemList, final CreateResponse createResponse) { final String sType = formItemList .getField(ProtocolConstants.Parameters.Create.TYPE); if (sType != null) { if (CreateRequestType.USER.getIdentifier().equals(sType)) { return CreateRequestType.USER; } else if (CreateRequestType.FOLLOW.getIdentifier().equals(sType)) { return CreateRequestType.FOLLOW; } else if (CreateRequestType.STATUS_UPDATE.getIdentifier().equals( sType)) { return CreateRequestType.STATUS_UPDATE; } createResponse.typeInvalid(sType); } else { createResponse.typeMissing(); } return null; }
[ "private", "static", "CreateRequestType", "checkType", "(", "final", "FormItemList", "formItemList", ",", "final", "CreateResponse", "createResponse", ")", "{", "final", "String", "sType", "=", "formItemList", ".", "getField", "(", "ProtocolConstants", ".", "Parameter...
check if the request contains a valid create request type @param formItemList form item list @param createResponse create response object @return create request type<br> <b>null</b> if the create request type is invalid
[ "check", "if", "the", "request", "contains", "a", "valid", "create", "request", "type" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/create/CreateRequest.java#L97-L117
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/tomcat/Create.java
Create.writeFiles
private void writeFiles(final StatusUpdateTemplate template, final FormItemList items) throws Exception { FormFile fileItem; TemplateFileInfo fileInfo; for (String fileIdentifier : items.getFileIdentifiers()) { fileItem = items.getFile(fileIdentifier); fileInfo = template.getFiles().get(fileIdentifier); if (fileInfo.getContentType().equals(fileItem.getContentType())) { // write the file and store it within the instantiation item final File file = this.writeFile(fileItem); fileItem.setFile(file); } else { throw new StatusUpdateInstantiationFailedException("file \"" + fileIdentifier + "\" must have content type " + fileInfo.getContentType()); } } }
java
private void writeFiles(final StatusUpdateTemplate template, final FormItemList items) throws Exception { FormFile fileItem; TemplateFileInfo fileInfo; for (String fileIdentifier : items.getFileIdentifiers()) { fileItem = items.getFile(fileIdentifier); fileInfo = template.getFiles().get(fileIdentifier); if (fileInfo.getContentType().equals(fileItem.getContentType())) { // write the file and store it within the instantiation item final File file = this.writeFile(fileItem); fileItem.setFile(file); } else { throw new StatusUpdateInstantiationFailedException("file \"" + fileIdentifier + "\" must have content type " + fileInfo.getContentType()); } } }
[ "private", "void", "writeFiles", "(", "final", "StatusUpdateTemplate", "template", ",", "final", "FormItemList", "items", ")", "throws", "Exception", "{", "FormFile", "fileItem", ";", "TemplateFileInfo", "fileInfo", ";", "for", "(", "String", "fileIdentifier", ":", ...
write the files posted if they are matching to the template targeted @param template status update template targeted @param items form item list @throws StatusUpdateInstantiationFailedException if a file is not matching the content type set @throws Exception if a file could not be written
[ "write", "the", "files", "posted", "if", "they", "are", "matching", "to", "the", "template", "targeted" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/Create.java#L209-L227
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/tomcat/Create.java
Create.writeFile
private File writeFile(final FormFile fileItem) throws Exception { final String directory = this.getFileDir(fileItem.getContentType()); // TODO: ensure unique file names final File file = new File(directory + System.currentTimeMillis() + "-" + fileItem.getOriginalFileName()); fileItem.getFormItem().write(file); return file; }
java
private File writeFile(final FormFile fileItem) throws Exception { final String directory = this.getFileDir(fileItem.getContentType()); // TODO: ensure unique file names final File file = new File(directory + System.currentTimeMillis() + "-" + fileItem.getOriginalFileName()); fileItem.getFormItem().write(file); return file; }
[ "private", "File", "writeFile", "(", "final", "FormFile", "fileItem", ")", "throws", "Exception", "{", "final", "String", "directory", "=", "this", ".", "getFileDir", "(", "fileItem", ".", "getContentType", "(", ")", ")", ";", "// TODO: ensure unique file names", ...
write a file to the directory matching its content type @param fileItem form file @return instance of the file written @throws Exception if the file could not be written
[ "write", "a", "file", "to", "the", "directory", "matching", "its", "content", "type" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/Create.java#L238-L246
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdate.java
StatusUpdate.toJSONObject
@SuppressWarnings("unchecked") public JSONObject toJSONObject() { final JSONObject activity = new JSONObject(); // parse time stamp activity.put("published", dateFormatter.format(new Date(this.timestamp))); // TODO: check performance // parse user // final Map<String, Object> user = this.creator.toActorJSON(); // activity.put("actor", user); // parse verb:read activity.put("verb", "read"); // parse object final Map<String, Object> object = this.toObjectJSON(); activity.put("object", object); return activity; }
java
@SuppressWarnings("unchecked") public JSONObject toJSONObject() { final JSONObject activity = new JSONObject(); // parse time stamp activity.put("published", dateFormatter.format(new Date(this.timestamp))); // TODO: check performance // parse user // final Map<String, Object> user = this.creator.toActorJSON(); // activity.put("actor", user); // parse verb:read activity.put("verb", "read"); // parse object final Map<String, Object> object = this.toObjectJSON(); activity.put("object", object); return activity; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "JSONObject", "toJSONObject", "(", ")", "{", "final", "JSONObject", "activity", "=", "new", "JSONObject", "(", ")", ";", "// parse time stamp", "activity", ".", "put", "(", "\"published\"", ",", "date...
parse the status update to an Activity JSON String @return Activity JSON String representing this status update<br> (Activitystrea.ms)
[ "parse", "the", "status", "update", "to", "an", "Activity", "JSON", "String" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdate.java#L119-L140
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdate.java
StatusUpdate.toObjectJSON
protected Map<String, Object> toObjectJSON() { final Map<String, Object> objectJSON = new LinkedHashMap<String, Object>(); // TODO: select correct object type - usage of own types allowed? objectJSON.put("objectType", "article"); objectJSON.put("type", this.type); objectJSON.put("id", this.id); return objectJSON; }
java
protected Map<String, Object> toObjectJSON() { final Map<String, Object> objectJSON = new LinkedHashMap<String, Object>(); // TODO: select correct object type - usage of own types allowed? objectJSON.put("objectType", "article"); objectJSON.put("type", this.type); objectJSON.put("id", this.id); return objectJSON; }
[ "protected", "Map", "<", "String", ",", "Object", ">", "toObjectJSON", "(", ")", "{", "final", "Map", "<", "String", ",", "Object", ">", "objectJSON", "=", "new", "LinkedHashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "// TODO: select correct o...
parse the status update to an Object JSON map @return Object JSON map representing this status update<br> (Activitystrea.ms)
[ "parse", "the", "status", "update", "to", "an", "Object", "JSON", "map" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdate.java#L148-L156
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.loadProperties
private static Properties loadProperties(String propertiesFile) { Properties properties = new Properties(); try (InputStream is = new FileInputStream(propertiesFile)) { properties.load(is); } catch (IOException e) { throw new RuntimeException("failed to load properties", e); } return properties; }
java
private static Properties loadProperties(String propertiesFile) { Properties properties = new Properties(); try (InputStream is = new FileInputStream(propertiesFile)) { properties.load(is); } catch (IOException e) { throw new RuntimeException("failed to load properties", e); } return properties; }
[ "private", "static", "Properties", "loadProperties", "(", "String", "propertiesFile", ")", "{", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "try", "(", "InputStream", "is", "=", "new", "FileInputStream", "(", "propertiesFile", ")", ")", ...
Loads properties from a properties file on the local filesystem.
[ "Loads", "properties", "from", "a", "properties", "file", "on", "the", "local", "filesystem", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L60-L68
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.loadPropertiesFromClasspath
private static Properties loadPropertiesFromClasspath(String propertiesFile) { Properties properties = new Properties(); try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(propertiesFile)) { properties.load(is); } catch (IOException e) { throw new RuntimeException("failed to load properties", e); } return properties; }
java
private static Properties loadPropertiesFromClasspath(String propertiesFile) { Properties properties = new Properties(); try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(propertiesFile)) { properties.load(is); } catch (IOException e) { throw new RuntimeException("failed to load properties", e); } return properties; }
[ "private", "static", "Properties", "loadPropertiesFromClasspath", "(", "String", "propertiesFile", ")", "{", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "try", "(", "InputStream", "is", "=", "Thread", ".", "currentThread", "(", ")", ".",...
Loads properties from a properties file on the classpath.
[ "Loads", "properties", "from", "a", "properties", "file", "on", "the", "classpath", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L73-L81
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getCollection
public <T> Collection<T> getCollection(String prefix, Function<String, T> factory) { Collection<T> collection = new ArrayList<>(); for (String property : properties.stringPropertyNames()) { if (property.startsWith(prefix + ".")) { collection.add(factory.apply(property)); } } return collection; }
java
public <T> Collection<T> getCollection(String prefix, Function<String, T> factory) { Collection<T> collection = new ArrayList<>(); for (String property : properties.stringPropertyNames()) { if (property.startsWith(prefix + ".")) { collection.add(factory.apply(property)); } } return collection; }
[ "public", "<", "T", ">", "Collection", "<", "T", ">", "getCollection", "(", "String", "prefix", ",", "Function", "<", "String", ",", "T", ">", "factory", ")", "{", "Collection", "<", "T", ">", "collection", "=", "new", "ArrayList", "<>", "(", ")", ";...
Reads a collection of properties based on a prefix. @param prefix The prefix for which to read properties. @param factory The factory to call for each property name in the collection. @param <T> The collection value type. @return The collection.
[ "Reads", "a", "collection", "of", "properties", "based", "on", "a", "prefix", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L106-L114
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getMap
public <K, V> Map<K, V> getMap(String prefix, Function<String, K> keyFactory, Function<String, V> valueFactory) { Map<K, V> map = new HashMap<>(); for (String property : properties.stringPropertyNames()) { if (property.startsWith(prefix + ".")) { map.put(keyFactory.apply(property.substring(prefix.length() + 1)), valueFactory.apply(properties.getProperty(property))); } } return map; }
java
public <K, V> Map<K, V> getMap(String prefix, Function<String, K> keyFactory, Function<String, V> valueFactory) { Map<K, V> map = new HashMap<>(); for (String property : properties.stringPropertyNames()) { if (property.startsWith(prefix + ".")) { map.put(keyFactory.apply(property.substring(prefix.length() + 1)), valueFactory.apply(properties.getProperty(property))); } } return map; }
[ "public", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "getMap", "(", "String", "prefix", ",", "Function", "<", "String", ",", "K", ">", "keyFactory", ",", "Function", "<", "String", ",", "V", ">", "valueFactory", ")", "{", "Map", "<"...
Returns a map of properties for a given prefix. @param prefix The prefix for which to return a map of property values. @param keyFactory A converter function to convert the map keys. @param valueFactory A converter function to convert the map values. @param <K> The map key type. @param <V> The map value type. @return The map.
[ "Returns", "a", "map", "of", "properties", "for", "a", "given", "prefix", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L126-L135
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getClass
public Class<?> getClass(String property) { return getProperty(property, className -> { try { return Class.forName(className); } catch (ClassNotFoundException e) { throw new ConfigurationException("unknown class: " + className, e); } }); }
java
public Class<?> getClass(String property) { return getProperty(property, className -> { try { return Class.forName(className); } catch (ClassNotFoundException e) { throw new ConfigurationException("unknown class: " + className, e); } }); }
[ "public", "Class", "<", "?", ">", "getClass", "(", "String", "property", ")", "{", "return", "getProperty", "(", "property", ",", "className", "->", "{", "try", "{", "return", "Class", ".", "forName", "(", "className", ")", ";", "}", "catch", "(", "Cla...
Reads a class property. @param property The property name. @return The property value. @throws ConfigurationException if the property is not present
[ "Reads", "a", "class", "property", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L144-L152
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getFile
public File getFile(String property, File defaultValue) { return getProperty(property, defaultValue, File::new); }
java
public File getFile(String property, File defaultValue) { return getProperty(property, defaultValue, File::new); }
[ "public", "File", "getFile", "(", "String", "property", ",", "File", "defaultValue", ")", "{", "return", "getProperty", "(", "property", ",", "defaultValue", ",", "File", "::", "new", ")", ";", "}" ]
Reads a file property. @param property The property name. @param defaultValue The default value to return if the property is not present @return The property value.
[ "Reads", "a", "file", "property", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L189-L191
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getEnum
public <T extends Enum<T>> T getEnum(String property, Class<T> type) { return Enum.valueOf(type, getString(property)); }
java
public <T extends Enum<T>> T getEnum(String property, Class<T> type) { return Enum.valueOf(type, getString(property)); }
[ "public", "<", "T", "extends", "Enum", "<", "T", ">", ">", "T", "getEnum", "(", "String", "property", ",", "Class", "<", "T", ">", "type", ")", "{", "return", "Enum", ".", "valueOf", "(", "type", ",", "getString", "(", "property", ")", ")", ";", ...
Reads an enum property. @param property The property name. @param type The enum type. @param <T> The enum type. @return The property value. @throws ConfigurationException if the property is not present
[ "Reads", "an", "enum", "property", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L202-L204
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getString
public String getString(String property, String defaultValue) { return getProperty(property, defaultValue, v -> v); }
java
public String getString(String property, String defaultValue) { return getProperty(property, defaultValue, v -> v); }
[ "public", "String", "getString", "(", "String", "property", ",", "String", "defaultValue", ")", "{", "return", "getProperty", "(", "property", ",", "defaultValue", ",", "v", "->", "v", ")", ";", "}" ]
Reads a string property, returning a default value if the property is not present. @param property The property name. @param defaultValue The default value to return if the property is not present. @return The property value.
[ "Reads", "a", "string", "property", "returning", "a", "default", "value", "if", "the", "property", "is", "not", "present", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L237-L239
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getBoolean
public boolean getBoolean(String property) { return getProperty(property, value -> { switch (value.trim().toLowerCase()) { case "true": case "1": return true; case "false": case "0": return false; default: throw new ConfigurationException("invalid property value: " + property + " must be a boolean"); } }); }
java
public boolean getBoolean(String property) { return getProperty(property, value -> { switch (value.trim().toLowerCase()) { case "true": case "1": return true; case "false": case "0": return false; default: throw new ConfigurationException("invalid property value: " + property + " must be a boolean"); } }); }
[ "public", "boolean", "getBoolean", "(", "String", "property", ")", "{", "return", "getProperty", "(", "property", ",", "value", "->", "{", "switch", "(", "value", ".", "trim", "(", ")", ".", "toLowerCase", "(", ")", ")", "{", "case", "\"true\"", ":", "...
Reads a boolean property. @param property The property name. @return The property value. @throws ConfigurationException if the property is not present
[ "Reads", "a", "boolean", "property", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L248-L261
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getShort
public short getShort(String property) { return getProperty(property, value -> { try { return Short.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("malformed property value: " + property + " must be a short"); } }); }
java
public short getShort(String property) { return getProperty(property, value -> { try { return Short.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("malformed property value: " + property + " must be a short"); } }); }
[ "public", "short", "getShort", "(", "String", "property", ")", "{", "return", "getProperty", "(", "property", ",", "value", "->", "{", "try", "{", "return", "Short", ".", "valueOf", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ...
Reads a short property. @param property The property name. @return The property value. @throws ConfigurationException if the property is not present
[ "Reads", "a", "short", "property", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L292-L300
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getInteger
public int getInteger(String property) { return getProperty(property, value -> { try { return Integer.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("malformed property value: " + property + " must be an integer"); } }); }
java
public int getInteger(String property) { return getProperty(property, value -> { try { return Integer.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("malformed property value: " + property + " must be an integer"); } }); }
[ "public", "int", "getInteger", "(", "String", "property", ")", "{", "return", "getProperty", "(", "property", ",", "value", "->", "{", "try", "{", "return", "Integer", ".", "valueOf", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e",...
Reads an integer property. @param property The property name. @return The property value. @throws ConfigurationException if the property is not present
[ "Reads", "an", "integer", "property", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L326-L334
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getLong
public long getLong(String property) { return getProperty(property, value -> { try { return Long.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("malformed property value: " + property + " must be a long"); } }); }
java
public long getLong(String property) { return getProperty(property, value -> { try { return Long.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("malformed property value: " + property + " must be a long"); } }); }
[ "public", "long", "getLong", "(", "String", "property", ")", "{", "return", "getProperty", "(", "property", ",", "value", "->", "{", "try", "{", "return", "Long", ".", "valueOf", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")...
Reads a long property. @param property The property name. @return The property value. @throws ConfigurationException if the property is not present
[ "Reads", "a", "long", "property", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L360-L368
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getFloat
public float getFloat(String property) { return getProperty(property, value -> { try { return Float.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("malformed property value: " + property + " must be a float"); } }); }
java
public float getFloat(String property) { return getProperty(property, value -> { try { return Float.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("malformed property value: " + property + " must be a float"); } }); }
[ "public", "float", "getFloat", "(", "String", "property", ")", "{", "return", "getProperty", "(", "property", ",", "value", "->", "{", "try", "{", "return", "Float", ".", "valueOf", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ...
Reads a float property. @param property The property name. @return The property value. @throws ConfigurationException if the property is not present
[ "Reads", "a", "float", "property", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L394-L402
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getDouble
public double getDouble(String property) { return getProperty(property, value -> { try { return Double.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("malformed property value: " + property + " must be a double"); } }); }
java
public double getDouble(String property) { return getProperty(property, value -> { try { return Double.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("malformed property value: " + property + " must be a double"); } }); }
[ "public", "double", "getDouble", "(", "String", "property", ")", "{", "return", "getProperty", "(", "property", ",", "value", "->", "{", "try", "{", "return", "Double", ".", "valueOf", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e"...
Reads a double property. @param property The property name. @return The property value. @throws ConfigurationException if the property is not present
[ "Reads", "a", "double", "property", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L428-L436
train
atomix/catalyst
common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java
PropertiesReader.getProperty
private <T> T getProperty(String property, Function<String, T> transformer) { Assert.notNull(property, "property"); String value = properties.getProperty(property); if (value == null) throw new ConfigurationException("missing property: " + property); return transformer.apply(value); }
java
private <T> T getProperty(String property, Function<String, T> transformer) { Assert.notNull(property, "property"); String value = properties.getProperty(property); if (value == null) throw new ConfigurationException("missing property: " + property); return transformer.apply(value); }
[ "private", "<", "T", ">", "T", "getProperty", "(", "String", "property", ",", "Function", "<", "String", ",", "T", ">", "transformer", ")", "{", "Assert", ".", "notNull", "(", "property", ",", "\"property\"", ")", ";", "String", "value", "=", "properties...
Reads an arbitrary property. @param property The property name. @param transformer A transformer function with which to transform the property value to its appropriate type. @param <T> The property type. @return The property value. @throws ConfigurationException if the property is not present
[ "Reads", "an", "arbitrary", "property", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/common/src/main/java/io/atomix/catalyst/util/PropertiesReader.java#L498-L504
train
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library
src/main/java/com/github/theholywaffle/lolchatapi/wrapper/FriendGroup.java
FriendGroup.addFriend
public void addFriend(Friend friend) { try { get().addEntry(friend.get()); } catch (NoResponseException | XMPPErrorException | NotConnectedException e) { e.printStackTrace(); } }
java
public void addFriend(Friend friend) { try { get().addEntry(friend.get()); } catch (NoResponseException | XMPPErrorException | NotConnectedException e) { e.printStackTrace(); } }
[ "public", "void", "addFriend", "(", "Friend", "friend", ")", "{", "try", "{", "get", "(", ")", ".", "addEntry", "(", "friend", ".", "get", "(", ")", ")", ";", "}", "catch", "(", "NoResponseException", "|", "XMPPErrorException", "|", "NotConnectedException"...
Moves a friend to this group and removes the friend from his previous group. This is an asynchronous call. @param friend The friend you want to move
[ "Moves", "a", "friend", "to", "this", "group", "and", "removes", "the", "friend", "from", "his", "previous", "group", ".", "This", "is", "an", "asynchronous", "call", "." ]
5e4d87d0c054ff2f6510545b0e9f838338695c70
https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/wrapper/FriendGroup.java#L61-L68
train
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library
src/main/java/com/github/theholywaffle/lolchatapi/wrapper/FriendGroup.java
FriendGroup.contains
public boolean contains(Friend friend) { for (final Friend f : getFriends()) { if (StringUtils.parseName(f.getUserId()).equals( StringUtils.parseName(friend.getUserId()))) { return true; } } return false; }
java
public boolean contains(Friend friend) { for (final Friend f : getFriends()) { if (StringUtils.parseName(f.getUserId()).equals( StringUtils.parseName(friend.getUserId()))) { return true; } } return false; }
[ "public", "boolean", "contains", "(", "Friend", "friend", ")", "{", "for", "(", "final", "Friend", "f", ":", "getFriends", "(", ")", ")", "{", "if", "(", "StringUtils", ".", "parseName", "(", "f", ".", "getUserId", "(", ")", ")", ".", "equals", "(", ...
Checks if a given Friend is part of this group. @param friend The friend @return True if this group contains the friend, false otherwise.
[ "Checks", "if", "a", "given", "Friend", "is", "part", "of", "this", "group", "." ]
5e4d87d0c054ff2f6510545b0e9f838338695c70
https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/wrapper/FriendGroup.java#L77-L85
train
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library
src/main/java/com/github/theholywaffle/lolchatapi/wrapper/FriendGroup.java
FriendGroup.getFriends
public List<Friend> getFriends() { final List<Friend> friends = new ArrayList<>(); for (final RosterEntry e : get().getEntries()) { friends.add(new Friend(api, con, e)); } return friends; }
java
public List<Friend> getFriends() { final List<Friend> friends = new ArrayList<>(); for (final RosterEntry e : get().getEntries()) { friends.add(new Friend(api, con, e)); } return friends; }
[ "public", "List", "<", "Friend", ">", "getFriends", "(", ")", "{", "final", "List", "<", "Friend", ">", "friends", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "final", "RosterEntry", "e", ":", "get", "(", ")", ".", "getEntries", "(", ...
Gets a list of all Friends in this FriendGroup. @return list of all Friends in this group
[ "Gets", "a", "list", "of", "all", "Friends", "in", "this", "FriendGroup", "." ]
5e4d87d0c054ff2f6510545b0e9f838338695c70
https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/wrapper/FriendGroup.java#L92-L98
train
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library
src/main/java/com/github/theholywaffle/lolchatapi/wrapper/FriendGroup.java
FriendGroup.setName
public void setName(String name) { try { get().setName(name); } catch (final NotConnectedException e) { e.printStackTrace(); } }
java
public void setName(String name) { try { get().setName(name); } catch (final NotConnectedException e) { e.printStackTrace(); } }
[ "public", "void", "setName", "(", "String", "name", ")", "{", "try", "{", "get", "(", ")", ".", "setName", "(", "name", ")", ";", "}", "catch", "(", "final", "NotConnectedException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "...
Changes the name of this group. Case sensitive. @param name the new name of this group
[ "Changes", "the", "name", "of", "this", "group", ".", "Case", "sensitive", "." ]
5e4d87d0c054ff2f6510545b0e9f838338695c70
https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/wrapper/FriendGroup.java#L115-L121
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/delete/DeleteRequest.java
DeleteRequest.checkRequest
public static DeleteRequest checkRequest(final HttpServletRequest request, final DeleteResponse deleteResponse) { final DeleteRequestType type = checkType(request, deleteResponse); if (type != null) { return new DeleteRequest(type); } return null; }
java
public static DeleteRequest checkRequest(final HttpServletRequest request, final DeleteResponse deleteResponse) { final DeleteRequestType type = checkType(request, deleteResponse); if (type != null) { return new DeleteRequest(type); } return null; }
[ "public", "static", "DeleteRequest", "checkRequest", "(", "final", "HttpServletRequest", "request", ",", "final", "DeleteResponse", "deleteResponse", ")", "{", "final", "DeleteRequestType", "type", "=", "checkType", "(", "request", ",", "deleteResponse", ")", ";", "...
check a delete request for validity concerning NSSP @param request Tomcat servlet request @param deleteResponse delete response object @return delete request object<br> <b>null</b> if the delete request is invalid
[ "check", "a", "delete", "request", "for", "validity", "concerning", "NSSP" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/delete/DeleteRequest.java#L48-L56
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/delete/DeleteRequest.java
DeleteRequest.checkType
private static DeleteRequestType checkType( final HttpServletRequest request, final DeleteResponse deleteResponse) { { final String sType = request .getParameter(ProtocolConstants.Parameters.Delete.TYPE); if (sType != null) { if (DeleteRequestType.USER.getIdentifier().equals(sType)) { return DeleteRequestType.USER; } else if (DeleteRequestType.FOLLOW.getIdentifier().equals( sType)) { return DeleteRequestType.FOLLOW; } else if (DeleteRequestType.STATUS_UPDATE.getIdentifier() .equals(sType)) { return DeleteRequestType.STATUS_UPDATE; } else { deleteResponse.typeInvalid(sType); } } else { deleteResponse.typeMissing(); } return null; } }
java
private static DeleteRequestType checkType( final HttpServletRequest request, final DeleteResponse deleteResponse) { { final String sType = request .getParameter(ProtocolConstants.Parameters.Delete.TYPE); if (sType != null) { if (DeleteRequestType.USER.getIdentifier().equals(sType)) { return DeleteRequestType.USER; } else if (DeleteRequestType.FOLLOW.getIdentifier().equals( sType)) { return DeleteRequestType.FOLLOW; } else if (DeleteRequestType.STATUS_UPDATE.getIdentifier() .equals(sType)) { return DeleteRequestType.STATUS_UPDATE; } else { deleteResponse.typeInvalid(sType); } } else { deleteResponse.typeMissing(); } return null; } }
[ "private", "static", "DeleteRequestType", "checkType", "(", "final", "HttpServletRequest", "request", ",", "final", "DeleteResponse", "deleteResponse", ")", "{", "{", "final", "String", "sType", "=", "request", ".", "getParameter", "(", "ProtocolConstants", ".", "Pa...
check if the request contains a valid delete request type @param request Tomcat servlet request @param deleteResponse delete response object @return delete request type<br> <b>null</b> if the delete request type is invalid
[ "check", "if", "the", "request", "contains", "a", "valid", "delete", "request", "type" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/delete/DeleteRequest.java#L68-L93
train
renepickhardt/metalcon
autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Retrieve/ProcessRetrieveRequest.java
ProcessRetrieveRequest.checkRequestParameter
public static ProcessRetrieveResponse checkRequestParameter( HttpServletRequest request, ServletContext context) { ProcessRetrieveResponse response = new ProcessRetrieveResponse(context); Integer numItems = checkNumItems(request, response); String term = checkTerm(request, response); if (term == null) { return response; } SuggestTree index = checkIndexName(request, response, context); if (index == null) { response.addError(RetrieveStatusCodes.NO_INDEX_AVAILABLE); return response; } retrieveSuggestions(request, response, index, term, numItems); return response; }
java
public static ProcessRetrieveResponse checkRequestParameter( HttpServletRequest request, ServletContext context) { ProcessRetrieveResponse response = new ProcessRetrieveResponse(context); Integer numItems = checkNumItems(request, response); String term = checkTerm(request, response); if (term == null) { return response; } SuggestTree index = checkIndexName(request, response, context); if (index == null) { response.addError(RetrieveStatusCodes.NO_INDEX_AVAILABLE); return response; } retrieveSuggestions(request, response, index, term, numItems); return response; }
[ "public", "static", "ProcessRetrieveResponse", "checkRequestParameter", "(", "HttpServletRequest", "request", ",", "ServletContext", "context", ")", "{", "ProcessRetrieveResponse", "response", "=", "new", "ProcessRetrieveResponse", "(", "context", ")", ";", "Integer", "nu...
checks if the request Parameters follow the Protocol or corrects them. @param request
[ "checks", "if", "the", "request", "Parameters", "follow", "the", "Protocol", "or", "corrects", "them", "." ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Retrieve/ProcessRetrieveRequest.java#L24-L39
train
renepickhardt/metalcon
autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Retrieve/ProcessRetrieveRequest.java
ProcessRetrieveRequest.checkIndexName
private static SuggestTree checkIndexName(HttpServletRequest request, ProcessRetrieveResponse response, ServletContext context) { String indexName = request .getParameter(ProtocolConstants.INDEX_PARAMETER); SuggestTree index = null; // if no indexName Parameter was provided use the default index. if (indexName == null) { indexName = ProtocolConstants.DEFAULT_INDEX_NAME; response.addIndexWarning(RetrieveStatusCodes.NO_INDEX_GIVEN); index = ContextListener.getIndex(indexName, context); } // if an indexName Parameter was provided use this one else { index = ContextListener.getIndex(indexName, context); // if the indexName given is unknown to the server use the default. if (index == null) { indexName = ProtocolConstants.DEFAULT_INDEX_NAME; response.addIndexWarning(RetrieveStatusCodes.INDEX_UNKNOWN); index = ContextListener.getIndex(indexName, context); } } return index; }
java
private static SuggestTree checkIndexName(HttpServletRequest request, ProcessRetrieveResponse response, ServletContext context) { String indexName = request .getParameter(ProtocolConstants.INDEX_PARAMETER); SuggestTree index = null; // if no indexName Parameter was provided use the default index. if (indexName == null) { indexName = ProtocolConstants.DEFAULT_INDEX_NAME; response.addIndexWarning(RetrieveStatusCodes.NO_INDEX_GIVEN); index = ContextListener.getIndex(indexName, context); } // if an indexName Parameter was provided use this one else { index = ContextListener.getIndex(indexName, context); // if the indexName given is unknown to the server use the default. if (index == null) { indexName = ProtocolConstants.DEFAULT_INDEX_NAME; response.addIndexWarning(RetrieveStatusCodes.INDEX_UNKNOWN); index = ContextListener.getIndex(indexName, context); } } return index; }
[ "private", "static", "SuggestTree", "checkIndexName", "(", "HttpServletRequest", "request", ",", "ProcessRetrieveResponse", "response", ",", "ServletContext", "context", ")", "{", "String", "indexName", "=", "request", ".", "getParameter", "(", "ProtocolConstants", ".",...
Returns the search Index according to the indexName Parameter of the ASTP if no Parameter was in the request the default index will be used. if the parameter did not match any known index the default index will be used. returns null if the default index is requested but does not exist @param request @param response
[ "Returns", "the", "search", "Index", "according", "to", "the", "indexName", "Parameter", "of", "the", "ASTP", "if", "no", "Parameter", "was", "in", "the", "request", "the", "default", "index", "will", "be", "used", ".", "if", "the", "parameter", "did", "no...
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Retrieve/ProcessRetrieveRequest.java#L83-L105
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/statusupdates/TemplateFileInfo.java
TemplateFileInfo.createTemplateFileInfoNode
public static org.neo4j.graphdb.Node createTemplateFileInfoNode( final AbstractGraphDatabase graphDatabase, final TemplateFileInfo fileInfo) { final org.neo4j.graphdb.Node fileNode = TemplateItemInfo .createTemplateItemNode(graphDatabase, fileInfo); fileNode.setProperty(TemplateXMLFields.FILE_CONTENT_TYPE, fileInfo.getContentType()); return fileNode; }
java
public static org.neo4j.graphdb.Node createTemplateFileInfoNode( final AbstractGraphDatabase graphDatabase, final TemplateFileInfo fileInfo) { final org.neo4j.graphdb.Node fileNode = TemplateItemInfo .createTemplateItemNode(graphDatabase, fileInfo); fileNode.setProperty(TemplateXMLFields.FILE_CONTENT_TYPE, fileInfo.getContentType()); return fileNode; }
[ "public", "static", "org", ".", "neo4j", ".", "graphdb", ".", "Node", "createTemplateFileInfoNode", "(", "final", "AbstractGraphDatabase", "graphDatabase", ",", "final", "TemplateFileInfo", "fileInfo", ")", "{", "final", "org", ".", "neo4j", ".", "graphdb", ".", ...
create a database node representing a template file information @param graphDatabase neo4j database to create the node in @param fileInfo template file information to be represented by the node @return neo4j node representing the template file information passed
[ "create", "a", "database", "node", "representing", "a", "template", "file", "information" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/statusupdates/TemplateFileInfo.java#L68-L76
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/read/ReadResponse.java
ReadResponse.addActivityStream
@SuppressWarnings("unchecked") public void addActivityStream(final List<JSONObject> activities) { final JSONArray items = new JSONArray(); for (JSONObject activity : activities) { items.add(activity); } this.json.put("items", items); }
java
@SuppressWarnings("unchecked") public void addActivityStream(final List<JSONObject> activities) { final JSONArray items = new JSONArray(); for (JSONObject activity : activities) { items.add(activity); } this.json.put("items", items); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "addActivityStream", "(", "final", "List", "<", "JSONObject", ">", "activities", ")", "{", "final", "JSONArray", "items", "=", "new", "JSONArray", "(", ")", ";", "for", "(", "JSONObject", ...
add the news stream according to the Activitystrea.ms format @param activities news stream items
[ "add", "the", "news", "stream", "according", "to", "the", "Activitystrea", ".", "ms", "format" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/read/ReadResponse.java#L108-L115
train
atomix/catalyst
concurrent/src/main/java/io/atomix/catalyst/concurrent/SingleThreadContext.java
SingleThreadContext.getThread
protected static CatalystThread getThread(ExecutorService executor) { final AtomicReference<CatalystThread> thread = new AtomicReference<>(); try { executor.submit(() -> { thread.set((CatalystThread) Thread.currentThread()); }).get(); } catch (InterruptedException | ExecutionException e) { throw new IllegalStateException("failed to initialize thread state", e); } return thread.get(); }
java
protected static CatalystThread getThread(ExecutorService executor) { final AtomicReference<CatalystThread> thread = new AtomicReference<>(); try { executor.submit(() -> { thread.set((CatalystThread) Thread.currentThread()); }).get(); } catch (InterruptedException | ExecutionException e) { throw new IllegalStateException("failed to initialize thread state", e); } return thread.get(); }
[ "protected", "static", "CatalystThread", "getThread", "(", "ExecutorService", "executor", ")", "{", "final", "AtomicReference", "<", "CatalystThread", ">", "thread", "=", "new", "AtomicReference", "<>", "(", ")", ";", "try", "{", "executor", ".", "submit", "(", ...
Gets the thread from a single threaded executor service.
[ "Gets", "the", "thread", "from", "a", "single", "threaded", "executor", "service", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/concurrent/src/main/java/io/atomix/catalyst/concurrent/SingleThreadContext.java#L78-L88
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/statusupdates/TemplateFieldInfo.java
TemplateFieldInfo.createTemplateFieldInfoNode
public static org.neo4j.graphdb.Node createTemplateFieldInfoNode( final AbstractGraphDatabase graphDatabase, final TemplateFieldInfo fieldInfo) { final org.neo4j.graphdb.Node fieldNode = TemplateItemInfo .createTemplateItemNode(graphDatabase, fieldInfo); fieldNode .setProperty(TemplateXMLFields.FIELD_TYPE, fieldInfo.getType()); return fieldNode; }
java
public static org.neo4j.graphdb.Node createTemplateFieldInfoNode( final AbstractGraphDatabase graphDatabase, final TemplateFieldInfo fieldInfo) { final org.neo4j.graphdb.Node fieldNode = TemplateItemInfo .createTemplateItemNode(graphDatabase, fieldInfo); fieldNode .setProperty(TemplateXMLFields.FIELD_TYPE, fieldInfo.getType()); return fieldNode; }
[ "public", "static", "org", ".", "neo4j", ".", "graphdb", ".", "Node", "createTemplateFieldInfoNode", "(", "final", "AbstractGraphDatabase", "graphDatabase", ",", "final", "TemplateFieldInfo", "fieldInfo", ")", "{", "final", "org", ".", "neo4j", ".", "graphdb", "."...
create a database node representing a template field information @param graphDatabase neo4j database to create the node in @param fieldInfo template field information to be represented by the node @return neo4j node representing the template field information passed
[ "create", "a", "database", "node", "representing", "a", "template", "field", "information" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/statusupdates/TemplateFieldInfo.java#L69-L77
train
atomix/catalyst
buffer/src/main/java/io/atomix/catalyst/buffer/util/BitArray.java
BitArray.allocate
public static BitArray allocate(long bits) { if (!(bits > 0 & (bits & (bits - 1)) == 0)) throw new IllegalArgumentException("size must be a power of 2"); return new BitArray(UnsafeHeapBytes.allocate(Math.max(bits / 8 + 8, 8)), bits); }
java
public static BitArray allocate(long bits) { if (!(bits > 0 & (bits & (bits - 1)) == 0)) throw new IllegalArgumentException("size must be a power of 2"); return new BitArray(UnsafeHeapBytes.allocate(Math.max(bits / 8 + 8, 8)), bits); }
[ "public", "static", "BitArray", "allocate", "(", "long", "bits", ")", "{", "if", "(", "!", "(", "bits", ">", "0", "&", "(", "bits", "&", "(", "bits", "-", "1", ")", ")", "==", "0", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"size ...
Allocates a new direct bit set. @param bits The number of bits in the bit set. @return The allocated bit set.
[ "Allocates", "a", "new", "direct", "bit", "set", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/buffer/src/main/java/io/atomix/catalyst/buffer/util/BitArray.java#L38-L42
train
atomix/catalyst
buffer/src/main/java/io/atomix/catalyst/buffer/util/BitArray.java
BitArray.set
public boolean set(long index) { if (!(index < size)) throw new IndexOutOfBoundsException(); if (!get(index)) { bytes.writeLong(offset(index), bytes.readLong(offset(index)) | (1l << position(index))); count++; return true; } return false; }
java
public boolean set(long index) { if (!(index < size)) throw new IndexOutOfBoundsException(); if (!get(index)) { bytes.writeLong(offset(index), bytes.readLong(offset(index)) | (1l << position(index))); count++; return true; } return false; }
[ "public", "boolean", "set", "(", "long", "index", ")", "{", "if", "(", "!", "(", "index", "<", "size", ")", ")", "throw", "new", "IndexOutOfBoundsException", "(", ")", ";", "if", "(", "!", "get", "(", "index", ")", ")", "{", "bytes", ".", "writeLon...
Sets the bit at the given index. @param index The index of the bit to set. @return Indicates if the bit was changed.
[ "Sets", "the", "bit", "at", "the", "given", "index", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/buffer/src/main/java/io/atomix/catalyst/buffer/util/BitArray.java#L78-L87
train
atomix/catalyst
buffer/src/main/java/io/atomix/catalyst/buffer/util/BitArray.java
BitArray.get
public boolean get(long index) { if (!(index < size)) throw new IndexOutOfBoundsException(); return (bytes.readLong(offset(index)) & (1l << (position(index)))) != 0; }
java
public boolean get(long index) { if (!(index < size)) throw new IndexOutOfBoundsException(); return (bytes.readLong(offset(index)) & (1l << (position(index)))) != 0; }
[ "public", "boolean", "get", "(", "long", "index", ")", "{", "if", "(", "!", "(", "index", "<", "size", ")", ")", "throw", "new", "IndexOutOfBoundsException", "(", ")", ";", "return", "(", "bytes", ".", "readLong", "(", "offset", "(", "index", ")", ")...
Gets the bit at the given index. @param index The index of the bit to get. @return Indicates whether the bit is set.
[ "Gets", "the", "bit", "at", "the", "given", "index", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/buffer/src/main/java/io/atomix/catalyst/buffer/util/BitArray.java#L95-L99
train
atomix/catalyst
buffer/src/main/java/io/atomix/catalyst/buffer/util/BitArray.java
BitArray.resize
public BitArray resize(long size) { bytes.resize(Math.max(size / 8 + 8, 8)); this.size = size; return this; }
java
public BitArray resize(long size) { bytes.resize(Math.max(size / 8 + 8, 8)); this.size = size; return this; }
[ "public", "BitArray", "resize", "(", "long", "size", ")", "{", "bytes", ".", "resize", "(", "Math", ".", "max", "(", "size", "/", "8", "+", "8", ",", "8", ")", ")", ";", "this", ".", "size", "=", "size", ";", "return", "this", ";", "}" ]
Resizes the bit array to a new count. @param size The new count. @return The resized bit array.
[ "Resizes", "the", "bit", "array", "to", "a", "new", "count", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/buffer/src/main/java/io/atomix/catalyst/buffer/util/BitArray.java#L125-L129
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/SerializerOptions.java
SerializerOptions.allocator
BufferAllocator allocator() { Class<?> allocator = reader.getClass(ALLOCATOR, UnpooledUnsafeHeapAllocator.class); try { return (BufferAllocator) allocator.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new ConfigurationException(e); } catch (ClassCastException e) { throw new ConfigurationException("invalid allocator class: " + allocator.getName()); } }
java
BufferAllocator allocator() { Class<?> allocator = reader.getClass(ALLOCATOR, UnpooledUnsafeHeapAllocator.class); try { return (BufferAllocator) allocator.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new ConfigurationException(e); } catch (ClassCastException e) { throw new ConfigurationException("invalid allocator class: " + allocator.getName()); } }
[ "BufferAllocator", "allocator", "(", ")", "{", "Class", "<", "?", ">", "allocator", "=", "reader", ".", "getClass", "(", "ALLOCATOR", ",", "UnpooledUnsafeHeapAllocator", ".", "class", ")", ";", "try", "{", "return", "(", "BufferAllocator", ")", "allocator", ...
Returns the serializer buffer allocator. @return The serializer buffer allocator.
[ "Returns", "the", "serializer", "buffer", "allocator", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/SerializerOptions.java#L59-L68
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/SerializerOptions.java
SerializerOptions.idToInt
private int idToInt(String value) { try { return Integer.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("invalid type ID: " + value); } }
java
private int idToInt(String value) { try { return Integer.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("invalid type ID: " + value); } }
[ "private", "int", "idToInt", "(", "String", "value", ")", "{", "try", "{", "return", "Integer", ".", "valueOf", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "throw", "new", "ConfigurationException", "(", "\"invalid type ...
Converts a string to an integer.
[ "Converts", "a", "string", "to", "an", "integer", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/SerializerOptions.java#L109-L115
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/SerializerOptions.java
SerializerOptions.serializerToClass
private Class<?> serializerToClass(String value) { try { return Thread.currentThread().getContextClassLoader().loadClass(value); } catch (ClassNotFoundException e) { throw new ConfigurationException("unknown serializable type: " + value); } }
java
private Class<?> serializerToClass(String value) { try { return Thread.currentThread().getContextClassLoader().loadClass(value); } catch (ClassNotFoundException e) { throw new ConfigurationException("unknown serializable type: " + value); } }
[ "private", "Class", "<", "?", ">", "serializerToClass", "(", "String", "value", ")", "{", "try", "{", "return", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "loadClass", "(", "value", ")", ";", "}", "catch", "(",...
Converts a string to a class.
[ "Converts", "a", "string", "to", "a", "class", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/SerializerOptions.java#L120-L126
train
atomix/catalyst
local/src/main/java/io/atomix/catalyst/transport/local/LocalServer.java
LocalServer.connect
CompletableFuture<Void> connect(LocalConnection connection) { LocalConnection localConnection = new LocalConnection(listener.context, connections); connections.add(localConnection); connection.connect(localConnection); localConnection.connect(connection); return CompletableFuture.runAsync(() -> listener.listener.accept(localConnection), listener.context.executor()); }
java
CompletableFuture<Void> connect(LocalConnection connection) { LocalConnection localConnection = new LocalConnection(listener.context, connections); connections.add(localConnection); connection.connect(localConnection); localConnection.connect(connection); return CompletableFuture.runAsync(() -> listener.listener.accept(localConnection), listener.context.executor()); }
[ "CompletableFuture", "<", "Void", ">", "connect", "(", "LocalConnection", "connection", ")", "{", "LocalConnection", "localConnection", "=", "new", "LocalConnection", "(", "listener", ".", "context", ",", "connections", ")", ";", "connections", ".", "add", "(", ...
Connects to the server.
[ "Connects", "to", "the", "server", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/local/src/main/java/io/atomix/catalyst/transport/local/LocalServer.java#L53-L59
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/Serializer.java
Serializer.registerClassLoader
public Serializer registerClassLoader(String className, ClassLoader classLoader) { classLoaders.put(className, classLoader); return this; }
java
public Serializer registerClassLoader(String className, ClassLoader classLoader) { classLoaders.put(className, classLoader); return this; }
[ "public", "Serializer", "registerClassLoader", "(", "String", "className", ",", "ClassLoader", "classLoader", ")", "{", "classLoaders", ".", "put", "(", "className", ",", "classLoader", ")", ";", "return", "this", ";", "}" ]
Registers a ClassLoader for a class. @param className The class name. @param classLoader The class loader. @return The serializer instance.
[ "Registers", "a", "ClassLoader", "for", "a", "class", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/Serializer.java#L355-L358
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/Serializer.java
Serializer.writeById
@SuppressWarnings("unchecked") private BufferOutput writeById(int id, Object object, BufferOutput output, TypeSerializer serializer) { for (Identifier identifier : Identifier.values()) { if (identifier.accept(id)) { identifier.write(id, output.writeByte(identifier.code())); serializer.write(object, output, this); return output; } } throw new SerializationException("invalid type ID: " + id); }
java
@SuppressWarnings("unchecked") private BufferOutput writeById(int id, Object object, BufferOutput output, TypeSerializer serializer) { for (Identifier identifier : Identifier.values()) { if (identifier.accept(id)) { identifier.write(id, output.writeByte(identifier.code())); serializer.write(object, output, this); return output; } } throw new SerializationException("invalid type ID: " + id); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "BufferOutput", "writeById", "(", "int", "id", ",", "Object", "object", ",", "BufferOutput", "output", ",", "TypeSerializer", "serializer", ")", "{", "for", "(", "Identifier", "identifier", ":", "Ide...
Writes an object to the buffer using the given serialization ID.
[ "Writes", "an", "object", "to", "the", "buffer", "using", "the", "given", "serialization", "ID", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/Serializer.java#L883-L893
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/Serializer.java
Serializer.writeByClass
@SuppressWarnings("unchecked") private BufferOutput writeByClass(Class<?> type, Object object, BufferOutput output, TypeSerializer serializer) { if (whitelistRequired.get()) throw new SerializationException("cannot serialize unregistered type: " + type); serializer.write(object, output.writeByte(Identifier.CLASS.code()).writeUTF8(type.getName()), this); return output; }
java
@SuppressWarnings("unchecked") private BufferOutput writeByClass(Class<?> type, Object object, BufferOutput output, TypeSerializer serializer) { if (whitelistRequired.get()) throw new SerializationException("cannot serialize unregistered type: " + type); serializer.write(object, output.writeByte(Identifier.CLASS.code()).writeUTF8(type.getName()), this); return output; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "BufferOutput", "writeByClass", "(", "Class", "<", "?", ">", "type", ",", "Object", "object", ",", "BufferOutput", "output", ",", "TypeSerializer", "serializer", ")", "{", "if", "(", "whitelistRequir...
Writes an object to the buffer with its class name.
[ "Writes", "an", "object", "to", "the", "buffer", "with", "its", "class", "name", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/Serializer.java#L898-L904
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/Serializer.java
Serializer.readById
@SuppressWarnings("unchecked") private <T> T readById(int id, BufferInput<?> buffer) { Class<T> type = (Class<T>) registry.type(id); if (type == null) throw new SerializationException("cannot deserialize: unknown type"); TypeSerializer<T> serializer = getSerializer(type); if (serializer == null) throw new SerializationException("cannot deserialize: unknown type"); return serializer.read(type, buffer, this); }
java
@SuppressWarnings("unchecked") private <T> T readById(int id, BufferInput<?> buffer) { Class<T> type = (Class<T>) registry.type(id); if (type == null) throw new SerializationException("cannot deserialize: unknown type"); TypeSerializer<T> serializer = getSerializer(type); if (serializer == null) throw new SerializationException("cannot deserialize: unknown type"); return serializer.read(type, buffer, this); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "<", "T", ">", "T", "readById", "(", "int", "id", ",", "BufferInput", "<", "?", ">", "buffer", ")", "{", "Class", "<", "T", ">", "type", "=", "(", "Class", "<", "T", ">", ")", "registry...
Reads a serializable object. @param id The serializable type ID. @param buffer The buffer from which to read the object. @param <T> The object type. @return The read object.
[ "Reads", "a", "serializable", "object", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/Serializer.java#L1030-L1041
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/Serializer.java
Serializer.readByClass
@SuppressWarnings("unchecked") private <T> T readByClass(BufferInput<?> buffer) { String name = buffer.readUTF8(); if (whitelistRequired.get()) throw new SerializationException("cannot deserialize unregistered type: " + name); Class<T> type = (Class<T>) types.get(name); if (type == null) { try { type = (Class<T>) Class.forName(name); if (type == null) throw new SerializationException("cannot deserialize: unknown type"); types.put(name, type); } catch (ClassNotFoundException e) { throw new SerializationException("object class not found: " + name, e); } } TypeSerializer<T> serializer = getSerializer(type); if (serializer == null) throw new SerializationException("cannot deserialize unregistered type: " + name); return serializer.read(type, buffer, this); }
java
@SuppressWarnings("unchecked") private <T> T readByClass(BufferInput<?> buffer) { String name = buffer.readUTF8(); if (whitelistRequired.get()) throw new SerializationException("cannot deserialize unregistered type: " + name); Class<T> type = (Class<T>) types.get(name); if (type == null) { try { type = (Class<T>) Class.forName(name); if (type == null) throw new SerializationException("cannot deserialize: unknown type"); types.put(name, type); } catch (ClassNotFoundException e) { throw new SerializationException("object class not found: " + name, e); } } TypeSerializer<T> serializer = getSerializer(type); if (serializer == null) throw new SerializationException("cannot deserialize unregistered type: " + name); return serializer.read(type, buffer, this); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "<", "T", ">", "T", "readByClass", "(", "BufferInput", "<", "?", ">", "buffer", ")", "{", "String", "name", "=", "buffer", ".", "readUTF8", "(", ")", ";", "if", "(", "whitelistRequired", ".",...
Reads a writable object. @param buffer The buffer from which to read the object. @param <T> The object type. @return The read object.
[ "Reads", "a", "writable", "object", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/Serializer.java#L1050-L1073
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdateTemplate.java
StatusUpdateTemplate.createTemplateNode
public static org.neo4j.graphdb.Node createTemplateNode( final AbstractGraphDatabase graphDatabase, final StatusUpdateTemplate template) { final org.neo4j.graphdb.Node templateNode = graphDatabase.createNode(); // write template information templateNode.setProperty(Properties.Templates.IDENTIFIER, template.getName()); templateNode.setProperty(Properties.Templates.VERSION, template.getVersion()); templateNode.setProperty(Properties.Templates.CODE, template.getJavaCode()); org.neo4j.graphdb.Node itemNode; // write template field items TemplateFieldInfo fieldInfo; for (String fieldName : template.getFields().keySet()) { fieldInfo = template.getFields().get(fieldName); itemNode = TemplateFieldInfo.createTemplateFieldInfoNode( graphDatabase, fieldInfo); templateNode.createRelationshipTo(itemNode, SocialGraphRelationshipType.Templates.FIELD); } // write template file items TemplateFileInfo fileInfo; for (String fileName : template.getFiles().keySet()) { fileInfo = template.getFiles().get(fileName); itemNode = TemplateFileInfo.createTemplateFileInfoNode( graphDatabase, fileInfo); templateNode.createRelationshipTo(itemNode, SocialGraphRelationshipType.Templates.FILE); } return templateNode; }
java
public static org.neo4j.graphdb.Node createTemplateNode( final AbstractGraphDatabase graphDatabase, final StatusUpdateTemplate template) { final org.neo4j.graphdb.Node templateNode = graphDatabase.createNode(); // write template information templateNode.setProperty(Properties.Templates.IDENTIFIER, template.getName()); templateNode.setProperty(Properties.Templates.VERSION, template.getVersion()); templateNode.setProperty(Properties.Templates.CODE, template.getJavaCode()); org.neo4j.graphdb.Node itemNode; // write template field items TemplateFieldInfo fieldInfo; for (String fieldName : template.getFields().keySet()) { fieldInfo = template.getFields().get(fieldName); itemNode = TemplateFieldInfo.createTemplateFieldInfoNode( graphDatabase, fieldInfo); templateNode.createRelationshipTo(itemNode, SocialGraphRelationshipType.Templates.FIELD); } // write template file items TemplateFileInfo fileInfo; for (String fileName : template.getFiles().keySet()) { fileInfo = template.getFiles().get(fileName); itemNode = TemplateFileInfo.createTemplateFileInfoNode( graphDatabase, fileInfo); templateNode.createRelationshipTo(itemNode, SocialGraphRelationshipType.Templates.FILE); } return templateNode; }
[ "public", "static", "org", ".", "neo4j", ".", "graphdb", ".", "Node", "createTemplateNode", "(", "final", "AbstractGraphDatabase", "graphDatabase", ",", "final", "StatusUpdateTemplate", "template", ")", "{", "final", "org", ".", "neo4j", ".", "graphdb", ".", "No...
create a database node representing a status update template @param graphDatabase neo4j database to create the node in @param template status update template to be represented by the node @return neo4j node representing the status update template passed
[ "create", "a", "database", "node", "representing", "a", "status", "update", "template" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdateTemplate.java#L322-L358
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/socialgraph/SocialGraph.java
SocialGraph.createUser
public void createUser(final String userId, final String displayName, final String profilePicturePath) { final Node user = NeoUtils.createUserNode(userId); user.setProperty(Properties.User.DISPLAY_NAME, displayName); user.setProperty(Properties.User.PROFILE_PICTURE_PATH, profilePicturePath); }
java
public void createUser(final String userId, final String displayName, final String profilePicturePath) { final Node user = NeoUtils.createUserNode(userId); user.setProperty(Properties.User.DISPLAY_NAME, displayName); user.setProperty(Properties.User.PROFILE_PICTURE_PATH, profilePicturePath); }
[ "public", "void", "createUser", "(", "final", "String", "userId", ",", "final", "String", "displayName", ",", "final", "String", "profilePicturePath", ")", "{", "final", "Node", "user", "=", "NeoUtils", ".", "createUserNode", "(", "userId", ")", ";", "user", ...
create a new user @param userId user identifier @param displayName user display name @param profilePicturePath path to the profile picture of the user
[ "create", "a", "new", "user" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/SocialGraph.java#L56-L62
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/socialgraph/SocialGraph.java
SocialGraph.deleteUser
public void deleteUser(final Node user) { Node userReplica, following; for (Relationship replica : user.getRelationships( SocialGraphRelationshipType.REPLICA, Direction.INCOMING)) { userReplica = replica.getEndNode(); following = NeoUtils.getPrevSingleNode(userReplica, SocialGraphRelationshipType.FOLLOW); this.removeFriendship(following, user); } }
java
public void deleteUser(final Node user) { Node userReplica, following; for (Relationship replica : user.getRelationships( SocialGraphRelationshipType.REPLICA, Direction.INCOMING)) { userReplica = replica.getEndNode(); following = NeoUtils.getPrevSingleNode(userReplica, SocialGraphRelationshipType.FOLLOW); this.removeFriendship(following, user); } }
[ "public", "void", "deleteUser", "(", "final", "Node", "user", ")", "{", "Node", "userReplica", ",", "following", ";", "for", "(", "Relationship", "replica", ":", "user", ".", "getRelationships", "(", "SocialGraphRelationshipType", ".", "REPLICA", ",", "Direction...
delete a user removing it from all replica layers of following users @param user user that shall be deleted
[ "delete", "a", "user", "removing", "it", "from", "all", "replica", "layers", "of", "following", "users" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/SocialGraph.java#L110-L119
train
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library
src/main/java/com/github/theholywaffle/lolchatapi/LolStatus.java
LolStatus.getInt
private int getInt(XMLProperty p, int defaultValue) { final String value = get(p); if (value.isEmpty()) { return defaultValue; } return Integer.parseInt(value); }
java
private int getInt(XMLProperty p, int defaultValue) { final String value = get(p); if (value.isEmpty()) { return defaultValue; } return Integer.parseInt(value); }
[ "private", "int", "getInt", "(", "XMLProperty", "p", ",", "int", "defaultValue", ")", "{", "final", "String", "value", "=", "get", "(", "p", ")", ";", "if", "(", "value", ".", "isEmpty", "(", ")", ")", "{", "return", "defaultValue", ";", "}", "return...
If the value exists it returns its value else the default value @param p the {@link XMLProperty} @param defaultValue the fallback value @return returns the value of the given {@link XMLProperty}
[ "If", "the", "value", "exists", "it", "returns", "its", "value", "else", "the", "default", "value" ]
5e4d87d0c054ff2f6510545b0e9f838338695c70
https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolStatus.java#L264-L270
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/Worker.java
Worker.start
public void start() { this.workerThread = new Thread(this); System.out.println("starting worker thread"); this.workerThread.start(); System.out.println("worker thread started"); }
java
public void start() { this.workerThread = new Thread(this); System.out.println("starting worker thread"); this.workerThread.start(); System.out.println("worker thread started"); }
[ "public", "void", "start", "(", ")", "{", "this", ".", "workerThread", "=", "new", "Thread", "(", "this", ")", ";", "System", ".", "out", ".", "println", "(", "\"starting worker thread\"", ")", ";", "this", ".", "workerThread", ".", "start", "(", ")", ...
start the worker thread
[ "start", "the", "worker", "thread" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/Worker.java#L84-L89
train
atomix/catalyst
local/src/main/java/io/atomix/catalyst/transport/local/LocalConnection.java
LocalConnection.sendRequest
private void sendRequest(Object request, ContextualFuture future) { if (open && connection.open) { long requestId = ++this.requestId; futures.put(requestId, future); connection.handleRequest(requestId, request); } else { future.context.executor().execute(() -> future.completeExceptionally(new ConnectException("connection closed"))); } if (request instanceof ReferenceCounted) { ((ReferenceCounted<?>) request).release(); } }
java
private void sendRequest(Object request, ContextualFuture future) { if (open && connection.open) { long requestId = ++this.requestId; futures.put(requestId, future); connection.handleRequest(requestId, request); } else { future.context.executor().execute(() -> future.completeExceptionally(new ConnectException("connection closed"))); } if (request instanceof ReferenceCounted) { ((ReferenceCounted<?>) request).release(); } }
[ "private", "void", "sendRequest", "(", "Object", "request", ",", "ContextualFuture", "future", ")", "{", "if", "(", "open", "&&", "connection", ".", "open", ")", "{", "long", "requestId", "=", "++", "this", ".", "requestId", ";", "futures", ".", "put", "...
Sends a request.
[ "Sends", "a", "request", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/local/src/main/java/io/atomix/catalyst/transport/local/LocalConnection.java#L83-L95
train
atomix/catalyst
local/src/main/java/io/atomix/catalyst/transport/local/LocalConnection.java
LocalConnection.handleResponseError
private void handleResponseError(long requestId, Throwable error) { ContextualFuture future = futures.remove(requestId); if (future != null) { future.context.execute(() -> future.completeExceptionally(error)); } }
java
private void handleResponseError(long requestId, Throwable error) { ContextualFuture future = futures.remove(requestId); if (future != null) { future.context.execute(() -> future.completeExceptionally(error)); } }
[ "private", "void", "handleResponseError", "(", "long", "requestId", ",", "Throwable", "error", ")", "{", "ContextualFuture", "future", "=", "futures", ".", "remove", "(", "requestId", ")", ";", "if", "(", "future", "!=", "null", ")", "{", "future", ".", "c...
Handles a response error.
[ "Handles", "a", "response", "error", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/local/src/main/java/io/atomix/catalyst/transport/local/LocalConnection.java#L111-L116
train
atomix/catalyst
local/src/main/java/io/atomix/catalyst/transport/local/LocalConnection.java
LocalConnection.handleRequest
@SuppressWarnings("unchecked") private void handleRequest(long requestId, Object request) { HandlerHolder holder = handlers.get(request.getClass()); if (holder == null) { connection.handleResponseError(requestId, new ConnectException("no handler registered")); return; } Function<Object, CompletableFuture<Object>> handler = (Function<Object, CompletableFuture<Object>>) holder.handler; try { holder.context.executor().execute(() -> { if (open && connection.open) { CompletableFuture<Object> responseFuture = handler.apply(request); if (responseFuture != null) { responseFuture.whenComplete((response, error) -> { if (!open || !connection.open) { connection.handleResponseError(requestId, new ConnectException("connection closed")); } else if (error == null) { connection.handleResponseOk(requestId, response); } else { connection.handleResponseError(requestId, error); } }); } } else { connection.handleResponseError(requestId, new ConnectException("connection closed")); } }); } catch (RejectedExecutionException e) { connection.handleResponseError(requestId, new ConnectException("connection closed")); } }
java
@SuppressWarnings("unchecked") private void handleRequest(long requestId, Object request) { HandlerHolder holder = handlers.get(request.getClass()); if (holder == null) { connection.handleResponseError(requestId, new ConnectException("no handler registered")); return; } Function<Object, CompletableFuture<Object>> handler = (Function<Object, CompletableFuture<Object>>) holder.handler; try { holder.context.executor().execute(() -> { if (open && connection.open) { CompletableFuture<Object> responseFuture = handler.apply(request); if (responseFuture != null) { responseFuture.whenComplete((response, error) -> { if (!open || !connection.open) { connection.handleResponseError(requestId, new ConnectException("connection closed")); } else if (error == null) { connection.handleResponseOk(requestId, response); } else { connection.handleResponseError(requestId, error); } }); } } else { connection.handleResponseError(requestId, new ConnectException("connection closed")); } }); } catch (RejectedExecutionException e) { connection.handleResponseError(requestId, new ConnectException("connection closed")); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "handleRequest", "(", "long", "requestId", ",", "Object", "request", ")", "{", "HandlerHolder", "holder", "=", "handlers", ".", "get", "(", "request", ".", "getClass", "(", ")", ")", ";",...
Receives a message.
[ "Receives", "a", "message", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/local/src/main/java/io/atomix/catalyst/transport/local/LocalConnection.java#L121-L153
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java
NeoUtils.loadDatabaseConfig
private static Map<String, String> loadDatabaseConfig( final Configuration config) { // create database configuration final Map<String, String> databaseConfig = new HashMap<String, String>(); // fill database configuration databaseConfig.put("cache_type", config.getCacheType()); databaseConfig.put("use_memory_mapped_buffers", config.getUseMemoryMappedBuffers()); return databaseConfig; }
java
private static Map<String, String> loadDatabaseConfig( final Configuration config) { // create database configuration final Map<String, String> databaseConfig = new HashMap<String, String>(); // fill database configuration databaseConfig.put("cache_type", config.getCacheType()); databaseConfig.put("use_memory_mapped_buffers", config.getUseMemoryMappedBuffers()); return databaseConfig; }
[ "private", "static", "Map", "<", "String", ",", "String", ">", "loadDatabaseConfig", "(", "final", "Configuration", "config", ")", "{", "// create database configuration", "final", "Map", "<", "String", ",", "String", ">", "databaseConfig", "=", "new", "HashMap", ...
load the database configuration map for neo4j databases @param config Graphity configuration containing the configuration values @return neo4j database configuration map
[ "load", "the", "database", "configuration", "map", "for", "neo4j", "databases" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java#L57-L68
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java
NeoUtils.loadLuceneIndices
private static void loadLuceneIndices( final AbstractGraphDatabase graphDatabase) { INDEX_STATUS_UPDATE_TEMPLATES = graphDatabase.index().forNodes("tmpl"); INDEX_USERS = graphDatabase.index().forNodes("user"); INDEX_STATUS_UPDATES = graphDatabase.index().forNodes("stup"); }
java
private static void loadLuceneIndices( final AbstractGraphDatabase graphDatabase) { INDEX_STATUS_UPDATE_TEMPLATES = graphDatabase.index().forNodes("tmpl"); INDEX_USERS = graphDatabase.index().forNodes("user"); INDEX_STATUS_UPDATES = graphDatabase.index().forNodes("stup"); }
[ "private", "static", "void", "loadLuceneIndices", "(", "final", "AbstractGraphDatabase", "graphDatabase", ")", "{", "INDEX_STATUS_UPDATE_TEMPLATES", "=", "graphDatabase", ".", "index", "(", ")", ".", "forNodes", "(", "\"tmpl\"", ")", ";", "INDEX_USERS", "=", "graphD...
load the lucene indices for a database @param graphDatabase social graph database to operate on
[ "load", "the", "lucene", "indices", "for", "a", "database" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java#L76-L81
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java
NeoUtils.getSocialGraphDatabase
public static AbstractGraphDatabase getSocialGraphDatabase( final Configuration config) { // prepare neo4j graph configuration final Map<String, String> graphConfig = loadDatabaseConfig(config); // load database from path specified AbstractGraphDatabase database; if (config.getReadOnly()) { database = new EmbeddedReadOnlyGraphDatabase( config.getDatabasePath(), graphConfig); } else { database = new EmbeddedGraphDatabase(config.getDatabasePath(), graphConfig); } // load lucene indices DATABASE = database; loadLuceneIndices(database); return database; }
java
public static AbstractGraphDatabase getSocialGraphDatabase( final Configuration config) { // prepare neo4j graph configuration final Map<String, String> graphConfig = loadDatabaseConfig(config); // load database from path specified AbstractGraphDatabase database; if (config.getReadOnly()) { database = new EmbeddedReadOnlyGraphDatabase( config.getDatabasePath(), graphConfig); } else { database = new EmbeddedGraphDatabase(config.getDatabasePath(), graphConfig); } // load lucene indices DATABASE = database; loadLuceneIndices(database); return database; }
[ "public", "static", "AbstractGraphDatabase", "getSocialGraphDatabase", "(", "final", "Configuration", "config", ")", "{", "// prepare neo4j graph configuration", "final", "Map", "<", "String", ",", "String", ">", "graphConfig", "=", "loadDatabaseConfig", "(", "config", ...
open the neo4j graph database @param config Graphity configuration @return abstract graph database
[ "open", "the", "neo4j", "graph", "database" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java#L90-L110
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java
NeoUtils.deleteFile
public static boolean deleteFile(final File file) { // delete directory content recursively if (file.isDirectory()) { final File[] children = file.listFiles(); for (File child : children) { if (!deleteFile(child)) { return false; } } } // delete file/empty directory return file.delete(); }
java
public static boolean deleteFile(final File file) { // delete directory content recursively if (file.isDirectory()) { final File[] children = file.listFiles(); for (File child : children) { if (!deleteFile(child)) { return false; } } } // delete file/empty directory return file.delete(); }
[ "public", "static", "boolean", "deleteFile", "(", "final", "File", "file", ")", "{", "// delete directory content recursively", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "final", "File", "[", "]", "children", "=", "file", ".", "listFiles", "...
delete file or directory @param file file path @return true - if the file/directory has been deleted<br> false otherwise
[ "delete", "file", "or", "directory" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java#L120-L133
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java
NeoUtils.getPrevSingleNode
public static Node getPrevSingleNode(final Node user, RelationshipType relationshipType) { // find an incoming relation of the type specified final Relationship rel = user.getSingleRelationship(relationshipType, Direction.INCOMING); return (rel == null) ? (null) : (rel.getStartNode()); }
java
public static Node getPrevSingleNode(final Node user, RelationshipType relationshipType) { // find an incoming relation of the type specified final Relationship rel = user.getSingleRelationship(relationshipType, Direction.INCOMING); return (rel == null) ? (null) : (rel.getStartNode()); }
[ "public", "static", "Node", "getPrevSingleNode", "(", "final", "Node", "user", ",", "RelationshipType", "relationshipType", ")", "{", "// find an incoming relation of the type specified", "final", "Relationship", "rel", "=", "user", ".", "getSingleRelationship", "(", "rel...
find an incoming relation from the user passed of the specified type @param user destination user node @param relationshipType relationship type of the relation being searched @return source node of the relation<br> null - if there is no relation of the type specified
[ "find", "an", "incoming", "relation", "from", "the", "user", "passed", "of", "the", "specified", "type" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java#L145-L152
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java
NeoUtils.getNextSingleNode
public static Node getNextSingleNode(final Node user, RelationshipType relationshipType) { // find an outgoing relation of the type specified Relationship rel = null; try { rel = user.getSingleRelationship(relationshipType, Direction.OUTGOING); } catch (final NonWritableChannelException e) { // TODO: why is this here? Bug for read-only databases in previous // version? } return (rel == null) ? (null) : (rel.getEndNode()); }
java
public static Node getNextSingleNode(final Node user, RelationshipType relationshipType) { // find an outgoing relation of the type specified Relationship rel = null; try { rel = user.getSingleRelationship(relationshipType, Direction.OUTGOING); } catch (final NonWritableChannelException e) { // TODO: why is this here? Bug for read-only databases in previous // version? } return (rel == null) ? (null) : (rel.getEndNode()); }
[ "public", "static", "Node", "getNextSingleNode", "(", "final", "Node", "user", ",", "RelationshipType", "relationshipType", ")", "{", "// find an outgoing relation of the type specified", "Relationship", "rel", "=", "null", ";", "try", "{", "rel", "=", "user", ".", ...
find an outgoing relation from the user passed of the specified type @param user source user node @param relType relationship type of the relation being searched @return node targeted by the relation<br> null - if there is no relation of the type specified
[ "find", "an", "outgoing", "relation", "from", "the", "user", "passed", "of", "the", "specified", "type" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java#L164-L177
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java
NeoUtils.getRelationshipBetween
public static Relationship getRelationshipBetween(final Node source, final Node target, final RelationshipType relationshipType, final Direction direction) { for (Relationship relationship : source.getRelationships( relationshipType, direction)) { if (relationship.getEndNode().equals(target)) { return relationship; } } return null; }
java
public static Relationship getRelationshipBetween(final Node source, final Node target, final RelationshipType relationshipType, final Direction direction) { for (Relationship relationship : source.getRelationships( relationshipType, direction)) { if (relationship.getEndNode().equals(target)) { return relationship; } } return null; }
[ "public", "static", "Relationship", "getRelationshipBetween", "(", "final", "Node", "source", ",", "final", "Node", "target", ",", "final", "RelationshipType", "relationshipType", ",", "final", "Direction", "direction", ")", "{", "for", "(", "Relationship", "relatio...
Search for a relationship between two nodes @param source source node to loop through relationships @param target target node of the relationship @param relationshipType relationship type of the relation being searched @param direction direction of the relationship being searched @return relationship instance matching the passed arguments if existing<br> <b>null</b> - otherwise
[ "Search", "for", "a", "relationship", "between", "two", "nodes" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java#L193-L204
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java
NeoUtils.createUserNode
public static Node createUserNode(final String userId) { if (INDEX_USERS.get(IDENTIFIER, userId).getSingle() == null) { final Node user = DATABASE.createNode(); user.setProperty(Properties.User.IDENTIFIER, userId); INDEX_USERS.add(user, IDENTIFIER, userId); return user; } throw new IllegalArgumentException("user node with identifier \"" + userId + "\" already existing!"); }
java
public static Node createUserNode(final String userId) { if (INDEX_USERS.get(IDENTIFIER, userId).getSingle() == null) { final Node user = DATABASE.createNode(); user.setProperty(Properties.User.IDENTIFIER, userId); INDEX_USERS.add(user, IDENTIFIER, userId); return user; } throw new IllegalArgumentException("user node with identifier \"" + userId + "\" already existing!"); }
[ "public", "static", "Node", "createUserNode", "(", "final", "String", "userId", ")", "{", "if", "(", "INDEX_USERS", ".", "get", "(", "IDENTIFIER", ",", "userId", ")", ".", "getSingle", "(", ")", "==", "null", ")", "{", "final", "Node", "user", "=", "DA...
create a user node in the active database @param userId user identifier @return user node having its identifier stored @throws IllegalArgumentException if the identifier is already in use
[ "create", "a", "user", "node", "in", "the", "active", "database" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java#L215-L225
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java
NeoUtils.createStatusUpdateNode
public static Node createStatusUpdateNode(final String statusUpdateId) { if (INDEX_STATUS_UPDATES.get(IDENTIFIER, statusUpdateId).getSingle() == null) { final Node statusUpdate = DATABASE.createNode(); statusUpdate.setProperty(Properties.StatusUpdate.IDENTIFIER, statusUpdateId); INDEX_STATUS_UPDATES.add(statusUpdate, IDENTIFIER, statusUpdateId); return statusUpdate; } throw new IllegalArgumentException( "status update node with identifier \"" + statusUpdateId + "\" already existing!"); }
java
public static Node createStatusUpdateNode(final String statusUpdateId) { if (INDEX_STATUS_UPDATES.get(IDENTIFIER, statusUpdateId).getSingle() == null) { final Node statusUpdate = DATABASE.createNode(); statusUpdate.setProperty(Properties.StatusUpdate.IDENTIFIER, statusUpdateId); INDEX_STATUS_UPDATES.add(statusUpdate, IDENTIFIER, statusUpdateId); return statusUpdate; } throw new IllegalArgumentException( "status update node with identifier \"" + statusUpdateId + "\" already existing!"); }
[ "public", "static", "Node", "createStatusUpdateNode", "(", "final", "String", "statusUpdateId", ")", "{", "if", "(", "INDEX_STATUS_UPDATES", ".", "get", "(", "IDENTIFIER", ",", "statusUpdateId", ")", ".", "getSingle", "(", ")", "==", "null", ")", "{", "final",...
create a status update node in the active database @param statusUpdateId status update identifier @return status update node having its identifier stored @throws IllegalArgumentException if the identifier is already in use
[ "create", "a", "status", "update", "node", "in", "the", "active", "database" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java#L236-L248
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java
NeoUtils.storeStatusUpdateTemplateNode
public static void storeStatusUpdateTemplateNode( final AbstractGraphDatabase graphDatabase, final String templateId, final Node templateNode, final Node previousTemplateNode) { // remove node of the latest previous template version if (previousTemplateNode != null) { INDEX_STATUS_UPDATE_TEMPLATES.remove(previousTemplateNode, IDENTIFIER, templateId); } // add the new template node INDEX_STATUS_UPDATE_TEMPLATES.add(templateNode, IDENTIFIER, templateId); }
java
public static void storeStatusUpdateTemplateNode( final AbstractGraphDatabase graphDatabase, final String templateId, final Node templateNode, final Node previousTemplateNode) { // remove node of the latest previous template version if (previousTemplateNode != null) { INDEX_STATUS_UPDATE_TEMPLATES.remove(previousTemplateNode, IDENTIFIER, templateId); } // add the new template node INDEX_STATUS_UPDATE_TEMPLATES.add(templateNode, IDENTIFIER, templateId); }
[ "public", "static", "void", "storeStatusUpdateTemplateNode", "(", "final", "AbstractGraphDatabase", "graphDatabase", ",", "final", "String", "templateId", ",", "final", "Node", "templateNode", ",", "final", "Node", "previousTemplateNode", ")", "{", "// remove node of the ...
store a status update template node in the index replacing previous occurrences @param graphDatabase graph database to operate on @param templateId template identifier @param templateNode template node that shall be stored @param previousTemplateNode node of the latest previous template version
[ "store", "a", "status", "update", "template", "node", "in", "the", "index", "replacing", "previous", "occurrences" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/NeoUtils.java#L287-L298
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/Server.java
Server.start
public void start() { this.commandWorker.start(); while (!this.commandWorker.isRunning()) { // wait for the command worker to be ready System.out.println("waiting for worker to connect..."); try { Thread.sleep(50); } catch (final InterruptedException e) { System.out.println("server thread could not wait for worker"); e.printStackTrace(); } } }
java
public void start() { this.commandWorker.start(); while (!this.commandWorker.isRunning()) { // wait for the command worker to be ready System.out.println("waiting for worker to connect..."); try { Thread.sleep(50); } catch (final InterruptedException e) { System.out.println("server thread could not wait for worker"); e.printStackTrace(); } } }
[ "public", "void", "start", "(", ")", "{", "this", ".", "commandWorker", ".", "start", "(", ")", ";", "while", "(", "!", "this", ".", "commandWorker", ".", "isRunning", "(", ")", ")", "{", "// wait for the command worker to be ready", "System", ".", "out", ...
start the server and wait for it to be running
[ "start", "the", "server", "and", "wait", "for", "it", "to", "be", "running" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/Server.java#L92-L104
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java
NettyConnection.handleRequestFailure
private void handleRequestFailure(long requestId, Throwable error, ThreadContext context) { ByteBuf buffer = channel.alloc().buffer(10) .writeByte(RESPONSE) .writeLong(requestId) .writeByte(FAILURE); try { writeError(buffer, error, context); } catch (SerializationException e) { return; } channel.writeAndFlush(buffer, channel.voidPromise()); }
java
private void handleRequestFailure(long requestId, Throwable error, ThreadContext context) { ByteBuf buffer = channel.alloc().buffer(10) .writeByte(RESPONSE) .writeLong(requestId) .writeByte(FAILURE); try { writeError(buffer, error, context); } catch (SerializationException e) { return; } channel.writeAndFlush(buffer, channel.voidPromise()); }
[ "private", "void", "handleRequestFailure", "(", "long", "requestId", ",", "Throwable", "error", ",", "ThreadContext", "context", ")", "{", "ByteBuf", "buffer", "=", "channel", ".", "alloc", "(", ")", ".", "buffer", "(", "10", ")", ".", "writeByte", "(", "R...
Handles a request failure.
[ "Handles", "a", "request", "failure", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java#L162-L175
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java
NettyConnection.handleResponse
void handleResponse(ByteBuf response) { long requestId = response.readLong(); byte status = response.readByte(); switch (status) { case SUCCESS: try { handleResponseSuccess(requestId, readResponse(response)); } catch (SerializationException e) { handleResponseFailure(requestId, e); } break; case FAILURE: try { handleResponseFailure(requestId, readError(response)); } catch (SerializationException e) { handleResponseFailure(requestId, e); } break; } response.release(); }
java
void handleResponse(ByteBuf response) { long requestId = response.readLong(); byte status = response.readByte(); switch (status) { case SUCCESS: try { handleResponseSuccess(requestId, readResponse(response)); } catch (SerializationException e) { handleResponseFailure(requestId, e); } break; case FAILURE: try { handleResponseFailure(requestId, readError(response)); } catch (SerializationException e) { handleResponseFailure(requestId, e); } break; } response.release(); }
[ "void", "handleResponse", "(", "ByteBuf", "response", ")", "{", "long", "requestId", "=", "response", ".", "readLong", "(", ")", ";", "byte", "status", "=", "response", ".", "readByte", "(", ")", ";", "switch", "(", "status", ")", "{", "case", "SUCCESS",...
Handles response.
[ "Handles", "response", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java#L180-L200
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java
NettyConnection.handleResponseSuccess
@SuppressWarnings("unchecked") private void handleResponseSuccess(long requestId, Object response) { ContextualFuture future = responseFutures.remove(requestId); if (future != null) { future.context.executor().execute(() -> future.complete(response)); } }
java
@SuppressWarnings("unchecked") private void handleResponseSuccess(long requestId, Object response) { ContextualFuture future = responseFutures.remove(requestId); if (future != null) { future.context.executor().execute(() -> future.complete(response)); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "handleResponseSuccess", "(", "long", "requestId", ",", "Object", "response", ")", "{", "ContextualFuture", "future", "=", "responseFutures", ".", "remove", "(", "requestId", ")", ";", "if", ...
Handles a successful response.
[ "Handles", "a", "successful", "response", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java#L205-L211
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java
NettyConnection.handleResponseFailure
private void handleResponseFailure(long requestId, Throwable t) { ContextualFuture future = responseFutures.remove(requestId); if (future != null) { future.context.executor().execute(() -> future.completeExceptionally(t)); } }
java
private void handleResponseFailure(long requestId, Throwable t) { ContextualFuture future = responseFutures.remove(requestId); if (future != null) { future.context.executor().execute(() -> future.completeExceptionally(t)); } }
[ "private", "void", "handleResponseFailure", "(", "long", "requestId", ",", "Throwable", "t", ")", "{", "ContextualFuture", "future", "=", "responseFutures", ".", "remove", "(", "requestId", ")", ";", "if", "(", "future", "!=", "null", ")", "{", "future", "."...
Handles a failure response.
[ "Handles", "a", "failure", "response", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java#L216-L221
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java
NettyConnection.writeRequest
private ByteBuf writeRequest(ByteBuf buffer, Object request, ThreadContext context) { context.serializer().writeObject(request, OUTPUT.get().setByteBuf(buffer)); if (request instanceof ReferenceCounted) { ((ReferenceCounted) request).release(); } return buffer; }
java
private ByteBuf writeRequest(ByteBuf buffer, Object request, ThreadContext context) { context.serializer().writeObject(request, OUTPUT.get().setByteBuf(buffer)); if (request instanceof ReferenceCounted) { ((ReferenceCounted) request).release(); } return buffer; }
[ "private", "ByteBuf", "writeRequest", "(", "ByteBuf", "buffer", ",", "Object", "request", ",", "ThreadContext", "context", ")", "{", "context", ".", "serializer", "(", ")", ".", "writeObject", "(", "request", ",", "OUTPUT", ".", "get", "(", ")", ".", "setB...
Writes a request to the given buffer.
[ "Writes", "a", "request", "to", "the", "given", "buffer", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java#L226-L232
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java
NettyConnection.writeResponse
private ByteBuf writeResponse(ByteBuf buffer, Object request, ThreadContext context) { context.serializer().writeObject(request, OUTPUT.get().setByteBuf(buffer)); return buffer; }
java
private ByteBuf writeResponse(ByteBuf buffer, Object request, ThreadContext context) { context.serializer().writeObject(request, OUTPUT.get().setByteBuf(buffer)); return buffer; }
[ "private", "ByteBuf", "writeResponse", "(", "ByteBuf", "buffer", ",", "Object", "request", ",", "ThreadContext", "context", ")", "{", "context", ".", "serializer", "(", ")", ".", "writeObject", "(", "request", ",", "OUTPUT", ".", "get", "(", ")", ".", "set...
Writes a response to the given buffer.
[ "Writes", "a", "response", "to", "the", "given", "buffer", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java#L237-L240
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java
NettyConnection.writeError
private ByteBuf writeError(ByteBuf buffer, Throwable t, ThreadContext context) { context.serializer().writeObject(t, OUTPUT.get().setByteBuf(buffer)); return buffer; }
java
private ByteBuf writeError(ByteBuf buffer, Throwable t, ThreadContext context) { context.serializer().writeObject(t, OUTPUT.get().setByteBuf(buffer)); return buffer; }
[ "private", "ByteBuf", "writeError", "(", "ByteBuf", "buffer", ",", "Throwable", "t", ",", "ThreadContext", "context", ")", "{", "context", ".", "serializer", "(", ")", ".", "writeObject", "(", "t", ",", "OUTPUT", ".", "get", "(", ")", ".", "setByteBuf", ...
Writes an error to the given buffer.
[ "Writes", "an", "error", "to", "the", "given", "buffer", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java#L245-L248
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java
NettyConnection.readRequest
private Object readRequest(ByteBuf buffer) { return context.serializer().readObject(INPUT.get().setByteBuf(buffer)); }
java
private Object readRequest(ByteBuf buffer) { return context.serializer().readObject(INPUT.get().setByteBuf(buffer)); }
[ "private", "Object", "readRequest", "(", "ByteBuf", "buffer", ")", "{", "return", "context", ".", "serializer", "(", ")", ".", "readObject", "(", "INPUT", ".", "get", "(", ")", ".", "setByteBuf", "(", "buffer", ")", ")", ";", "}" ]
Reads a request from the given buffer.
[ "Reads", "a", "request", "from", "the", "given", "buffer", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java#L253-L255
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java
NettyConnection.readError
private Throwable readError(ByteBuf buffer) { return context.serializer().readObject(INPUT.get().setByteBuf(buffer)); }
java
private Throwable readError(ByteBuf buffer) { return context.serializer().readObject(INPUT.get().setByteBuf(buffer)); }
[ "private", "Throwable", "readError", "(", "ByteBuf", "buffer", ")", "{", "return", "context", ".", "serializer", "(", ")", ".", "readObject", "(", "INPUT", ".", "get", "(", ")", ".", "setByteBuf", "(", "buffer", ")", ")", ";", "}" ]
Reads an error from the given buffer.
[ "Reads", "an", "error", "from", "the", "given", "buffer", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java#L267-L269
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java
NettyConnection.handleException
void handleException(Throwable t) { if (failure == null) { failure = t; for (ContextualFuture<?> responseFuture : responseFutures.values()) { responseFuture.context.executor().execute(() -> responseFuture.completeExceptionally(t)); } responseFutures.clear(); for (Listener<Throwable> listener : exceptionListeners) { listener.accept(t); } } }
java
void handleException(Throwable t) { if (failure == null) { failure = t; for (ContextualFuture<?> responseFuture : responseFutures.values()) { responseFuture.context.executor().execute(() -> responseFuture.completeExceptionally(t)); } responseFutures.clear(); for (Listener<Throwable> listener : exceptionListeners) { listener.accept(t); } } }
[ "void", "handleException", "(", "Throwable", "t", ")", "{", "if", "(", "failure", "==", "null", ")", "{", "failure", "=", "t", ";", "for", "(", "ContextualFuture", "<", "?", ">", "responseFuture", ":", "responseFutures", ".", "values", "(", ")", ")", "...
Handles an exception. @param t The exception to handle.
[ "Handles", "an", "exception", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java#L276-L289
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java
NettyConnection.handleClosed
void handleClosed() { if (!closed) { closed = true; for (ContextualFuture<?> responseFuture : responseFutures.values()) { responseFuture.context.executor().execute(() -> responseFuture.completeExceptionally(new ConnectException("connection closed"))); } responseFutures.clear(); for (Listener<Connection> listener : closeListeners) { listener.accept(this); } timeout.cancel(); } }
java
void handleClosed() { if (!closed) { closed = true; for (ContextualFuture<?> responseFuture : responseFutures.values()) { responseFuture.context.executor().execute(() -> responseFuture.completeExceptionally(new ConnectException("connection closed"))); } responseFutures.clear(); for (Listener<Connection> listener : closeListeners) { listener.accept(this); } timeout.cancel(); } }
[ "void", "handleClosed", "(", ")", "{", "if", "(", "!", "closed", ")", "{", "closed", "=", "true", ";", "for", "(", "ContextualFuture", "<", "?", ">", "responseFuture", ":", "responseFutures", ".", "values", "(", ")", ")", "{", "responseFuture", ".", "c...
Handles the channel being closed.
[ "Handles", "the", "channel", "being", "closed", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java#L294-L308
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java
NettyConnection.timeout
void timeout() { long time = System.currentTimeMillis(); Iterator<Map.Entry<Long, ContextualFuture>> iterator = responseFutures.entrySet().iterator(); while (iterator.hasNext()) { ContextualFuture future = iterator.next().getValue(); if (future.time + requestTimeout < time) { iterator.remove(); future.context.executor().execute(() -> future.completeExceptionally(new TimeoutException("request timed out"))); } else { break; } } }
java
void timeout() { long time = System.currentTimeMillis(); Iterator<Map.Entry<Long, ContextualFuture>> iterator = responseFutures.entrySet().iterator(); while (iterator.hasNext()) { ContextualFuture future = iterator.next().getValue(); if (future.time + requestTimeout < time) { iterator.remove(); future.context.executor().execute(() -> future.completeExceptionally(new TimeoutException("request timed out"))); } else { break; } } }
[ "void", "timeout", "(", ")", "{", "long", "time", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "Iterator", "<", "Map", ".", "Entry", "<", "Long", ",", "ContextualFuture", ">", ">", "iterator", "=", "responseFutures", ".", "entrySet", "(", ")",...
Times out requests.
[ "Times", "out", "requests", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyConnection.java#L313-L325
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/statusupdates/TemplateItemInfo.java
TemplateItemInfo.createTemplateItemNode
protected static org.neo4j.graphdb.Node createTemplateItemNode( final AbstractGraphDatabase graphDatabase, final TemplateItemInfo itemInfo) { final org.neo4j.graphdb.Node itemNode = graphDatabase.createNode(); itemNode.setProperty(TemplateXMLFields.ITEM_NAME, itemInfo.getName()); return itemNode; }
java
protected static org.neo4j.graphdb.Node createTemplateItemNode( final AbstractGraphDatabase graphDatabase, final TemplateItemInfo itemInfo) { final org.neo4j.graphdb.Node itemNode = graphDatabase.createNode(); itemNode.setProperty(TemplateXMLFields.ITEM_NAME, itemInfo.getName()); return itemNode; }
[ "protected", "static", "org", ".", "neo4j", ".", "graphdb", ".", "Node", "createTemplateItemNode", "(", "final", "AbstractGraphDatabase", "graphDatabase", ",", "final", "TemplateItemInfo", "itemInfo", ")", "{", "final", "org", ".", "neo4j", ".", "graphdb", ".", ...
create a database node representing a template item information @param graphDatabase neo4j database to create the node in @param itemInfo template item information to be represented by the node @return neo4j node representing the template item information passed
[ "create", "a", "database", "node", "representing", "a", "template", "item", "information" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/statusupdates/TemplateItemInfo.java#L72-L78
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/create/user/CreateUserRequest.java
CreateUserRequest.checkRequest
public static CreateUserRequest checkRequest( final FormItemList formItemList, final CreateRequest createRequest, final CreateUserResponse createUserResponse) { final String userId = checkUserIdentifier(formItemList, createUserResponse); if (userId != null) { final String displayName = checkDisplayName(formItemList, createUserResponse); if (displayName != null) { final String profilePicturePath = checkProfilePicturePath( formItemList, createUserResponse); return new CreateUserRequest(createRequest.getType(), userId, displayName, profilePicturePath); } } return null; }
java
public static CreateUserRequest checkRequest( final FormItemList formItemList, final CreateRequest createRequest, final CreateUserResponse createUserResponse) { final String userId = checkUserIdentifier(formItemList, createUserResponse); if (userId != null) { final String displayName = checkDisplayName(formItemList, createUserResponse); if (displayName != null) { final String profilePicturePath = checkProfilePicturePath( formItemList, createUserResponse); return new CreateUserRequest(createRequest.getType(), userId, displayName, profilePicturePath); } } return null; }
[ "public", "static", "CreateUserRequest", "checkRequest", "(", "final", "FormItemList", "formItemList", ",", "final", "CreateRequest", "createRequest", ",", "final", "CreateUserResponse", "createUserResponse", ")", "{", "final", "String", "userId", "=", "checkUserIdentifie...
check a create user request for validity concerning NSSP @param formItemList form item list extracted @param createRequest basic create request object @param createUserResponse create user response object @return create user request object<br> <b>null</b> if the create user request is invalid
[ "check", "a", "create", "user", "request", "for", "validity", "concerning", "NSSP" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/create/user/CreateUserRequest.java#L90-L107
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/create/user/CreateUserRequest.java
CreateUserRequest.checkDisplayName
private static String checkDisplayName(final FormItemList formItemList, final CreateUserResponse createUserResponse) { final String displayName = formItemList .getField(ProtocolConstants.Parameters.Create.User.DISPLAY_NAME); if (displayName != null) { return displayName; } else { createUserResponse.displayNameMissing(); } return null; }
java
private static String checkDisplayName(final FormItemList formItemList, final CreateUserResponse createUserResponse) { final String displayName = formItemList .getField(ProtocolConstants.Parameters.Create.User.DISPLAY_NAME); if (displayName != null) { return displayName; } else { createUserResponse.displayNameMissing(); } return null; }
[ "private", "static", "String", "checkDisplayName", "(", "final", "FormItemList", "formItemList", ",", "final", "CreateUserResponse", "createUserResponse", ")", "{", "final", "String", "displayName", "=", "formItemList", ".", "getField", "(", "ProtocolConstants", ".", ...
check if the request contains a display name @param formItemList form item list extracted @param createUserResponse response object @return display name<br> <b>null</b> if there was no display name passed
[ "check", "if", "the", "request", "contains", "a", "display", "name" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/create/user/CreateUserRequest.java#L147-L158
train
renepickhardt/metalcon
graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/create/user/CreateUserRequest.java
CreateUserRequest.checkProfilePicturePath
private static String checkProfilePicturePath( final FormItemList formItemList, final CreateUserResponse createUserResponse) { final String profilePicturePath = formItemList .getField(ProtocolConstants.Parameters.Create.User.PROFILE_PICTURE_PATH); if (profilePicturePath != null) { return profilePicturePath; } else { createUserResponse.profilePicturePathMissing(); } return null; }
java
private static String checkProfilePicturePath( final FormItemList formItemList, final CreateUserResponse createUserResponse) { final String profilePicturePath = formItemList .getField(ProtocolConstants.Parameters.Create.User.PROFILE_PICTURE_PATH); if (profilePicturePath != null) { return profilePicturePath; } else { createUserResponse.profilePicturePathMissing(); } return null; }
[ "private", "static", "String", "checkProfilePicturePath", "(", "final", "FormItemList", "formItemList", ",", "final", "CreateUserResponse", "createUserResponse", ")", "{", "final", "String", "profilePicturePath", "=", "formItemList", ".", "getField", "(", "ProtocolConstan...
check if the request contains a profile picture path @param formItemList form item list extracted @param createUserResponse create user response object @return profile picture path<br> <b>null</b> if there was no profile picture path passed
[ "check", "if", "the", "request", "contains", "a", "profile", "picture", "path" ]
26a7bd89d2225fe2172dc958d10f64a1bd9cf52f
https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/create/user/CreateUserRequest.java#L170-L182
train
atomix/catalyst
concurrent/src/main/java/io/atomix/catalyst/concurrent/Listeners.java
Listeners.add
public Listener<T> add(Consumer<T> listener) { Assert.notNull(listener, "listener"); ListenerHolder holder = new ListenerHolder(listener, ThreadContext.currentContext()); listeners.add(holder); return holder; }
java
public Listener<T> add(Consumer<T> listener) { Assert.notNull(listener, "listener"); ListenerHolder holder = new ListenerHolder(listener, ThreadContext.currentContext()); listeners.add(holder); return holder; }
[ "public", "Listener", "<", "T", ">", "add", "(", "Consumer", "<", "T", ">", "listener", ")", "{", "Assert", ".", "notNull", "(", "listener", ",", "\"listener\"", ")", ";", "ListenerHolder", "holder", "=", "new", "ListenerHolder", "(", "listener", ",", "T...
Adds a listener to the set of listeners. @param listener The listener to add. @return The listener context. @throws NullPointerException if {@code listener} is null
[ "Adds", "a", "listener", "to", "the", "set", "of", "listeners", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/concurrent/src/main/java/io/atomix/catalyst/concurrent/Listeners.java#L53-L58
train
atomix/catalyst
concurrent/src/main/java/io/atomix/catalyst/concurrent/Listeners.java
Listeners.accept
public CompletableFuture<Void> accept(T event) { List<CompletableFuture<Void>> futures = new ArrayList<>(listeners.size()); for (ListenerHolder listener : listeners) { if (listener.context != null) { futures.add(listener.context.execute(() -> listener.listener.accept(event))); } else { listener.listener.accept(event); } } return CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])); }
java
public CompletableFuture<Void> accept(T event) { List<CompletableFuture<Void>> futures = new ArrayList<>(listeners.size()); for (ListenerHolder listener : listeners) { if (listener.context != null) { futures.add(listener.context.execute(() -> listener.listener.accept(event))); } else { listener.listener.accept(event); } } return CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])); }
[ "public", "CompletableFuture", "<", "Void", ">", "accept", "(", "T", "event", ")", "{", "List", "<", "CompletableFuture", "<", "Void", ">>", "futures", "=", "new", "ArrayList", "<>", "(", "listeners", ".", "size", "(", ")", ")", ";", "for", "(", "Liste...
Applies an event to all listeners. @param event The event to apply. @return A completable future to be completed once all listeners have been completed.
[ "Applies", "an", "event", "to", "all", "listeners", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/concurrent/src/main/java/io/atomix/catalyst/concurrent/Listeners.java#L66-L76
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyHandler.java
NettyHandler.getOrCreateContext
private ThreadContext getOrCreateContext(Channel channel) { ThreadContext context = ThreadContext.currentContext(); if (context != null) { return context; } return new SingleThreadContext(Thread.currentThread(), channel.eventLoop(), this.context.serializer().clone()); }
java
private ThreadContext getOrCreateContext(Channel channel) { ThreadContext context = ThreadContext.currentContext(); if (context != null) { return context; } return new SingleThreadContext(Thread.currentThread(), channel.eventLoop(), this.context.serializer().clone()); }
[ "private", "ThreadContext", "getOrCreateContext", "(", "Channel", "channel", ")", "{", "ThreadContext", "context", "=", "ThreadContext", ".", "currentContext", "(", ")", ";", "if", "(", "context", "!=", "null", ")", "{", "return", "context", ";", "}", "return"...
Returns the current execution context or creates one.
[ "Returns", "the", "current", "execution", "context", "or", "creates", "one", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyHandler.java#L83-L89
train
atomix/catalyst
netty/src/main/java/io/atomix/catalyst/transport/netty/NettyHandler.java
NettyHandler.handleResponse
private void handleResponse(ByteBuf response, ChannelHandlerContext context) { NettyConnection connection = getConnection(context.channel()); if (connection != null) { connection.handleResponse(response); } }
java
private void handleResponse(ByteBuf response, ChannelHandlerContext context) { NettyConnection connection = getConnection(context.channel()); if (connection != null) { connection.handleResponse(response); } }
[ "private", "void", "handleResponse", "(", "ByteBuf", "response", ",", "ChannelHandlerContext", "context", ")", "{", "NettyConnection", "connection", "=", "getConnection", "(", "context", ".", "channel", "(", ")", ")", ";", "if", "(", "connection", "!=", "null", ...
Handles a response.
[ "Handles", "a", "response", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyHandler.java#L128-L133
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/SerializerRegistry.java
SerializerRegistry.calculateTypeId
private int calculateTypeId(Class<?> type) { if (type == null) throw new NullPointerException("type cannot be null"); return hasher.hash32(type.getName()); }
java
private int calculateTypeId(Class<?> type) { if (type == null) throw new NullPointerException("type cannot be null"); return hasher.hash32(type.getName()); }
[ "private", "int", "calculateTypeId", "(", "Class", "<", "?", ">", "type", ")", "{", "if", "(", "type", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"type cannot be null\"", ")", ";", "return", "hasher", ".", "hash32", "(", "type", ".",...
Returns the type ID for the given class.
[ "Returns", "the", "type", "ID", "for", "the", "given", "class", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/SerializerRegistry.java#L89-L93
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/SerializerRegistry.java
SerializerRegistry.registerDefault
public SerializerRegistry registerDefault(Class<?> baseType, Class<? extends TypeSerializer> serializer) { return registerDefault(baseType, new DefaultTypeSerializerFactory(serializer)); }
java
public SerializerRegistry registerDefault(Class<?> baseType, Class<? extends TypeSerializer> serializer) { return registerDefault(baseType, new DefaultTypeSerializerFactory(serializer)); }
[ "public", "SerializerRegistry", "registerDefault", "(", "Class", "<", "?", ">", "baseType", ",", "Class", "<", "?", "extends", "TypeSerializer", ">", "serializer", ")", "{", "return", "registerDefault", "(", "baseType", ",", "new", "DefaultTypeSerializerFactory", ...
Registers the given class as a default serializer for the given base type. @param baseType The base type for which to register the serializer. @param serializer The serializer class. @return The serializer registry.
[ "Registers", "the", "given", "class", "as", "a", "default", "serializer", "for", "the", "given", "base", "type", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/SerializerRegistry.java#L257-L259
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/SerializerRegistry.java
SerializerRegistry.registerDefault
public synchronized SerializerRegistry registerDefault(Class<?> baseType, TypeSerializerFactory factory) { defaultFactories.put(baseType, factory); return this; }
java
public synchronized SerializerRegistry registerDefault(Class<?> baseType, TypeSerializerFactory factory) { defaultFactories.put(baseType, factory); return this; }
[ "public", "synchronized", "SerializerRegistry", "registerDefault", "(", "Class", "<", "?", ">", "baseType", ",", "TypeSerializerFactory", "factory", ")", "{", "defaultFactories", ".", "put", "(", "baseType", ",", "factory", ")", ";", "return", "this", ";", "}" ]
Registers the given factory as a default serializer factory for the given base type. @param baseType The base type for which to register the serializer. @param factory The serializer factory. @return The serializer registry.
[ "Registers", "the", "given", "factory", "as", "a", "default", "serializer", "factory", "for", "the", "given", "base", "type", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/SerializerRegistry.java#L268-L271
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/SerializerRegistry.java
SerializerRegistry.findBaseType
private Class<?> findBaseType(Class<?> type, Map<Class<?>, TypeSerializerFactory> factories) { if (factories.containsKey(type)) return type; List<Map.Entry<Class<?>, TypeSerializerFactory>> orderedFactories = new ArrayList<>(factories.entrySet()); Collections.reverse(orderedFactories); Optional<Map.Entry<Class<?>, TypeSerializerFactory>> optional = orderedFactories.stream() .filter(e -> e.getKey().isAssignableFrom(type)) .findFirst(); return optional.isPresent() ? optional.get().getKey() : null; }
java
private Class<?> findBaseType(Class<?> type, Map<Class<?>, TypeSerializerFactory> factories) { if (factories.containsKey(type)) return type; List<Map.Entry<Class<?>, TypeSerializerFactory>> orderedFactories = new ArrayList<>(factories.entrySet()); Collections.reverse(orderedFactories); Optional<Map.Entry<Class<?>, TypeSerializerFactory>> optional = orderedFactories.stream() .filter(e -> e.getKey().isAssignableFrom(type)) .findFirst(); return optional.isPresent() ? optional.get().getKey() : null; }
[ "private", "Class", "<", "?", ">", "findBaseType", "(", "Class", "<", "?", ">", "type", ",", "Map", "<", "Class", "<", "?", ">", ",", "TypeSerializerFactory", ">", "factories", ")", "{", "if", "(", "factories", ".", "containsKey", "(", "type", ")", "...
Finds a serializable base type for the given type in the given factories map.
[ "Finds", "a", "serializable", "base", "type", "for", "the", "given", "type", "in", "the", "given", "factories", "map", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/SerializerRegistry.java#L276-L287
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/SerializerRegistry.java
SerializerRegistry.id
synchronized int id(Class<?> type) { Integer id = ids.get(type); if (id != null) return id; // If no ID was found for the given type, determine whether the type is an abstract type. Class<?> baseType = findBaseType(type, abstractFactories); if (baseType != null) { id = ids.get(baseType); if (id != null) { return id; } } return 0; }
java
synchronized int id(Class<?> type) { Integer id = ids.get(type); if (id != null) return id; // If no ID was found for the given type, determine whether the type is an abstract type. Class<?> baseType = findBaseType(type, abstractFactories); if (baseType != null) { id = ids.get(baseType); if (id != null) { return id; } } return 0; }
[ "synchronized", "int", "id", "(", "Class", "<", "?", ">", "type", ")", "{", "Integer", "id", "=", "ids", ".", "get", "(", "type", ")", ";", "if", "(", "id", "!=", "null", ")", "return", "id", ";", "// If no ID was found for the given type, determine whethe...
Looks up the serializable type ID for the given type.
[ "Looks", "up", "the", "serializable", "type", "ID", "for", "the", "given", "type", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/SerializerRegistry.java#L320-L334
train
atomix/catalyst
serializer/src/main/java/io/atomix/catalyst/serializer/util/CatalystSerializableSerializer.java
CatalystSerializableSerializer.readReference
@SuppressWarnings("unchecked") private T readReference(Class<T> type, BufferInput<?> buffer, Serializer serializer) { ReferencePool<?> pool = pools.get(type); if (pool == null) { Constructor<?> constructor = constructorMap.get(type); if (constructor == null) { try { constructor = type.getDeclaredConstructor(ReferenceManager.class); constructor.setAccessible(true); constructorMap.put(type, constructor); } catch (NoSuchMethodException e) { throw new SerializationException("failed to instantiate reference: must provide a single argument constructor", e); } } pool = new ReferencePool<>(createFactory(constructor)); pools.put(type, pool); } T object = (T) pool.acquire(); object.readObject(buffer, serializer); return object; }
java
@SuppressWarnings("unchecked") private T readReference(Class<T> type, BufferInput<?> buffer, Serializer serializer) { ReferencePool<?> pool = pools.get(type); if (pool == null) { Constructor<?> constructor = constructorMap.get(type); if (constructor == null) { try { constructor = type.getDeclaredConstructor(ReferenceManager.class); constructor.setAccessible(true); constructorMap.put(type, constructor); } catch (NoSuchMethodException e) { throw new SerializationException("failed to instantiate reference: must provide a single argument constructor", e); } } pool = new ReferencePool<>(createFactory(constructor)); pools.put(type, pool); } T object = (T) pool.acquire(); object.readObject(buffer, serializer); return object; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "T", "readReference", "(", "Class", "<", "T", ">", "type", ",", "BufferInput", "<", "?", ">", "buffer", ",", "Serializer", "serializer", ")", "{", "ReferencePool", "<", "?", ">", "pool", "=", ...
Reads an object reference. @param type The reference type. @param buffer The reference buffer. @param serializer The serializer with which the object is being read. @return The reference to read.
[ "Reads", "an", "object", "reference", "." ]
140e762cb975cd8ee1fd85119043c5b8bf917c5c
https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/util/CatalystSerializableSerializer.java#L71-L92
train