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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
atomix/catalyst | serializer/src/main/java/io/atomix/catalyst/serializer/util/CatalystSerializableSerializer.java | CatalystSerializableSerializer.createFactory | private ReferenceFactory<?> createFactory(final Constructor<?> constructor) {
return manager -> {
try {
return (ReferenceCounted<?>) constructor.newInstance(manager);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new SerializationException("failed to instantiate reference", e);
}
};
} | java | private ReferenceFactory<?> createFactory(final Constructor<?> constructor) {
return manager -> {
try {
return (ReferenceCounted<?>) constructor.newInstance(manager);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new SerializationException("failed to instantiate reference", e);
}
};
} | [
"private",
"ReferenceFactory",
"<",
"?",
">",
"createFactory",
"(",
"final",
"Constructor",
"<",
"?",
">",
"constructor",
")",
"{",
"return",
"manager",
"->",
"{",
"try",
"{",
"return",
"(",
"ReferenceCounted",
"<",
"?",
">",
")",
"constructor",
".",
"newI... | Dynamically created a reference factory for a pooled type. | [
"Dynamically",
"created",
"a",
"reference",
"factory",
"for",
"a",
"pooled",
"type",
"."
] | 140e762cb975cd8ee1fd85119043c5b8bf917c5c | https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/util/CatalystSerializableSerializer.java#L97-L105 | train |
atomix/catalyst | serializer/src/main/java/io/atomix/catalyst/serializer/util/CatalystSerializableSerializer.java | CatalystSerializableSerializer.readObject | @SuppressWarnings("unchecked")
private T readObject(Class<T> type, BufferInput<?> buffer, Serializer serializer) {
try {
Constructor<?> constructor = constructorMap.get(type);
if (constructor == null) {
try {
constructor = type.getDeclaredConstructor();
constructor.setAccessible(true);
constructorMap.put(type, constructor);
} catch (NoSuchMethodException e) {
throw new SerializationException("failed to instantiate reference: must provide a single argument constructor", e);
}
}
T object = (T) constructor.newInstance();
object.readObject(buffer, serializer);
return object;
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new SerializationException("failed to instantiate object: must provide a no argument constructor", e);
}
} | java | @SuppressWarnings("unchecked")
private T readObject(Class<T> type, BufferInput<?> buffer, Serializer serializer) {
try {
Constructor<?> constructor = constructorMap.get(type);
if (constructor == null) {
try {
constructor = type.getDeclaredConstructor();
constructor.setAccessible(true);
constructorMap.put(type, constructor);
} catch (NoSuchMethodException e) {
throw new SerializationException("failed to instantiate reference: must provide a single argument constructor", e);
}
}
T object = (T) constructor.newInstance();
object.readObject(buffer, serializer);
return object;
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new SerializationException("failed to instantiate object: must provide a no argument constructor", e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"T",
"readObject",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"BufferInput",
"<",
"?",
">",
"buffer",
",",
"Serializer",
"serializer",
")",
"{",
"try",
"{",
"Constructor",
"<",
"?",
">",
"cons... | Reads an object.
@param type The object type.
@param buffer The object buffer.
@param serializer The serializer with which the object is being read.
@return The object. | [
"Reads",
"an",
"object",
"."
] | 140e762cb975cd8ee1fd85119043c5b8bf917c5c | https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/serializer/src/main/java/io/atomix/catalyst/serializer/util/CatalystSerializableSerializer.java#L115-L135 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdateManager.java | StatusUpdateManager.loadXmlFiles | private static File[] loadXmlFiles(final File directory) {
return directory.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return file.getName().endsWith(".xml");
}
});
} | java | private static File[] loadXmlFiles(final File directory) {
return directory.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return file.getName().endsWith(".xml");
}
});
} | [
"private",
"static",
"File",
"[",
"]",
"loadXmlFiles",
"(",
"final",
"File",
"directory",
")",
"{",
"return",
"directory",
".",
"listFiles",
"(",
"new",
"FileFilter",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"accept",
"(",
"File",
"file",
")",
... | load all XML files listed in the directory specified
@param directory
status update templates directory
@return array of status update templates (XML files) | [
"load",
"all",
"XML",
"files",
"listed",
"in",
"the",
"directory",
"specified"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdateManager.java#L53-L62 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdateManager.java | StatusUpdateManager.generateJavaFiles | private static void generateJavaFiles(final StatusUpdateTemplate template,
final String workingPath) throws FileNotFoundException {
final String javaPath = WORKING_DIR + template.getName() + ".java";
final File javaFile = new File(javaPath);
final String[] optionsAndSources = { "-classpath", workingPath,
"-proc:none", "-source", "1.7", "-target", "1.7", javaPath };
// write java file
final PrintWriter writer = new PrintWriter(javaFile);
writer.write(template.getJavaCode());
writer.flush();
writer.close();
// delete previous class file
final File classFile = new File(WORKING_DIR + template.getName()
+ ".class");
classFile.delete();
// compile java file to class file
final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
compiler.run(System.in, System.out, System.err, optionsAndSources);
// delete java file
javaFile.delete();
} | java | private static void generateJavaFiles(final StatusUpdateTemplate template,
final String workingPath) throws FileNotFoundException {
final String javaPath = WORKING_DIR + template.getName() + ".java";
final File javaFile = new File(javaPath);
final String[] optionsAndSources = { "-classpath", workingPath,
"-proc:none", "-source", "1.7", "-target", "1.7", javaPath };
// write java file
final PrintWriter writer = new PrintWriter(javaFile);
writer.write(template.getJavaCode());
writer.flush();
writer.close();
// delete previous class file
final File classFile = new File(WORKING_DIR + template.getName()
+ ".class");
classFile.delete();
// compile java file to class file
final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
compiler.run(System.in, System.out, System.err, optionsAndSources);
// delete java file
javaFile.delete();
} | [
"private",
"static",
"void",
"generateJavaFiles",
"(",
"final",
"StatusUpdateTemplate",
"template",
",",
"final",
"String",
"workingPath",
")",
"throws",
"FileNotFoundException",
"{",
"final",
"String",
"javaPath",
"=",
"WORKING_DIR",
"+",
"template",
".",
"getName",
... | generate a java class file for the template specified
@param template
status update template
@param workingPath
working path including JAVA and/or CLASS-files
@throws FileNotFoundException | [
"generate",
"a",
"java",
"class",
"file",
"for",
"the",
"template",
"specified"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdateManager.java#L73-L97 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdateManager.java | StatusUpdateManager.storeStatusUpdateTemplate | private static void storeStatusUpdateTemplate(
final AbstractGraphDatabase graphDatabase,
final StatusUpdateTemplate template, final Node previousTemplateNode) {
final Transaction transaction = graphDatabase.beginTx();
try {
// create template node
final Node templateNode = StatusUpdateTemplate.createTemplateNode(
graphDatabase, template);
// link to the latest previous version
if (previousTemplateNode != null) {
templateNode.createRelationshipTo(previousTemplateNode,
SocialGraphRelationshipType.Templates.PREVIOUS);
}
// store the template node
NeoUtils.storeStatusUpdateTemplateNode(graphDatabase,
template.getName(), templateNode, previousTemplateNode);
transaction.success();
} finally {
transaction.finish();
}
} | java | private static void storeStatusUpdateTemplate(
final AbstractGraphDatabase graphDatabase,
final StatusUpdateTemplate template, final Node previousTemplateNode) {
final Transaction transaction = graphDatabase.beginTx();
try {
// create template node
final Node templateNode = StatusUpdateTemplate.createTemplateNode(
graphDatabase, template);
// link to the latest previous version
if (previousTemplateNode != null) {
templateNode.createRelationshipTo(previousTemplateNode,
SocialGraphRelationshipType.Templates.PREVIOUS);
}
// store the template node
NeoUtils.storeStatusUpdateTemplateNode(graphDatabase,
template.getName(), templateNode, previousTemplateNode);
transaction.success();
} finally {
transaction.finish();
}
} | [
"private",
"static",
"void",
"storeStatusUpdateTemplate",
"(",
"final",
"AbstractGraphDatabase",
"graphDatabase",
",",
"final",
"StatusUpdateTemplate",
"template",
",",
"final",
"Node",
"previousTemplateNode",
")",
"{",
"final",
"Transaction",
"transaction",
"=",
"graphDa... | store the status update template linking to the latest previous version
@param graphDatabase
social graph database to store the template in
@param template
status update template
@param previousTemplateNode
template node of the latest previous version | [
"store",
"the",
"status",
"update",
"template",
"linking",
"to",
"the",
"latest",
"previous",
"version"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdateManager.java#L109-L132 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdateManager.java | StatusUpdateManager.loadStatusUpdateTemplates | public static void loadStatusUpdateTemplates(final String rootDir,
final Configuration config,
final AbstractGraphDatabase graphDatabase)
throws ParserConfigurationException, SAXException, IOException {
// set working directory
final String workingPath = rootDir + "classes/";
final String targetPackage = StatusUpdate.class.getPackage().getName()
+ ".templates.";
WORKING_DIR = workingPath + targetPackage.replace(".", "/");
final File dirWorking = new File(WORKING_DIR);
if (!dirWorking.exists()) {
dirWorking.mkdir();
}
System.out.println("WORKING_DIR:" + WORKING_DIR);
// create class loader
final ClassLoader classLoader = StatusUpdate.class.getClassLoader();
final URLClassLoader loader = new URLClassLoader(new URL[] { new File(
workingPath).toURI().toURL() }, classLoader);
// crawl XML files
StatusUpdateTemplate template, previousTemplate;
final File templatesDir = new File(config.getTemplatesPath());
if (!templatesDir.exists()) {
templatesDir.mkdir();
}
File[] xmlFiles = loadXmlFiles(templatesDir);
// create basic status update template
if (xmlFiles.length == 0) {
final File plainTemplate = new File(config.getTemplatesPath()
+ "Plain.xml");
final PrintWriter writer = new PrintWriter(plainTemplate);
writer.println("<class name=\"Plain\" version=\"1.0\">");
writer.println("<param name=\"message\" type=\"String\" />");
writer.println("</class>");
writer.flush();
writer.close();
xmlFiles = loadXmlFiles(new File(config.getTemplatesPath()));
}
System.out.println("TEMPLATES:" + xmlFiles.length);
for (File xmlFile : xmlFiles) {
template = new StatusUpdateTemplate(xmlFile);
final Node previousTemplateNode = NeoUtils
.getStatusUpdateTemplateByIdentifier(template.getName());
if (previousTemplateNode != null) {
previousTemplate = new StatusUpdateTemplate(
previousTemplateNode);
} else {
previousTemplate = null;
}
// check for previous template versions
if (previousTemplate != null) {
if (!template.getVersion()
.equals(previousTemplate.getVersion())) {
// TODO: ask which template shall be used, for the moment
// overwrite previous versions
}
}
// store the new template
storeStatusUpdateTemplate(graphDatabase, template,
previousTemplateNode);
// generate class file
generateJavaFiles(template, workingPath);
// register the new template
try {
template.setInstantiationClass(loader.loadClass(targetPackage
+ template.getName()));
STATUS_UPDATE_TYPES.put(template.getName(), template);
} catch (final ClassNotFoundException e) {
e.printStackTrace();
}
}
loader.close();
} | java | public static void loadStatusUpdateTemplates(final String rootDir,
final Configuration config,
final AbstractGraphDatabase graphDatabase)
throws ParserConfigurationException, SAXException, IOException {
// set working directory
final String workingPath = rootDir + "classes/";
final String targetPackage = StatusUpdate.class.getPackage().getName()
+ ".templates.";
WORKING_DIR = workingPath + targetPackage.replace(".", "/");
final File dirWorking = new File(WORKING_DIR);
if (!dirWorking.exists()) {
dirWorking.mkdir();
}
System.out.println("WORKING_DIR:" + WORKING_DIR);
// create class loader
final ClassLoader classLoader = StatusUpdate.class.getClassLoader();
final URLClassLoader loader = new URLClassLoader(new URL[] { new File(
workingPath).toURI().toURL() }, classLoader);
// crawl XML files
StatusUpdateTemplate template, previousTemplate;
final File templatesDir = new File(config.getTemplatesPath());
if (!templatesDir.exists()) {
templatesDir.mkdir();
}
File[] xmlFiles = loadXmlFiles(templatesDir);
// create basic status update template
if (xmlFiles.length == 0) {
final File plainTemplate = new File(config.getTemplatesPath()
+ "Plain.xml");
final PrintWriter writer = new PrintWriter(plainTemplate);
writer.println("<class name=\"Plain\" version=\"1.0\">");
writer.println("<param name=\"message\" type=\"String\" />");
writer.println("</class>");
writer.flush();
writer.close();
xmlFiles = loadXmlFiles(new File(config.getTemplatesPath()));
}
System.out.println("TEMPLATES:" + xmlFiles.length);
for (File xmlFile : xmlFiles) {
template = new StatusUpdateTemplate(xmlFile);
final Node previousTemplateNode = NeoUtils
.getStatusUpdateTemplateByIdentifier(template.getName());
if (previousTemplateNode != null) {
previousTemplate = new StatusUpdateTemplate(
previousTemplateNode);
} else {
previousTemplate = null;
}
// check for previous template versions
if (previousTemplate != null) {
if (!template.getVersion()
.equals(previousTemplate.getVersion())) {
// TODO: ask which template shall be used, for the moment
// overwrite previous versions
}
}
// store the new template
storeStatusUpdateTemplate(graphDatabase, template,
previousTemplateNode);
// generate class file
generateJavaFiles(template, workingPath);
// register the new template
try {
template.setInstantiationClass(loader.loadClass(targetPackage
+ template.getName()));
STATUS_UPDATE_TYPES.put(template.getName(), template);
} catch (final ClassNotFoundException e) {
e.printStackTrace();
}
}
loader.close();
} | [
"public",
"static",
"void",
"loadStatusUpdateTemplates",
"(",
"final",
"String",
"rootDir",
",",
"final",
"Configuration",
"config",
",",
"final",
"AbstractGraphDatabase",
"graphDatabase",
")",
"throws",
"ParserConfigurationException",
",",
"SAXException",
",",
"IOExcepti... | load the status update allowed
@param rootDir
classes directory parent
@param config
Graphity configuration
@param graphDatabase
graph database to store status update version control
@throws IOException
- IO error
@throws SAXException
- parse error
@throws ParserConfigurationException
- DocumentBuilder cannot match the current configuration | [
"load",
"the",
"status",
"update",
"allowed"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdateManager.java#L150-L231 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdateManager.java | StatusUpdateManager.instantiateStatusUpdate | public static StatusUpdate instantiateStatusUpdate(
final String typeIdentifier, final FormItemList values)
throws StatusUpdateInstantiationFailedException {
final StatusUpdateTemplate template = getStatusUpdateTemplate(typeIdentifier);
final Class<?> templateInstantiationClass = template
.getInstantiationClass();
try {
// instantiate status update
final StatusUpdate statusUpdate = (StatusUpdate) templateInstantiationClass
.newInstance();
// set status update fields
String value;
try {
for (String fieldName : template.getFields().keySet()) {
try {
value = values.getField(fieldName);
} catch (final IllegalArgumentException e) {
throw new StatusUpdateInstantiationFailedException(
e.getMessage());
}
templateInstantiationClass.getField(fieldName).set(
statusUpdate, value);
}
// set status update file paths
for (String fileName : template.getFiles().keySet()) {
try {
value = values.getFile(fileName).getAbsoluteFilePath();
} catch (final IllegalArgumentException e) {
throw new StatusUpdateInstantiationFailedException(
e.getMessage());
}
templateInstantiationClass.getField(fileName).set(
statusUpdate, value);
}
} catch (final IllegalArgumentException e) {
throw new StatusUpdateInstantiationFailedException(
"The types of the parameters passed do not match the status update template.");
}
return statusUpdate;
} catch (final SecurityException e) {
throw new IllegalArgumentException(
"failed to load the status update type specified, SecurityException occurred!");
} catch (final InstantiationException e) {
throw new IllegalArgumentException(
"failed to load the status update type specified, InstantiationException occurred!");
} catch (final IllegalAccessException e) {
throw new IllegalArgumentException(
"failed to load the status update type specified, IllegalAccessException occurred!");
} catch (final NoSuchFieldException e) {
throw new IllegalArgumentException(
"failed to load the status update type specified, NoSuchFieldException occurred!");
}
} | java | public static StatusUpdate instantiateStatusUpdate(
final String typeIdentifier, final FormItemList values)
throws StatusUpdateInstantiationFailedException {
final StatusUpdateTemplate template = getStatusUpdateTemplate(typeIdentifier);
final Class<?> templateInstantiationClass = template
.getInstantiationClass();
try {
// instantiate status update
final StatusUpdate statusUpdate = (StatusUpdate) templateInstantiationClass
.newInstance();
// set status update fields
String value;
try {
for (String fieldName : template.getFields().keySet()) {
try {
value = values.getField(fieldName);
} catch (final IllegalArgumentException e) {
throw new StatusUpdateInstantiationFailedException(
e.getMessage());
}
templateInstantiationClass.getField(fieldName).set(
statusUpdate, value);
}
// set status update file paths
for (String fileName : template.getFiles().keySet()) {
try {
value = values.getFile(fileName).getAbsoluteFilePath();
} catch (final IllegalArgumentException e) {
throw new StatusUpdateInstantiationFailedException(
e.getMessage());
}
templateInstantiationClass.getField(fileName).set(
statusUpdate, value);
}
} catch (final IllegalArgumentException e) {
throw new StatusUpdateInstantiationFailedException(
"The types of the parameters passed do not match the status update template.");
}
return statusUpdate;
} catch (final SecurityException e) {
throw new IllegalArgumentException(
"failed to load the status update type specified, SecurityException occurred!");
} catch (final InstantiationException e) {
throw new IllegalArgumentException(
"failed to load the status update type specified, InstantiationException occurred!");
} catch (final IllegalAccessException e) {
throw new IllegalArgumentException(
"failed to load the status update type specified, IllegalAccessException occurred!");
} catch (final NoSuchFieldException e) {
throw new IllegalArgumentException(
"failed to load the status update type specified, NoSuchFieldException occurred!");
}
} | [
"public",
"static",
"StatusUpdate",
"instantiateStatusUpdate",
"(",
"final",
"String",
"typeIdentifier",
",",
"final",
"FormItemList",
"values",
")",
"throws",
"StatusUpdateInstantiationFailedException",
"{",
"final",
"StatusUpdateTemplate",
"template",
"=",
"getStatusUpdateT... | instantiate a status update
@param typeIdentifier
status update type identifier
@param values
form item list containing all status update items necessary
@return status update instance of type specified
@throws StatusUpdateInstantiationFailedException
if the status update could not be instantiated with the
parameters passed
@throws IllegalArgumentException
if template internal errors occur | [
"instantiate",
"a",
"status",
"update"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/statusupdates/StatusUpdateManager.java#L260-L316 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/delete/user/DeleteUserRequest.java | DeleteUserRequest.checkRequest | public static DeleteUserRequest checkRequest(
final HttpServletRequest request,
final DeleteRequest deleteRequest,
final DeleteUserResponse deleteUserResponse) {
final Node user = checkUserIdentifier(request, deleteUserResponse);
if (user != null) {
return new DeleteUserRequest(deleteRequest.getType(), user);
}
return null;
} | java | public static DeleteUserRequest checkRequest(
final HttpServletRequest request,
final DeleteRequest deleteRequest,
final DeleteUserResponse deleteUserResponse) {
final Node user = checkUserIdentifier(request, deleteUserResponse);
if (user != null) {
return new DeleteUserRequest(deleteRequest.getType(), user);
}
return null;
} | [
"public",
"static",
"DeleteUserRequest",
"checkRequest",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"DeleteRequest",
"deleteRequest",
",",
"final",
"DeleteUserResponse",
"deleteUserResponse",
")",
"{",
"final",
"Node",
"user",
"=",
"checkUserIdentifier",... | check a delete user request for validity concerning NSSP
@param request
Tomcat servlet request
@param deleteRequest
basic delete request object
@param deleteUserResponse
delete user response object
@return delete user request object<br>
<b>null</b> if the delete user request is invalid | [
"check",
"a",
"delete",
"user",
"request",
"for",
"validity",
"concerning",
"NSSP"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/delete/user/DeleteUserRequest.java#L58-L68 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.addFriendById | public void addFriendById(String userId, String name,
FriendGroup friendGroup) {
if (name == null && getRiotApi() != null) {
try {
name = getRiotApi().getName(userId);
} catch (final IOException e) {
e.printStackTrace();
}
}
try {
connection
.getRoster()
.createEntry(
StringUtils.parseBareAddress(userId),
name,
new String[] { friendGroup == null ? getDefaultFriendGroup()
.getName() : friendGroup.getName() });
} catch (NotLoggedInException | NoResponseException
| XMPPErrorException | NotConnectedException e) {
e.printStackTrace();
}
} | java | public void addFriendById(String userId, String name,
FriendGroup friendGroup) {
if (name == null && getRiotApi() != null) {
try {
name = getRiotApi().getName(userId);
} catch (final IOException e) {
e.printStackTrace();
}
}
try {
connection
.getRoster()
.createEntry(
StringUtils.parseBareAddress(userId),
name,
new String[] { friendGroup == null ? getDefaultFriendGroup()
.getName() : friendGroup.getName() });
} catch (NotLoggedInException | NoResponseException
| XMPPErrorException | NotConnectedException e) {
e.printStackTrace();
}
} | [
"public",
"void",
"addFriendById",
"(",
"String",
"userId",
",",
"String",
"name",
",",
"FriendGroup",
"friendGroup",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"&&",
"getRiotApi",
"(",
")",
"!=",
"null",
")",
"{",
"try",
"{",
"name",
"=",
"getRiotApi",
... | Sends an friend request to an other user.
@param userId
The userId of the user you want to add (e.g.
sum12345678@pvp.net).
@param name
The name you want to assign to this user.
@param friendGroup
The FriendGroup you want to put this user in. | [
"Sends",
"an",
"friend",
"request",
"to",
"an",
"other",
"user",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L221-L242 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.addFriendByName | public boolean addFriendByName(String name, FriendGroup friendGroup) {
if (getRiotApi() != null) {
try {
final StringBuilder buf = new StringBuilder();
buf.append("sum");
buf.append(getRiotApi().getSummonerId(name));
buf.append("@pvp.net");
addFriendById(buf.toString(), name, friendGroup);
return true;
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
return false;
}
}
return false;
} | java | public boolean addFriendByName(String name, FriendGroup friendGroup) {
if (getRiotApi() != null) {
try {
final StringBuilder buf = new StringBuilder();
buf.append("sum");
buf.append(getRiotApi().getSummonerId(name));
buf.append("@pvp.net");
addFriendById(buf.toString(), name, friendGroup);
return true;
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
return false;
}
}
return false;
} | [
"public",
"boolean",
"addFriendByName",
"(",
"String",
"name",
",",
"FriendGroup",
"friendGroup",
")",
"{",
"if",
"(",
"getRiotApi",
"(",
")",
"!=",
"null",
")",
"{",
"try",
"{",
"final",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
... | Sends an friend request to an other user. An Riot API key is required for
this.
@param name
The name of the Friend you want to add (case insensitive)
@param friendGroup
The FriendGroup you want to put this user in.
@return True if succesful otherwise false. | [
"Sends",
"an",
"friend",
"request",
"to",
"an",
"other",
"user",
".",
"An",
"Riot",
"API",
"key",
"is",
"required",
"for",
"this",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L266-L281 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.addFriendGroup | public FriendGroup addFriendGroup(String name) {
final RosterGroup g = connection.getRoster().createGroup(name);
if (g != null) {
return new FriendGroup(this, connection, g);
}
return null;
} | java | public FriendGroup addFriendGroup(String name) {
final RosterGroup g = connection.getRoster().createGroup(name);
if (g != null) {
return new FriendGroup(this, connection, g);
}
return null;
} | [
"public",
"FriendGroup",
"addFriendGroup",
"(",
"String",
"name",
")",
"{",
"final",
"RosterGroup",
"g",
"=",
"connection",
".",
"getRoster",
"(",
")",
".",
"createGroup",
"(",
"name",
")",
";",
"if",
"(",
"g",
"!=",
"null",
")",
"{",
"return",
"new",
... | Creates a new FriendGroup. If this FriendGroup contains no Friends when
you logout it will be erased from the server.
@param name
The name of this FriendGroup
@return The new FriendGroup or null if a FriendGroup with this name
already exists. | [
"Creates",
"a",
"new",
"FriendGroup",
".",
"If",
"this",
"FriendGroup",
"contains",
"no",
"Friends",
"when",
"you",
"logout",
"it",
"will",
"be",
"erased",
"from",
"the",
"server",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L292-L298 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.disconnect | public void disconnect() {
connection.getRoster().removeRosterListener(leagueRosterListener);
try {
connection.disconnect();
} catch (final NotConnectedException e) {
e.printStackTrace();
}
stop = true;
} | java | public void disconnect() {
connection.getRoster().removeRosterListener(leagueRosterListener);
try {
connection.disconnect();
} catch (final NotConnectedException e) {
e.printStackTrace();
}
stop = true;
} | [
"public",
"void",
"disconnect",
"(",
")",
"{",
"connection",
".",
"getRoster",
"(",
")",
".",
"removeRosterListener",
"(",
"leagueRosterListener",
")",
";",
"try",
"{",
"connection",
".",
"disconnect",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"NotConnected... | Disconnects from chatserver and releases all resources. | [
"Disconnects",
"from",
"chatserver",
"and",
"releases",
"all",
"resources",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L404-L412 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.getFriend | public Friend getFriend(Filter<Friend> filter) {
for (final RosterEntry e : connection.getRoster().getEntries()) {
final Friend f = new Friend(this, connection, e);
if (filter.accept(f)) {
return f;
}
}
return null;
} | java | public Friend getFriend(Filter<Friend> filter) {
for (final RosterEntry e : connection.getRoster().getEntries()) {
final Friend f = new Friend(this, connection, e);
if (filter.accept(f)) {
return f;
}
}
return null;
} | [
"public",
"Friend",
"getFriend",
"(",
"Filter",
"<",
"Friend",
">",
"filter",
")",
"{",
"for",
"(",
"final",
"RosterEntry",
"e",
":",
"connection",
".",
"getRoster",
"(",
")",
".",
"getEntries",
"(",
")",
")",
"{",
"final",
"Friend",
"f",
"=",
"new",
... | Gets a friend based on a given filter.
@param filter
The filter defines conditions that your Friend must meet.
@return The first Friend that meets the conditions or null if not found. | [
"Gets",
"a",
"friend",
"based",
"on",
"a",
"given",
"filter",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L439-L447 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.getFriendById | public Friend getFriendById(String xmppAddress) {
final RosterEntry entry = connection.getRoster().getEntry(
StringUtils.parseBareAddress(xmppAddress));
if (entry != null) {
return new Friend(this, connection, entry);
}
return null;
} | java | public Friend getFriendById(String xmppAddress) {
final RosterEntry entry = connection.getRoster().getEntry(
StringUtils.parseBareAddress(xmppAddress));
if (entry != null) {
return new Friend(this, connection, entry);
}
return null;
} | [
"public",
"Friend",
"getFriendById",
"(",
"String",
"xmppAddress",
")",
"{",
"final",
"RosterEntry",
"entry",
"=",
"connection",
".",
"getRoster",
"(",
")",
".",
"getEntry",
"(",
"StringUtils",
".",
"parseBareAddress",
"(",
"xmppAddress",
")",
")",
";",
"if",
... | Gets a friend based on his XMPPAddress.
@param xmppAddress
For example sum12345678@pvp.net
@return The corresponding Friend or null if user is not found or he is
not a friend of you. | [
"Gets",
"a",
"friend",
"based",
"on",
"his",
"XMPPAddress",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L457-L464 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.getFriendGroupByName | public FriendGroup getFriendGroupByName(String name) {
final RosterGroup g = connection.getRoster().getGroup(name);
if (g != null) {
return new FriendGroup(this, connection, g);
}
return addFriendGroup(name);
} | java | public FriendGroup getFriendGroupByName(String name) {
final RosterGroup g = connection.getRoster().getGroup(name);
if (g != null) {
return new FriendGroup(this, connection, g);
}
return addFriendGroup(name);
} | [
"public",
"FriendGroup",
"getFriendGroupByName",
"(",
"String",
"name",
")",
"{",
"final",
"RosterGroup",
"g",
"=",
"connection",
".",
"getRoster",
"(",
")",
".",
"getGroup",
"(",
"name",
")",
";",
"if",
"(",
"g",
"!=",
"null",
")",
"{",
"return",
"new",... | Gets a FriendGroup by name, for example "Duo Partners". The name is case
sensitive! The FriendGroup will be created if it didn't exist yet.
@param name
The name of your group (case-sensitive)
@return The corresponding FriendGroup | [
"Gets",
"a",
"FriendGroup",
"by",
"name",
"for",
"example",
"Duo",
"Partners",
".",
"The",
"name",
"is",
"case",
"sensitive!",
"The",
"FriendGroup",
"will",
"be",
"created",
"if",
"it",
"didn",
"t",
"exist",
"yet",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L493-L499 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.getFriendGroups | public List<FriendGroup> getFriendGroups() {
final ArrayList<FriendGroup> groups = new ArrayList<>();
for (final RosterGroup g : connection.getRoster().getGroups()) {
groups.add(new FriendGroup(this, connection, g));
}
return groups;
} | java | public List<FriendGroup> getFriendGroups() {
final ArrayList<FriendGroup> groups = new ArrayList<>();
for (final RosterGroup g : connection.getRoster().getGroups()) {
groups.add(new FriendGroup(this, connection, g));
}
return groups;
} | [
"public",
"List",
"<",
"FriendGroup",
">",
"getFriendGroups",
"(",
")",
"{",
"final",
"ArrayList",
"<",
"FriendGroup",
">",
"groups",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"RosterGroup",
"g",
":",
"connection",
".",
"getRoster"... | Get a list of all your FriendGroups.
@return A List of all your FriendGroups | [
"Get",
"a",
"list",
"of",
"all",
"your",
"FriendGroups",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L506-L512 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.getFriends | public List<Friend> getFriends() {
return getFriends(new Filter<Friend>() {
public boolean accept(Friend e) {
return true;
}
});
} | java | public List<Friend> getFriends() {
return getFriends(new Filter<Friend>() {
public boolean accept(Friend e) {
return true;
}
});
} | [
"public",
"List",
"<",
"Friend",
">",
"getFriends",
"(",
")",
"{",
"return",
"getFriends",
"(",
"new",
"Filter",
"<",
"Friend",
">",
"(",
")",
"{",
"public",
"boolean",
"accept",
"(",
"Friend",
"e",
")",
"{",
"return",
"true",
";",
"}",
"}",
")",
"... | Get all your friends, both online and offline.
@return A List of all your Friends | [
"Get",
"all",
"your",
"friends",
"both",
"online",
"and",
"offline",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L537-L544 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.getFriends | public List<Friend> getFriends(Filter<Friend> filter) {
final ArrayList<Friend> friends = new ArrayList<>();
for (final RosterEntry e : connection.getRoster().getEntries()) {
final Friend f = new Friend(this, connection, e);
if (filter.accept(f)) {
friends.add(f);
}
}
return friends;
} | java | public List<Friend> getFriends(Filter<Friend> filter) {
final ArrayList<Friend> friends = new ArrayList<>();
for (final RosterEntry e : connection.getRoster().getEntries()) {
final Friend f = new Friend(this, connection, e);
if (filter.accept(f)) {
friends.add(f);
}
}
return friends;
} | [
"public",
"List",
"<",
"Friend",
">",
"getFriends",
"(",
"Filter",
"<",
"Friend",
">",
"filter",
")",
"{",
"final",
"ArrayList",
"<",
"Friend",
">",
"friends",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"RosterEntry",
"e",
":",
... | Gets a list of your friends based on a given filter.
@param filter
The filter defines conditions that your Friends must meet.
@return A List of your Friends that meet the condition of your Filter | [
"Gets",
"a",
"list",
"of",
"your",
"friends",
"based",
"on",
"a",
"given",
"filter",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L553-L562 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.getName | public String getName(boolean forcedUpdate) {
if ((name == null || forcedUpdate) && getRiotApi() != null) {
try {
name = getRiotApi().getName(connection.getUser());
} catch (final IOException e) {
e.printStackTrace();
}
}
return name;
} | java | public String getName(boolean forcedUpdate) {
if ((name == null || forcedUpdate) && getRiotApi() != null) {
try {
name = getRiotApi().getName(connection.getUser());
} catch (final IOException e) {
e.printStackTrace();
}
}
return name;
} | [
"public",
"String",
"getName",
"(",
"boolean",
"forcedUpdate",
")",
"{",
"if",
"(",
"(",
"name",
"==",
"null",
"||",
"forcedUpdate",
")",
"&&",
"getRiotApi",
"(",
")",
"!=",
"null",
")",
"{",
"try",
"{",
"name",
"=",
"getRiotApi",
"(",
")",
".",
"get... | Gets the name of the user that is logged in. An Riot API key has to be
provided.
@param forcedUpdate
True will force to update the name even when it is not null.
@return The name of this user or null if something went wrong. | [
"Gets",
"the",
"name",
"of",
"the",
"user",
"that",
"is",
"logged",
"in",
".",
"An",
"Riot",
"API",
"key",
"has",
"to",
"be",
"provided",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L582-L591 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.getOfflineFriends | public List<Friend> getOfflineFriends() {
return getFriends(new Filter<Friend>() {
public boolean accept(Friend friend) {
return !friend.isOnline();
}
});
} | java | public List<Friend> getOfflineFriends() {
return getFriends(new Filter<Friend>() {
public boolean accept(Friend friend) {
return !friend.isOnline();
}
});
} | [
"public",
"List",
"<",
"Friend",
">",
"getOfflineFriends",
"(",
")",
"{",
"return",
"getFriends",
"(",
"new",
"Filter",
"<",
"Friend",
">",
"(",
")",
"{",
"public",
"boolean",
"accept",
"(",
"Friend",
"friend",
")",
"{",
"return",
"!",
"friend",
".",
"... | Get all your friends who are offline.
@return A list of all your offline Friends | [
"Get",
"all",
"your",
"friends",
"who",
"are",
"offline",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L598-L605 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.getOnlineFriends | public List<Friend> getOnlineFriends() {
return getFriends(new Filter<Friend>() {
public boolean accept(Friend friend) {
return friend.isOnline();
}
});
} | java | public List<Friend> getOnlineFriends() {
return getFriends(new Filter<Friend>() {
public boolean accept(Friend friend) {
return friend.isOnline();
}
});
} | [
"public",
"List",
"<",
"Friend",
">",
"getOnlineFriends",
"(",
")",
"{",
"return",
"getFriends",
"(",
"new",
"Filter",
"<",
"Friend",
">",
"(",
")",
"{",
"public",
"boolean",
"accept",
"(",
"Friend",
"friend",
")",
"{",
"return",
"friend",
".",
"isOnline... | Get all your friends who are online.
@return A list of all your online Friends | [
"Get",
"all",
"your",
"friends",
"who",
"are",
"online",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L612-L619 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.getPendingFriendRequests | public List<Friend> getPendingFriendRequests() {
return getFriends(new Filter<Friend>() {
public boolean accept(Friend friend) {
return friend.getFriendStatus() == FriendStatus.ADD_REQUEST_PENDING;
}
});
} | java | public List<Friend> getPendingFriendRequests() {
return getFriends(new Filter<Friend>() {
public boolean accept(Friend friend) {
return friend.getFriendStatus() == FriendStatus.ADD_REQUEST_PENDING;
}
});
} | [
"public",
"List",
"<",
"Friend",
">",
"getPendingFriendRequests",
"(",
")",
"{",
"return",
"getFriends",
"(",
"new",
"Filter",
"<",
"Friend",
">",
"(",
")",
"{",
"public",
"boolean",
"accept",
"(",
"Friend",
"friend",
")",
"{",
"return",
"friend",
".",
"... | Gets a list of user that you've sent friend requests but haven't answered
yet.
@return A list of Friends. | [
"Gets",
"a",
"list",
"of",
"user",
"that",
"you",
"ve",
"sent",
"friend",
"requests",
"but",
"haven",
"t",
"answered",
"yet",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L627-L634 | train |
atomix/catalyst | netty/src/main/java/io/atomix/catalyst/transport/netty/NettyOptions.java | NettyOptions.threads | public int threads() {
int threads = reader.getInteger(THREADS, DEFAULT_THREADS);
if (threads == -1) {
return Runtime.getRuntime().availableProcessors();
}
return threads;
} | java | public int threads() {
int threads = reader.getInteger(THREADS, DEFAULT_THREADS);
if (threads == -1) {
return Runtime.getRuntime().availableProcessors();
}
return threads;
} | [
"public",
"int",
"threads",
"(",
")",
"{",
"int",
"threads",
"=",
"reader",
".",
"getInteger",
"(",
"THREADS",
",",
"DEFAULT_THREADS",
")",
";",
"if",
"(",
"threads",
"==",
"-",
"1",
")",
"{",
"return",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"a... | The number of event loop threads. | [
"The",
"number",
"of",
"event",
"loop",
"threads",
"."
] | 140e762cb975cd8ee1fd85119043c5b8bf917c5c | https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyOptions.java#L71-L77 | train |
atomix/catalyst | netty/src/main/java/io/atomix/catalyst/transport/netty/NettyOptions.java | NettyOptions.sslProtocol | public SslProtocol sslProtocol() {
String protocol = reader.getString(SSL_PROTOCOL, DEFAULT_SSL_PROTOCOL).replace(".", "_");
try {
return SslProtocol.valueOf(protocol);
} catch (IllegalArgumentException e) {
throw new ConfigurationException("unknown SSL protocol: " + protocol, e);
}
} | java | public SslProtocol sslProtocol() {
String protocol = reader.getString(SSL_PROTOCOL, DEFAULT_SSL_PROTOCOL).replace(".", "_");
try {
return SslProtocol.valueOf(protocol);
} catch (IllegalArgumentException e) {
throw new ConfigurationException("unknown SSL protocol: " + protocol, e);
}
} | [
"public",
"SslProtocol",
"sslProtocol",
"(",
")",
"{",
"String",
"protocol",
"=",
"reader",
".",
"getString",
"(",
"SSL_PROTOCOL",
",",
"DEFAULT_SSL_PROTOCOL",
")",
".",
"replace",
"(",
"\".\"",
",",
"\"_\"",
")",
";",
"try",
"{",
"return",
"SslProtocol",
".... | The SSL Protocol. | [
"The",
"SSL",
"Protocol",
"."
] | 140e762cb975cd8ee1fd85119043c5b8bf917c5c | https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyOptions.java#L152-L159 | train |
atomix/catalyst | netty/src/main/java/io/atomix/catalyst/transport/netty/NettyServer.java | NettyServer.listen | private void listen(Address address, Consumer<Connection> listener, ThreadContext context) {
channelGroup = new DefaultChannelGroup("catalyst-acceptor-channels", GlobalEventExecutor.INSTANCE);
handler = new ServerHandler(connections, listener, context, transport.properties());
final ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.group(transport.eventLoopGroup())
.channel(NioServerSocketChannel.class)
.handler(new LoggingHandler(LogLevel.DEBUG))
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel channel) throws Exception {
ChannelPipeline pipeline = channel.pipeline();
if (transport.properties().sslEnabled()) {
pipeline.addFirst(new SslHandler(new NettyTls(transport.properties()).initSslEngine(false)));
}
pipeline.addLast(FIELD_PREPENDER);
pipeline.addLast(new LengthFieldBasedFrameDecoder(transport.properties().maxFrameSize(), 0, 4, 0, 4));
pipeline.addLast(handler);
}
})
.option(ChannelOption.SO_BACKLOG, transport.properties().acceptBacklog())
.option(ChannelOption.TCP_NODELAY, transport.properties().tcpNoDelay())
.option(ChannelOption.SO_REUSEADDR, transport.properties().reuseAddress())
.childOption(ChannelOption.ALLOCATOR, ALLOCATOR)
.childOption(ChannelOption.SO_KEEPALIVE, transport.properties().tcpKeepAlive());
if (transport.properties().sendBufferSize() != -1) {
bootstrap.childOption(ChannelOption.SO_SNDBUF, transport.properties().sendBufferSize());
}
if (transport.properties().receiveBufferSize() != -1) {
bootstrap.childOption(ChannelOption.SO_RCVBUF, transport.properties().receiveBufferSize());
}
LOGGER.info("Binding to {}", address);
ChannelFuture bindFuture = bootstrap.bind(address.socketAddress());
bindFuture.addListener((ChannelFutureListener) channelFuture -> {
if (channelFuture.isSuccess()) {
listening = true;
context.executor().execute(() -> {
LOGGER.info("Listening at {}", bindFuture.channel().localAddress());
listenFuture.complete(null);
});
} else {
context.execute(() -> listenFuture.completeExceptionally(channelFuture.cause()));
}
});
channelGroup.add(bindFuture.channel());
} | java | private void listen(Address address, Consumer<Connection> listener, ThreadContext context) {
channelGroup = new DefaultChannelGroup("catalyst-acceptor-channels", GlobalEventExecutor.INSTANCE);
handler = new ServerHandler(connections, listener, context, transport.properties());
final ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.group(transport.eventLoopGroup())
.channel(NioServerSocketChannel.class)
.handler(new LoggingHandler(LogLevel.DEBUG))
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel channel) throws Exception {
ChannelPipeline pipeline = channel.pipeline();
if (transport.properties().sslEnabled()) {
pipeline.addFirst(new SslHandler(new NettyTls(transport.properties()).initSslEngine(false)));
}
pipeline.addLast(FIELD_PREPENDER);
pipeline.addLast(new LengthFieldBasedFrameDecoder(transport.properties().maxFrameSize(), 0, 4, 0, 4));
pipeline.addLast(handler);
}
})
.option(ChannelOption.SO_BACKLOG, transport.properties().acceptBacklog())
.option(ChannelOption.TCP_NODELAY, transport.properties().tcpNoDelay())
.option(ChannelOption.SO_REUSEADDR, transport.properties().reuseAddress())
.childOption(ChannelOption.ALLOCATOR, ALLOCATOR)
.childOption(ChannelOption.SO_KEEPALIVE, transport.properties().tcpKeepAlive());
if (transport.properties().sendBufferSize() != -1) {
bootstrap.childOption(ChannelOption.SO_SNDBUF, transport.properties().sendBufferSize());
}
if (transport.properties().receiveBufferSize() != -1) {
bootstrap.childOption(ChannelOption.SO_RCVBUF, transport.properties().receiveBufferSize());
}
LOGGER.info("Binding to {}", address);
ChannelFuture bindFuture = bootstrap.bind(address.socketAddress());
bindFuture.addListener((ChannelFutureListener) channelFuture -> {
if (channelFuture.isSuccess()) {
listening = true;
context.executor().execute(() -> {
LOGGER.info("Listening at {}", bindFuture.channel().localAddress());
listenFuture.complete(null);
});
} else {
context.execute(() -> listenFuture.completeExceptionally(channelFuture.cause()));
}
});
channelGroup.add(bindFuture.channel());
} | [
"private",
"void",
"listen",
"(",
"Address",
"address",
",",
"Consumer",
"<",
"Connection",
">",
"listener",
",",
"ThreadContext",
"context",
")",
"{",
"channelGroup",
"=",
"new",
"DefaultChannelGroup",
"(",
"\"catalyst-acceptor-channels\"",
",",
"GlobalEventExecutor"... | Starts listening for the given member. | [
"Starts",
"listening",
"for",
"the",
"given",
"member",
"."
] | 140e762cb975cd8ee1fd85119043c5b8bf917c5c | https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyServer.java#L87-L136 | train |
atomix/catalyst | concurrent/src/main/java/io/atomix/catalyst/concurrent/Runnables.java | Runnables.logFailure | static Runnable logFailure(final Runnable runnable, Logger logger) {
return () -> {
try {
runnable.run();
} catch (Throwable t) {
if (!(t instanceof RejectedExecutionException)) {
logger.error("An uncaught exception occurred", t);
}
throw t;
}
};
} | java | static Runnable logFailure(final Runnable runnable, Logger logger) {
return () -> {
try {
runnable.run();
} catch (Throwable t) {
if (!(t instanceof RejectedExecutionException)) {
logger.error("An uncaught exception occurred", t);
}
throw t;
}
};
} | [
"static",
"Runnable",
"logFailure",
"(",
"final",
"Runnable",
"runnable",
",",
"Logger",
"logger",
")",
"{",
"return",
"(",
")",
"->",
"{",
"try",
"{",
"runnable",
".",
"run",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"if",
"(",
... | Returns a wrapped runnable that logs and rethrows uncaught exceptions. | [
"Returns",
"a",
"wrapped",
"runnable",
"that",
"logs",
"and",
"rethrows",
"uncaught",
"exceptions",
"."
] | 140e762cb975cd8ee1fd85119043c5b8bf917c5c | https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/concurrent/src/main/java/io/atomix/catalyst/concurrent/Runnables.java#L17-L28 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/wrapper/Friend.java | Friend.delete | public boolean delete() {
try {
con.getRoster().removeEntry(get());
return true;
} catch (XMPPException | NotLoggedInException | NoResponseException
| NotConnectedException e) {
e.printStackTrace();
}
return false;
} | java | public boolean delete() {
try {
con.getRoster().removeEntry(get());
return true;
} catch (XMPPException | NotLoggedInException | NoResponseException
| NotConnectedException e) {
e.printStackTrace();
}
return false;
} | [
"public",
"boolean",
"delete",
"(",
")",
"{",
"try",
"{",
"con",
".",
"getRoster",
"(",
")",
".",
"removeEntry",
"(",
"get",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"XMPPException",
"|",
"NotLoggedInException",
"|",
"NoResponseExcep... | Deletes this friend.
@return true if succesful, otherwise false | [
"Deletes",
"this",
"friend",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/wrapper/Friend.java#L98-L107 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/wrapper/Friend.java | Friend.getFriendStatus | public FriendStatus getFriendStatus() {
for (final FriendStatus status : FriendStatus.values()) {
if (status.status == get().getStatus()) {
return status;
}
}
return null;
} | java | public FriendStatus getFriendStatus() {
for (final FriendStatus status : FriendStatus.values()) {
if (status.status == get().getStatus()) {
return status;
}
}
return null;
} | [
"public",
"FriendStatus",
"getFriendStatus",
"(",
")",
"{",
"for",
"(",
"final",
"FriendStatus",
"status",
":",
"FriendStatus",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"status",
".",
"status",
"==",
"get",
"(",
")",
".",
"getStatus",
"(",
")",
")... | Gets the relation between you and this friend.
@return The FriendStatus
@see FriendStatus | [
"Gets",
"the",
"relation",
"between",
"you",
"and",
"this",
"friend",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/wrapper/Friend.java#L149-L156 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/wrapper/Friend.java | Friend.getGroup | public FriendGroup getGroup() {
final Collection<RosterGroup> groups = get().getGroups();
if (groups.size() > 0) {
return new FriendGroup(api, con, get().getGroups().iterator()
.next());
}
return null;
} | java | public FriendGroup getGroup() {
final Collection<RosterGroup> groups = get().getGroups();
if (groups.size() > 0) {
return new FriendGroup(api, con, get().getGroups().iterator()
.next());
}
return null;
} | [
"public",
"FriendGroup",
"getGroup",
"(",
")",
"{",
"final",
"Collection",
"<",
"RosterGroup",
">",
"groups",
"=",
"get",
"(",
")",
".",
"getGroups",
"(",
")",
";",
"if",
"(",
"groups",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"return",
"new",
"F... | Gets the FriendGroup that contains this friend.
@return the FriendGroup that currently contains this Friend or null if
this Friend is not in a FriendGroup. | [
"Gets",
"the",
"FriendGroup",
"that",
"contains",
"this",
"friend",
"."
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/wrapper/Friend.java#L164-L171 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/wrapper/Friend.java | Friend.getName | public String getName(boolean forcedUpdate) {
String name = get().getName();
if ((name == null || forcedUpdate) && api.getRiotApi() != null) {
try {
name = api.getRiotApi().getName(getUserId());
setName(name);
} catch (final IOException e) {
e.printStackTrace();
}
}
return name;
} | java | public String getName(boolean forcedUpdate) {
String name = get().getName();
if ((name == null || forcedUpdate) && api.getRiotApi() != null) {
try {
name = api.getRiotApi().getName(getUserId());
setName(name);
} catch (final IOException e) {
e.printStackTrace();
}
}
return name;
} | [
"public",
"String",
"getName",
"(",
"boolean",
"forcedUpdate",
")",
"{",
"String",
"name",
"=",
"get",
"(",
")",
".",
"getName",
"(",
")",
";",
"if",
"(",
"(",
"name",
"==",
"null",
"||",
"forcedUpdate",
")",
"&&",
"api",
".",
"getRiotApi",
"(",
")",... | Gets the name of this friend. If the name was null then we try to fetch
the name with your Riot API Key if provided. Enable forcedUpdate to
always fetch the latest name of this Friend even when the name is not
null.
@param forcedUpdate
True will force to update the name even when it is not null.
@return The name of this Friend or null if no name is assigned. | [
"Gets",
"the",
"name",
"of",
"this",
"friend",
".",
"If",
"the",
"name",
"was",
"null",
"then",
"we",
"try",
"to",
"fetch",
"the",
"name",
"with",
"your",
"Riot",
"API",
"Key",
"if",
"provided",
".",
"Enable",
"forcedUpdate",
"to",
"always",
"fetch",
"... | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/wrapper/Friend.java#L193-L204 | train |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/wrapper/Friend.java | Friend.sendMessage | public void sendMessage(String message) {
try {
getChat().sendMessage(message);
} catch (XMPPException | NotConnectedException e) {
e.printStackTrace();
}
} | java | public void sendMessage(String message) {
try {
getChat().sendMessage(message);
} catch (XMPPException | NotConnectedException e) {
e.printStackTrace();
}
} | [
"public",
"void",
"sendMessage",
"(",
"String",
"message",
")",
"{",
"try",
"{",
"getChat",
"(",
")",
".",
"sendMessage",
"(",
"message",
")",
";",
"}",
"catch",
"(",
"XMPPException",
"|",
"NotConnectedException",
"e",
")",
"{",
"e",
".",
"printStackTrace"... | Sends a message to this friend
@param message
The message you want to send | [
"Sends",
"a",
"message",
"to",
"this",
"friend"
] | 5e4d87d0c054ff2f6510545b0e9f838338695c70 | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/wrapper/Friend.java#L250-L256 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/Response.java | Response.addStatusMessage | @SuppressWarnings("unchecked")
protected void addStatusMessage(final String statusMessage,
final String solution) {
this.json.put(ProtocolConstants.SOLUTION, solution);
this.json.put(ProtocolConstants.STATUS_MESSAGE, statusMessage);
} | java | @SuppressWarnings("unchecked")
protected void addStatusMessage(final String statusMessage,
final String solution) {
this.json.put(ProtocolConstants.SOLUTION, solution);
this.json.put(ProtocolConstants.STATUS_MESSAGE, statusMessage);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"void",
"addStatusMessage",
"(",
"final",
"String",
"statusMessage",
",",
"final",
"String",
"solution",
")",
"{",
"this",
".",
"json",
".",
"put",
"(",
"ProtocolConstants",
".",
"SOLUTION",
",",
... | add a status message to the response
@param statusMessage
status message
@param solution
detailed description and solution | [
"add",
"a",
"status",
"message",
"to",
"the",
"response"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/Response.java#L31-L36 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/tomcat/TomcatClientResponder.java | TomcatClientResponder.error | public void error(final int errorCode, final String message) {
try {
this.response.sendError(errorCode, message);
} catch (final IOException e) {
e.printStackTrace();
}
} | java | public void error(final int errorCode, final String message) {
try {
this.response.sendError(errorCode, message);
} catch (final IOException e) {
e.printStackTrace();
}
} | [
"public",
"void",
"error",
"(",
"final",
"int",
"errorCode",
",",
"final",
"String",
"message",
")",
"{",
"try",
"{",
"this",
".",
"response",
".",
"sendError",
"(",
"errorCode",
",",
"message",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
... | abort the response with an error
@param errorCode
HTTP error code
@param message
error message | [
"abort",
"the",
"response",
"with",
"an",
"error"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/TomcatClientResponder.java#L58-L64 | train |
atomix/catalyst | buffer/src/main/java/io/atomix/catalyst/buffer/AbstractBuffer.java | AbstractBuffer.reset | protected AbstractBuffer reset(long offset, long capacity, long maxCapacity) {
this.offset = offset;
this.capacity = 0;
this.initialCapacity = capacity;
this.maxCapacity = maxCapacity;
capacity(initialCapacity);
references.set(0);
rewind();
return this;
} | java | protected AbstractBuffer reset(long offset, long capacity, long maxCapacity) {
this.offset = offset;
this.capacity = 0;
this.initialCapacity = capacity;
this.maxCapacity = maxCapacity;
capacity(initialCapacity);
references.set(0);
rewind();
return this;
} | [
"protected",
"AbstractBuffer",
"reset",
"(",
"long",
"offset",
",",
"long",
"capacity",
",",
"long",
"maxCapacity",
")",
"{",
"this",
".",
"offset",
"=",
"offset",
";",
"this",
".",
"capacity",
"=",
"0",
";",
"this",
".",
"initialCapacity",
"=",
"capacity"... | Resets the buffer's internal offset and capacity. | [
"Resets",
"the",
"buffer",
"s",
"internal",
"offset",
"and",
"capacity",
"."
] | 140e762cb975cd8ee1fd85119043c5b8bf917c5c | https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/buffer/src/main/java/io/atomix/catalyst/buffer/AbstractBuffer.java#L75-L84 | train |
atomix/catalyst | buffer/src/main/java/io/atomix/catalyst/buffer/AbstractBuffer.java | AbstractBuffer.checkOffset | protected void checkOffset(long offset) {
if (offset(offset) < this.offset) {
throw new IndexOutOfBoundsException();
} else if (limit == -1) {
if (offset > maxCapacity)
throw new IndexOutOfBoundsException();
} else {
if (offset > limit)
throw new IndexOutOfBoundsException();
}
} | java | protected void checkOffset(long offset) {
if (offset(offset) < this.offset) {
throw new IndexOutOfBoundsException();
} else if (limit == -1) {
if (offset > maxCapacity)
throw new IndexOutOfBoundsException();
} else {
if (offset > limit)
throw new IndexOutOfBoundsException();
}
} | [
"protected",
"void",
"checkOffset",
"(",
"long",
"offset",
")",
"{",
"if",
"(",
"offset",
"(",
"offset",
")",
"<",
"this",
".",
"offset",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"else",
"if",
"(",
"limit",
"==",
"-",
... | Checks that the offset is within the bounds of the buffer. | [
"Checks",
"that",
"the",
"offset",
"is",
"within",
"the",
"bounds",
"of",
"the",
"buffer",
"."
] | 140e762cb975cd8ee1fd85119043c5b8bf917c5c | https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/buffer/src/main/java/io/atomix/catalyst/buffer/AbstractBuffer.java#L319-L329 | train |
atomix/catalyst | buffer/src/main/java/io/atomix/catalyst/buffer/AbstractBuffer.java | AbstractBuffer.checkSlice | protected long checkSlice(long offset, long length) {
checkOffset(offset);
if (limit == -1) {
if (offset + length > capacity) {
if (capacity < maxCapacity) {
capacity(calculateCapacity(offset + length));
} else {
throw new BufferUnderflowException();
}
}
} else {
if (offset + length > limit)
throw new BufferUnderflowException();
}
return offset(offset);
} | java | protected long checkSlice(long offset, long length) {
checkOffset(offset);
if (limit == -1) {
if (offset + length > capacity) {
if (capacity < maxCapacity) {
capacity(calculateCapacity(offset + length));
} else {
throw new BufferUnderflowException();
}
}
} else {
if (offset + length > limit)
throw new BufferUnderflowException();
}
return offset(offset);
} | [
"protected",
"long",
"checkSlice",
"(",
"long",
"offset",
",",
"long",
"length",
")",
"{",
"checkOffset",
"(",
"offset",
")",
";",
"if",
"(",
"limit",
"==",
"-",
"1",
")",
"{",
"if",
"(",
"offset",
"+",
"length",
">",
"capacity",
")",
"{",
"if",
"(... | Checks bounds for a slice. | [
"Checks",
"bounds",
"for",
"a",
"slice",
"."
] | 140e762cb975cd8ee1fd85119043c5b8bf917c5c | https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/buffer/src/main/java/io/atomix/catalyst/buffer/AbstractBuffer.java#L334-L349 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/read/ReadRequest.java | ReadRequest.checkRequest | public static ReadRequest checkRequest(final HttpServletRequest request,
final ReadResponse readResponse) {
final Node user = checkUserIdentifier(request, readResponse);
if (user != null) {
final Node poster = checkPosterIdentifier(request, readResponse);
if (poster != null) {
final int numItems = checkNumItems(request, readResponse);
if (numItems != 0) {
final Boolean ownUpdates = checkOwnUpdates(request,
readResponse);
if (ownUpdates != null) {
return new ReadRequest(user, poster, numItems,
ownUpdates);
}
}
}
}
return null;
} | java | public static ReadRequest checkRequest(final HttpServletRequest request,
final ReadResponse readResponse) {
final Node user = checkUserIdentifier(request, readResponse);
if (user != null) {
final Node poster = checkPosterIdentifier(request, readResponse);
if (poster != null) {
final int numItems = checkNumItems(request, readResponse);
if (numItems != 0) {
final Boolean ownUpdates = checkOwnUpdates(request,
readResponse);
if (ownUpdates != null) {
return new ReadRequest(user, poster, numItems,
ownUpdates);
}
}
}
}
return null;
} | [
"public",
"static",
"ReadRequest",
"checkRequest",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"ReadResponse",
"readResponse",
")",
"{",
"final",
"Node",
"user",
"=",
"checkUserIdentifier",
"(",
"request",
",",
"readResponse",
")",
";",
"if",
"(",... | check a read request for validity concerning NSSP
@param request
Tomcat servlet request
@param readResponse
read response object
@return read request object<br>
<b>null</b> if the read request is invalid | [
"check",
"a",
"read",
"request",
"for",
"validity",
"concerning",
"NSSP"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/read/ReadRequest.java#L100-L119 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/read/ReadRequest.java | ReadRequest.checkPosterIdentifier | private static Node checkPosterIdentifier(final HttpServletRequest request,
final ReadResponse response) {
final String posterId = request
.getParameter(ProtocolConstants.Parameters.Read.POSTER_IDENTIFIER);
if (posterId != null) {
final Node user = NeoUtils.getUserByIdentifier(posterId);
if (user != null) {
return user;
}
response.posterIdentifierInvalid(posterId);
} else {
response.posterIdentifierMissing();
}
return null;
} | java | private static Node checkPosterIdentifier(final HttpServletRequest request,
final ReadResponse response) {
final String posterId = request
.getParameter(ProtocolConstants.Parameters.Read.POSTER_IDENTIFIER);
if (posterId != null) {
final Node user = NeoUtils.getUserByIdentifier(posterId);
if (user != null) {
return user;
}
response.posterIdentifierInvalid(posterId);
} else {
response.posterIdentifierMissing();
}
return null;
} | [
"private",
"static",
"Node",
"checkPosterIdentifier",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"ReadResponse",
"response",
")",
"{",
"final",
"String",
"posterId",
"=",
"request",
".",
"getParameter",
"(",
"ProtocolConstants",
".",
"Parameters",
... | check if the request contains a valid poster identifier
@param request
Tomcat servlet request
@param response
response object
@return user node with the identifier passed<br>
<b>null</b> if the identifier is invalid | [
"check",
"if",
"the",
"request",
"contains",
"a",
"valid",
"poster",
"identifier"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/read/ReadRequest.java#L158-L173 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/read/ReadRequest.java | ReadRequest.checkNumItems | private static int checkNumItems(final HttpServletRequest request,
final ReadResponse response) {
final String sNumItems = request
.getParameter(ProtocolConstants.Parameters.Read.NUM_ITEMS);
if (sNumItems != null) {
int numItems;
try {
numItems = Integer.valueOf(sNumItems);
if (numItems > 0) {
return numItems;
}
response.numItemsInvalid("Please provide a number greater than zero.");
} catch (final NumberFormatException e) {
response.numItemsInvalid("\""
+ sNumItems
+ "\" is not a number. Please provide a number such as \"15\" to retrieve that number of items.");
}
} else {
response.numItemsMissing();
}
return 0;
} | java | private static int checkNumItems(final HttpServletRequest request,
final ReadResponse response) {
final String sNumItems = request
.getParameter(ProtocolConstants.Parameters.Read.NUM_ITEMS);
if (sNumItems != null) {
int numItems;
try {
numItems = Integer.valueOf(sNumItems);
if (numItems > 0) {
return numItems;
}
response.numItemsInvalid("Please provide a number greater than zero.");
} catch (final NumberFormatException e) {
response.numItemsInvalid("\""
+ sNumItems
+ "\" is not a number. Please provide a number such as \"15\" to retrieve that number of items.");
}
} else {
response.numItemsMissing();
}
return 0;
} | [
"private",
"static",
"int",
"checkNumItems",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"ReadResponse",
"response",
")",
"{",
"final",
"String",
"sNumItems",
"=",
"request",
".",
"getParameter",
"(",
"ProtocolConstants",
".",
"Parameters",
".",
"... | check if the request contains a valid number of items to retrieve
@param request
Tomcat servlet request
@param response
response object
@return number of items to retrieve<br>
zero if the number is invalid | [
"check",
"if",
"the",
"request",
"contains",
"a",
"valid",
"number",
"of",
"items",
"to",
"retrieve"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/read/ReadRequest.java#L185-L208 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/read/ReadRequest.java | ReadRequest.checkOwnUpdates | private static Boolean checkOwnUpdates(final HttpServletRequest request,
final ReadResponse response) {
final String sOwnUpdates = request
.getParameter(ProtocolConstants.Parameters.Read.OWN_UPDATES);
if (sOwnUpdates != null) {
try {
final int iOwnUpdates = Integer.valueOf(sOwnUpdates);
return (iOwnUpdates != 0);
} catch (final NumberFormatException e) {
response.ownUpdatesInvalid(sOwnUpdates);
}
} else {
response.ownUpdatesMissing();
}
return null;
} | java | private static Boolean checkOwnUpdates(final HttpServletRequest request,
final ReadResponse response) {
final String sOwnUpdates = request
.getParameter(ProtocolConstants.Parameters.Read.OWN_UPDATES);
if (sOwnUpdates != null) {
try {
final int iOwnUpdates = Integer.valueOf(sOwnUpdates);
return (iOwnUpdates != 0);
} catch (final NumberFormatException e) {
response.ownUpdatesInvalid(sOwnUpdates);
}
} else {
response.ownUpdatesMissing();
}
return null;
} | [
"private",
"static",
"Boolean",
"checkOwnUpdates",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"ReadResponse",
"response",
")",
"{",
"final",
"String",
"sOwnUpdates",
"=",
"request",
".",
"getParameter",
"(",
"ProtocolConstants",
".",
"Parameters",
... | check if the request contains a valid retrieval flag
@param request
Tomcat servlet request
@param response
response object
@return retrieval flag<br>
<b>null</b> if the retrieval flag is invalid | [
"check",
"if",
"the",
"request",
"contains",
"a",
"valid",
"retrieval",
"flag"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/read/ReadRequest.java#L220-L236 | train |
atomix/catalyst | netty/src/main/java/io/atomix/catalyst/transport/netty/NettyTls.java | NettyTls.initSslEngine | public SSLEngine initSslEngine(boolean client) throws Exception {
// Load the keystore
KeyStore keyStore = loadKeystore(properties.sslKeyStorePath(), properties.sslKeyStorePassword());
// Setup the keyManager to use our keystore
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStore, keyStoreKeyPass(properties));
// Setup the Trust keystore
KeyStore trustStore;
if (properties.sslTrustStorePath() != null) {
// Use the separate Trust keystore
LOGGER.debug("Using separate trust store");
trustStore = loadKeystore(properties.sslTrustStorePath(), properties.sslTrustStorePassword());
} else {
// Reuse the existing keystore
trustStore = keyStore;
LOGGER.debug("Using key store as trust store");
}
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(trustStore);
KeyManager[] keyManagers = keyManagerFactory.getKeyManagers();
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagers, trustManagers, null);
SSLEngine sslEngine = sslContext.createSSLEngine();
sslEngine.setUseClientMode(client);
sslEngine.setWantClientAuth(true);
sslEngine.setEnabledProtocols(sslEngine.getSupportedProtocols());
sslEngine.setEnabledCipherSuites(sslEngine.getSupportedCipherSuites());
sslEngine.setEnableSessionCreation(true);
return sslEngine;
} | java | public SSLEngine initSslEngine(boolean client) throws Exception {
// Load the keystore
KeyStore keyStore = loadKeystore(properties.sslKeyStorePath(), properties.sslKeyStorePassword());
// Setup the keyManager to use our keystore
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStore, keyStoreKeyPass(properties));
// Setup the Trust keystore
KeyStore trustStore;
if (properties.sslTrustStorePath() != null) {
// Use the separate Trust keystore
LOGGER.debug("Using separate trust store");
trustStore = loadKeystore(properties.sslTrustStorePath(), properties.sslTrustStorePassword());
} else {
// Reuse the existing keystore
trustStore = keyStore;
LOGGER.debug("Using key store as trust store");
}
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(trustStore);
KeyManager[] keyManagers = keyManagerFactory.getKeyManagers();
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagers, trustManagers, null);
SSLEngine sslEngine = sslContext.createSSLEngine();
sslEngine.setUseClientMode(client);
sslEngine.setWantClientAuth(true);
sslEngine.setEnabledProtocols(sslEngine.getSupportedProtocols());
sslEngine.setEnabledCipherSuites(sslEngine.getSupportedCipherSuites());
sslEngine.setEnableSessionCreation(true);
return sslEngine;
} | [
"public",
"SSLEngine",
"initSslEngine",
"(",
"boolean",
"client",
")",
"throws",
"Exception",
"{",
"// Load the keystore",
"KeyStore",
"keyStore",
"=",
"loadKeystore",
"(",
"properties",
".",
"sslKeyStorePath",
"(",
")",
",",
"properties",
".",
"sslKeyStorePassword",
... | Initializes an SSL engine.
@param client Indicates whether the engine is being initialized for a client.
@return The initialized SSL engine. | [
"Initializes",
"an",
"SSL",
"engine",
"."
] | 140e762cb975cd8ee1fd85119043c5b8bf917c5c | https://github.com/atomix/catalyst/blob/140e762cb975cd8ee1fd85119043c5b8bf917c5c/netty/src/main/java/io/atomix/catalyst/transport/netty/NettyTls.java#L46-L82 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/Configs.java | Configs.initialize | private void initialize() throws IllegalArgumentException,
IllegalAccessException {
Field[] fields = this.getClass().getFields();
for (Field f : fields) {
if (this.getProperty(f.getName()) == null) {
System.err.print("Property '" + f.getName()
+ "' not defined in config file");
}
if (f.getType().equals(String.class)) {
f.set(this, this.getProperty(f.getName()));
} else if (f.getType().equals(long.class)) {
f.setLong(this, Long.valueOf(this.getProperty(f.getName())));
} else if (f.getType().equals(int.class)) {
f.setInt(this, Integer.valueOf(this.getProperty(f.getName())));
} else if (f.getType().equals(boolean.class)) {
f.setBoolean(this,
Boolean.valueOf(this.getProperty(f.getName())));
} else if (f.getType().equals(String[].class)) {
f.set(this, this.getProperty(f.getName()).split(";"));
} else if (f.getType().equals(int[].class)) {
String[] tmp = this.getProperty(f.getName()).split(";");
int[] ints = new int[tmp.length];
for (int i = 0; i < tmp.length; i++) {
ints[i] = Integer.parseInt(tmp[i]);
}
f.set(this, ints);
} else if (f.getType().equals(long[].class)) {
String[] tmp = this.getProperty(f.getName()).split(";");
long[] longs = new long[tmp.length];
for (int i = 0; i < tmp.length; i++) {
longs[i] = Long.parseLong(tmp[i]);
}
f.set(this, longs);
}
}
} | java | private void initialize() throws IllegalArgumentException,
IllegalAccessException {
Field[] fields = this.getClass().getFields();
for (Field f : fields) {
if (this.getProperty(f.getName()) == null) {
System.err.print("Property '" + f.getName()
+ "' not defined in config file");
}
if (f.getType().equals(String.class)) {
f.set(this, this.getProperty(f.getName()));
} else if (f.getType().equals(long.class)) {
f.setLong(this, Long.valueOf(this.getProperty(f.getName())));
} else if (f.getType().equals(int.class)) {
f.setInt(this, Integer.valueOf(this.getProperty(f.getName())));
} else if (f.getType().equals(boolean.class)) {
f.setBoolean(this,
Boolean.valueOf(this.getProperty(f.getName())));
} else if (f.getType().equals(String[].class)) {
f.set(this, this.getProperty(f.getName()).split(";"));
} else if (f.getType().equals(int[].class)) {
String[] tmp = this.getProperty(f.getName()).split(";");
int[] ints = new int[tmp.length];
for (int i = 0; i < tmp.length; i++) {
ints[i] = Integer.parseInt(tmp[i]);
}
f.set(this, ints);
} else if (f.getType().equals(long[].class)) {
String[] tmp = this.getProperty(f.getName()).split(";");
long[] longs = new long[tmp.length];
for (int i = 0; i < tmp.length; i++) {
longs[i] = Long.parseLong(tmp[i]);
}
f.set(this, longs);
}
}
} | [
"private",
"void",
"initialize",
"(",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalAccessException",
"{",
"Field",
"[",
"]",
"fields",
"=",
"this",
".",
"getClass",
"(",
")",
".",
"getFields",
"(",
")",
";",
"for",
"(",
"Field",
"f",
":",
"field... | Fills all fields with the data defined in the config file.
@throws IllegalArgumentException
@throws IllegalAccessException | [
"Fills",
"all",
"fields",
"with",
"the",
"data",
"defined",
"in",
"the",
"config",
"file",
"."
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/Configs.java#L92-L127 | train |
renepickhardt/metalcon | autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Helper/SuggestTree.java | SuggestTree.weightOf | public int weightOf(String suggestion) {
Node n = getNode(suggestion);
return (n != null) ? n.weight : -1;
} | java | public int weightOf(String suggestion) {
Node n = getNode(suggestion);
return (n != null) ? n.weight : -1;
} | [
"public",
"int",
"weightOf",
"(",
"String",
"suggestion",
")",
"{",
"Node",
"n",
"=",
"getNode",
"(",
"suggestion",
")",
";",
"return",
"(",
"n",
"!=",
"null",
")",
"?",
"n",
".",
"weight",
":",
"-",
"1",
";",
"}"
] | Returns the weight of the specified suggestion in this tree, or -1 if the
tree does not contain the suggestion.
@throws NullPointerException if the specified suggestion is {@code null} | [
"Returns",
"the",
"weight",
"of",
"the",
"specified",
"suggestion",
"in",
"this",
"tree",
"or",
"-",
"1",
"if",
"the",
"tree",
"does",
"not",
"contain",
"the",
"suggestion",
"."
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Helper/SuggestTree.java#L152-L155 | train |
renepickhardt/metalcon | autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Helper/SuggestTree.java | SuggestTree.put | public void put(String suggestion, int weight, String key) {
if(suggestion.isEmpty() || weight < 0)
throw new IllegalArgumentException();
if(root == null) {
root = new Node(suggestion, weight, key, 0, null);
size++;
return;
}
int i = 0;
Node n = root;
while(true) {
if(suggestion.charAt(i) < n.firstChar) {
if(n.left != null)
n = n.left;
else{
n.left = new Node(suggestion, weight, key, i, n);
insertIntoLists(n.left);
size++;
return;
}
}else if(suggestion.charAt(i) > n.firstChar) {
if(n.right != null)
n = n.right;
else{
n.right = new Node(suggestion, weight, key, i, n);
insertIntoLists(n.right);
size++;
return;
}
}else{
for(i++; i < n.charEnd; i++) {
if(i == suggestion.length()
|| suggestion.charAt(i) != n.suggestion.charAt(i)) {
n = splitNode(n, i);
break;
}
}
if(i < suggestion.length()) {
if(n.mid != null)
n = n.mid;
else{
n.mid = new Node(suggestion, weight, key, i, n);
insertIntoLists(n.mid);
size++;
return;
}
}else if(n.weight == -1) {
n.suggestion = suggestion;
n.weight = weight;
insertIntoLists(n);
size++;
return;
}else if(weight > n.weight) {
n.weight = weight;
updateListsIncreasedWeight(n);
return;
}else if(weight < n.weight) {
n.weight = weight;
updateListsDecreasedWeight(n);
return;
}else
return;
}
}
} | java | public void put(String suggestion, int weight, String key) {
if(suggestion.isEmpty() || weight < 0)
throw new IllegalArgumentException();
if(root == null) {
root = new Node(suggestion, weight, key, 0, null);
size++;
return;
}
int i = 0;
Node n = root;
while(true) {
if(suggestion.charAt(i) < n.firstChar) {
if(n.left != null)
n = n.left;
else{
n.left = new Node(suggestion, weight, key, i, n);
insertIntoLists(n.left);
size++;
return;
}
}else if(suggestion.charAt(i) > n.firstChar) {
if(n.right != null)
n = n.right;
else{
n.right = new Node(suggestion, weight, key, i, n);
insertIntoLists(n.right);
size++;
return;
}
}else{
for(i++; i < n.charEnd; i++) {
if(i == suggestion.length()
|| suggestion.charAt(i) != n.suggestion.charAt(i)) {
n = splitNode(n, i);
break;
}
}
if(i < suggestion.length()) {
if(n.mid != null)
n = n.mid;
else{
n.mid = new Node(suggestion, weight, key, i, n);
insertIntoLists(n.mid);
size++;
return;
}
}else if(n.weight == -1) {
n.suggestion = suggestion;
n.weight = weight;
insertIntoLists(n);
size++;
return;
}else if(weight > n.weight) {
n.weight = weight;
updateListsIncreasedWeight(n);
return;
}else if(weight < n.weight) {
n.weight = weight;
updateListsDecreasedWeight(n);
return;
}else
return;
}
}
} | [
"public",
"void",
"put",
"(",
"String",
"suggestion",
",",
"int",
"weight",
",",
"String",
"key",
")",
"{",
"if",
"(",
"suggestion",
".",
"isEmpty",
"(",
")",
"||",
"weight",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"if... | Inserts the specified suggestion with the specified weight into this
tree, or assigns the specified new weight to the suggestion if it is
already present.
@throws IllegalArgumentException if the specified suggestion is an empty
string or the specified weight is negative
@throws NullPointerException if the specified suggestion is {@code null} | [
"Inserts",
"the",
"specified",
"suggestion",
"with",
"the",
"specified",
"weight",
"into",
"this",
"tree",
"or",
"assigns",
"the",
"specified",
"new",
"weight",
"to",
"the",
"suggestion",
"if",
"it",
"is",
"already",
"present",
"."
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Helper/SuggestTree.java#L190-L254 | train |
renepickhardt/metalcon | autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Helper/SuggestTree.java | SuggestTree.remove | public void remove(String suggestion) {
Node n = getNode(suggestion);
if(n == null)
return;
n.weight = -1;
size--;
Node m = n;
if(n.mid == null) {
Node replacement = removeNode(n);
if(replacement != null)
replacement.parent = n.parent;
if(n == root)
root = replacement;
else if(n == n.parent.mid)
n.parent.mid = replacement;
else{
if(n == n.parent.left)
n.parent.left = replacement;
else
n.parent.right = replacement;
while(n != root && n != n.parent.mid)
n = n.parent;
}
n = n.parent;
if(n == null)
return;
}
if(n.weight == -1 && n.mid.left == null && n.mid.right == null) {
n = mergeWithChild(n);
while(n != root && n != n.parent.mid)
n = n.parent;
n = n.parent;
if(n == null)
return;
}
removeFromLists(m, n);
} | java | public void remove(String suggestion) {
Node n = getNode(suggestion);
if(n == null)
return;
n.weight = -1;
size--;
Node m = n;
if(n.mid == null) {
Node replacement = removeNode(n);
if(replacement != null)
replacement.parent = n.parent;
if(n == root)
root = replacement;
else if(n == n.parent.mid)
n.parent.mid = replacement;
else{
if(n == n.parent.left)
n.parent.left = replacement;
else
n.parent.right = replacement;
while(n != root && n != n.parent.mid)
n = n.parent;
}
n = n.parent;
if(n == null)
return;
}
if(n.weight == -1 && n.mid.left == null && n.mid.right == null) {
n = mergeWithChild(n);
while(n != root && n != n.parent.mid)
n = n.parent;
n = n.parent;
if(n == null)
return;
}
removeFromLists(m, n);
} | [
"public",
"void",
"remove",
"(",
"String",
"suggestion",
")",
"{",
"Node",
"n",
"=",
"getNode",
"(",
"suggestion",
")",
";",
"if",
"(",
"n",
"==",
"null",
")",
"return",
";",
"n",
".",
"weight",
"=",
"-",
"1",
";",
"size",
"--",
";",
"Node",
"m",... | Removes the specified suggestion from this tree, if present.
@throws NullPointerException if the specified suggestion is {@code null} | [
"Removes",
"the",
"specified",
"suggestion",
"from",
"this",
"tree",
"if",
"present",
"."
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/autocompleteServer/src/main/java/de/metalcon/autocompleteServer/Helper/SuggestTree.java#L408-L444 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/socialgraph/algorithms/ReadOptimizedGraphity.java | ReadOptimizedGraphity.updateEgoNetwork | private void updateEgoNetwork(final Node user) {
Node followedReplica, followingUser, lastPosterReplica;
Node prevReplica, nextReplica;
// loop through users following
for (Relationship relationship : user.getRelationships(
SocialGraphRelationshipType.REPLICA, Direction.INCOMING)) {
// load each replica and the user corresponding
followedReplica = relationship.getStartNode();
followingUser = NeoUtils.getPrevSingleNode(followedReplica,
SocialGraphRelationshipType.FOLLOW);
// bridge user node
prevReplica = NeoUtils.getPrevSingleNode(followedReplica,
SocialGraphRelationshipType.GRAPHITY);
if (!prevReplica.equals(followingUser)) {
followedReplica.getSingleRelationship(
SocialGraphRelationshipType.GRAPHITY,
Direction.INCOMING).delete();
nextReplica = NeoUtils.getNextSingleNode(followedReplica,
SocialGraphRelationshipType.GRAPHITY);
if (nextReplica != null) {
followedReplica.getSingleRelationship(
SocialGraphRelationshipType.GRAPHITY,
Direction.OUTGOING).delete();
prevReplica.createRelationshipTo(nextReplica,
SocialGraphRelationshipType.GRAPHITY);
}
}
// insert user's replica at its new position
lastPosterReplica = NeoUtils.getNextSingleNode(followingUser,
SocialGraphRelationshipType.GRAPHITY);
if (!lastPosterReplica.equals(followedReplica)) {
followingUser.getSingleRelationship(
SocialGraphRelationshipType.GRAPHITY,
Direction.OUTGOING).delete();
followingUser.createRelationshipTo(followedReplica,
SocialGraphRelationshipType.GRAPHITY);
followedReplica.createRelationshipTo(lastPosterReplica,
SocialGraphRelationshipType.GRAPHITY);
}
}
} | java | private void updateEgoNetwork(final Node user) {
Node followedReplica, followingUser, lastPosterReplica;
Node prevReplica, nextReplica;
// loop through users following
for (Relationship relationship : user.getRelationships(
SocialGraphRelationshipType.REPLICA, Direction.INCOMING)) {
// load each replica and the user corresponding
followedReplica = relationship.getStartNode();
followingUser = NeoUtils.getPrevSingleNode(followedReplica,
SocialGraphRelationshipType.FOLLOW);
// bridge user node
prevReplica = NeoUtils.getPrevSingleNode(followedReplica,
SocialGraphRelationshipType.GRAPHITY);
if (!prevReplica.equals(followingUser)) {
followedReplica.getSingleRelationship(
SocialGraphRelationshipType.GRAPHITY,
Direction.INCOMING).delete();
nextReplica = NeoUtils.getNextSingleNode(followedReplica,
SocialGraphRelationshipType.GRAPHITY);
if (nextReplica != null) {
followedReplica.getSingleRelationship(
SocialGraphRelationshipType.GRAPHITY,
Direction.OUTGOING).delete();
prevReplica.createRelationshipTo(nextReplica,
SocialGraphRelationshipType.GRAPHITY);
}
}
// insert user's replica at its new position
lastPosterReplica = NeoUtils.getNextSingleNode(followingUser,
SocialGraphRelationshipType.GRAPHITY);
if (!lastPosterReplica.equals(followedReplica)) {
followingUser.getSingleRelationship(
SocialGraphRelationshipType.GRAPHITY,
Direction.OUTGOING).delete();
followingUser.createRelationshipTo(followedReplica,
SocialGraphRelationshipType.GRAPHITY);
followedReplica.createRelationshipTo(lastPosterReplica,
SocialGraphRelationshipType.GRAPHITY);
}
}
} | [
"private",
"void",
"updateEgoNetwork",
"(",
"final",
"Node",
"user",
")",
"{",
"Node",
"followedReplica",
",",
"followingUser",
",",
"lastPosterReplica",
";",
"Node",
"prevReplica",
",",
"nextReplica",
";",
"// loop through users following",
"for",
"(",
"Relationship"... | update the ego network of a user
@param user
user where changes have occurred | [
"update",
"the",
"ego",
"network",
"of",
"a",
"user"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/algorithms/ReadOptimizedGraphity.java#L149-L193 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/socialgraph/algorithms/ReadOptimizedGraphity.java | ReadOptimizedGraphity.removeFromReplicaLayer | private void removeFromReplicaLayer(final Node followedReplica) {
final Node prev = NeoUtils.getPrevSingleNode(followedReplica,
SocialGraphRelationshipType.GRAPHITY);
final Node next = NeoUtils.getNextSingleNode(followedReplica,
SocialGraphRelationshipType.GRAPHITY);
// bridge the user replica in the replica layer
prev.getSingleRelationship(SocialGraphRelationshipType.GRAPHITY,
Direction.OUTGOING).delete();
if (next != null) {
next.getSingleRelationship(SocialGraphRelationshipType.GRAPHITY,
Direction.INCOMING).delete();
prev.createRelationshipTo(next,
SocialGraphRelationshipType.GRAPHITY);
}
// remove the followship
followedReplica.getSingleRelationship(
SocialGraphRelationshipType.FOLLOW, Direction.INCOMING)
.delete();
// remove the replica node itself
followedReplica.getSingleRelationship(
SocialGraphRelationshipType.REPLICA, Direction.OUTGOING)
.delete();
followedReplica.delete();
} | java | private void removeFromReplicaLayer(final Node followedReplica) {
final Node prev = NeoUtils.getPrevSingleNode(followedReplica,
SocialGraphRelationshipType.GRAPHITY);
final Node next = NeoUtils.getNextSingleNode(followedReplica,
SocialGraphRelationshipType.GRAPHITY);
// bridge the user replica in the replica layer
prev.getSingleRelationship(SocialGraphRelationshipType.GRAPHITY,
Direction.OUTGOING).delete();
if (next != null) {
next.getSingleRelationship(SocialGraphRelationshipType.GRAPHITY,
Direction.INCOMING).delete();
prev.createRelationshipTo(next,
SocialGraphRelationshipType.GRAPHITY);
}
// remove the followship
followedReplica.getSingleRelationship(
SocialGraphRelationshipType.FOLLOW, Direction.INCOMING)
.delete();
// remove the replica node itself
followedReplica.getSingleRelationship(
SocialGraphRelationshipType.REPLICA, Direction.OUTGOING)
.delete();
followedReplica.delete();
} | [
"private",
"void",
"removeFromReplicaLayer",
"(",
"final",
"Node",
"followedReplica",
")",
"{",
"final",
"Node",
"prev",
"=",
"NeoUtils",
".",
"getPrevSingleNode",
"(",
"followedReplica",
",",
"SocialGraphRelationshipType",
".",
"GRAPHITY",
")",
";",
"final",
"Node"... | remove a followed user from the replica layer
@param followedReplica
replica of the user that will be removed | [
"remove",
"a",
"followed",
"user",
"from",
"the",
"replica",
"layer"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/algorithms/ReadOptimizedGraphity.java#L276-L302 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/socialgraph/algorithms/ReadOptimizedGraphity.java | ReadOptimizedGraphity.updateReplicaLayerStatusUpdateDeletion | private void updateReplicaLayerStatusUpdateDeletion(final Node user,
final Node statusUpdate) {
final Node lastUpdate = NeoUtils.getNextSingleNode(user,
SocialGraphRelationshipType.UPDATE);
// update the ego network if the removal targets the last recent status
// update
if (statusUpdate.equals(lastUpdate)) {
// get timestamp of the last recent status update in future
long newTimestamp = 0;
final Node nextStatusUpdate = NeoUtils.getNextSingleNode(
statusUpdate, SocialGraphRelationshipType.UPDATE);
if (nextStatusUpdate != null) {
newTimestamp = (long) nextStatusUpdate
.getProperty(Properties.StatusUpdate.TIMESTAMP);
}
// loop through followers
Node replicaNode, following;
for (Relationship replicated : user.getRelationships(
SocialGraphRelationshipType.REPLICA, Direction.INCOMING)) {
replicaNode = replicated.getEndNode();
following = NeoUtils.getPrevSingleNode(replicaNode,
SocialGraphRelationshipType.FOLLOW);
// search for insertion index within following replica layer
long crrTimestamp;
Node prevReplica = following;
Node nextReplica = null;
while (true) {
// get next user
nextReplica = NeoUtils.getNextSingleNode(prevReplica,
SocialGraphRelationshipType.GRAPHITY);
if (nextReplica != null) {
// ignore replica of the status update owner
if (nextReplica.equals(replicaNode)) {
prevReplica = nextReplica;
continue;
}
crrTimestamp = getLastUpdateByReplica(nextReplica);
// step on if current user has newer status updates
if (crrTimestamp > newTimestamp) {
prevReplica = nextReplica;
continue;
}
}
// insertion position has been found
break;
}
// insert the replica
if (nextReplica != null) {
// bride the replica node
final Node oldPrevReplica = NeoUtils.getNextSingleNode(
replicaNode, SocialGraphRelationshipType.GRAPHITY);
final Node oldNextReplica = NeoUtils.getNextSingleNode(
replicaNode, SocialGraphRelationshipType.GRAPHITY);
replicaNode.getSingleRelationship(
SocialGraphRelationshipType.GRAPHITY,
Direction.INCOMING).delete();
if (oldNextReplica != null) {
oldNextReplica.getSingleRelationship(
SocialGraphRelationshipType.GRAPHITY,
Direction.INCOMING).delete();
oldPrevReplica.createRelationshipTo(oldNextReplica,
SocialGraphRelationshipType.GRAPHITY);
}
// link to new neighbored nodes
if (nextReplica != null) {
replicaNode.createRelationshipTo(nextReplica,
SocialGraphRelationshipType.GRAPHITY);
prevReplica.getSingleRelationship(
SocialGraphRelationshipType.GRAPHITY,
Direction.OUTGOING);
}
prevReplica.createRelationshipTo(replicaNode,
SocialGraphRelationshipType.GRAPHITY);
}
}
}
} | java | private void updateReplicaLayerStatusUpdateDeletion(final Node user,
final Node statusUpdate) {
final Node lastUpdate = NeoUtils.getNextSingleNode(user,
SocialGraphRelationshipType.UPDATE);
// update the ego network if the removal targets the last recent status
// update
if (statusUpdate.equals(lastUpdate)) {
// get timestamp of the last recent status update in future
long newTimestamp = 0;
final Node nextStatusUpdate = NeoUtils.getNextSingleNode(
statusUpdate, SocialGraphRelationshipType.UPDATE);
if (nextStatusUpdate != null) {
newTimestamp = (long) nextStatusUpdate
.getProperty(Properties.StatusUpdate.TIMESTAMP);
}
// loop through followers
Node replicaNode, following;
for (Relationship replicated : user.getRelationships(
SocialGraphRelationshipType.REPLICA, Direction.INCOMING)) {
replicaNode = replicated.getEndNode();
following = NeoUtils.getPrevSingleNode(replicaNode,
SocialGraphRelationshipType.FOLLOW);
// search for insertion index within following replica layer
long crrTimestamp;
Node prevReplica = following;
Node nextReplica = null;
while (true) {
// get next user
nextReplica = NeoUtils.getNextSingleNode(prevReplica,
SocialGraphRelationshipType.GRAPHITY);
if (nextReplica != null) {
// ignore replica of the status update owner
if (nextReplica.equals(replicaNode)) {
prevReplica = nextReplica;
continue;
}
crrTimestamp = getLastUpdateByReplica(nextReplica);
// step on if current user has newer status updates
if (crrTimestamp > newTimestamp) {
prevReplica = nextReplica;
continue;
}
}
// insertion position has been found
break;
}
// insert the replica
if (nextReplica != null) {
// bride the replica node
final Node oldPrevReplica = NeoUtils.getNextSingleNode(
replicaNode, SocialGraphRelationshipType.GRAPHITY);
final Node oldNextReplica = NeoUtils.getNextSingleNode(
replicaNode, SocialGraphRelationshipType.GRAPHITY);
replicaNode.getSingleRelationship(
SocialGraphRelationshipType.GRAPHITY,
Direction.INCOMING).delete();
if (oldNextReplica != null) {
oldNextReplica.getSingleRelationship(
SocialGraphRelationshipType.GRAPHITY,
Direction.INCOMING).delete();
oldPrevReplica.createRelationshipTo(oldNextReplica,
SocialGraphRelationshipType.GRAPHITY);
}
// link to new neighbored nodes
if (nextReplica != null) {
replicaNode.createRelationshipTo(nextReplica,
SocialGraphRelationshipType.GRAPHITY);
prevReplica.getSingleRelationship(
SocialGraphRelationshipType.GRAPHITY,
Direction.OUTGOING);
}
prevReplica.createRelationshipTo(replicaNode,
SocialGraphRelationshipType.GRAPHITY);
}
}
}
} | [
"private",
"void",
"updateReplicaLayerStatusUpdateDeletion",
"(",
"final",
"Node",
"user",
",",
"final",
"Node",
"statusUpdate",
")",
"{",
"final",
"Node",
"lastUpdate",
"=",
"NeoUtils",
".",
"getNextSingleNode",
"(",
"user",
",",
"SocialGraphRelationshipType",
".",
... | update the replica layer for status update deletion
@param user
owner of the status update being deleted
@param statusUpdate
status update being deleted | [
"update",
"the",
"replica",
"layer",
"for",
"status",
"update",
"deletion"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/algorithms/ReadOptimizedGraphity.java#L335-L421 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/socialgraph/algorithms/ReadOptimizedGraphity.java | ReadOptimizedGraphity.getLastUpdateByReplica | private static long getLastUpdateByReplica(final Node userReplica) {
final Node user = NeoUtils.getNextSingleNode(userReplica,
SocialGraphRelationshipType.REPLICA);
if (user.hasProperty(Properties.User.LAST_UPDATE)) {
return (long) user.getProperty(Properties.User.LAST_UPDATE);
}
return 0;
} | java | private static long getLastUpdateByReplica(final Node userReplica) {
final Node user = NeoUtils.getNextSingleNode(userReplica,
SocialGraphRelationshipType.REPLICA);
if (user.hasProperty(Properties.User.LAST_UPDATE)) {
return (long) user.getProperty(Properties.User.LAST_UPDATE);
}
return 0;
} | [
"private",
"static",
"long",
"getLastUpdateByReplica",
"(",
"final",
"Node",
"userReplica",
")",
"{",
"final",
"Node",
"user",
"=",
"NeoUtils",
".",
"getNextSingleNode",
"(",
"userReplica",
",",
"SocialGraphRelationshipType",
".",
"REPLICA",
")",
";",
"if",
"(",
... | get a user's last recent status update's time stamp
@param userReplica
replica of the user targeted
@return last recent status update's time stamp | [
"get",
"a",
"user",
"s",
"last",
"recent",
"status",
"update",
"s",
"time",
"stamp"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/socialgraph/algorithms/ReadOptimizedGraphity.java#L467-L474 | train |
renepickhardt/metalcon | graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/create/follow/CreateFollowRequest.java | CreateFollowRequest.checkRequest | public static CreateFollowRequest checkRequest(
final FormItemList formItemList, final CreateRequest createRequest,
final CreateFollowResponse createFollowResponse) {
final Node user = checkUserIdentifier(formItemList,
createFollowResponse);
if (user != null) {
final Node followed = checkFollowedIdentifier(formItemList,
createFollowResponse);
if (followed != null) {
return new CreateFollowRequest(createRequest.getType(), user,
followed);
}
}
return null;
} | java | public static CreateFollowRequest checkRequest(
final FormItemList formItemList, final CreateRequest createRequest,
final CreateFollowResponse createFollowResponse) {
final Node user = checkUserIdentifier(formItemList,
createFollowResponse);
if (user != null) {
final Node followed = checkFollowedIdentifier(formItemList,
createFollowResponse);
if (followed != null) {
return new CreateFollowRequest(createRequest.getType(), user,
followed);
}
}
return null;
} | [
"public",
"static",
"CreateFollowRequest",
"checkRequest",
"(",
"final",
"FormItemList",
"formItemList",
",",
"final",
"CreateRequest",
"createRequest",
",",
"final",
"CreateFollowResponse",
"createFollowResponse",
")",
"{",
"final",
"Node",
"user",
"=",
"checkUserIdentif... | check a create follow edge request for validity concerning NSSP
@param formItemList
form item list extracted
@param createRequest
basic create request object
@param createFollowResponse
create follow edge response object
@return create follow edge request object<br>
<b>null</b> if the create follow edge request is invalid | [
"check",
"a",
"create",
"follow",
"edge",
"request",
"for",
"validity",
"concerning",
"NSSP"
] | 26a7bd89d2225fe2172dc958d10f64a1bd9cf52f | https://github.com/renepickhardt/metalcon/blob/26a7bd89d2225fe2172dc958d10f64a1bd9cf52f/graphityServer/src/main/java/de/metalcon/server/tomcat/NSSP/create/follow/CreateFollowRequest.java#L74-L89 | train |
recruit-mp/android-HeaderFooterGridView | library/src/main/java/jp/co/recruit_mp/android/headerfootergridview/HeaderFooterGridView.java | HeaderFooterGridView.removeFooterView | public boolean removeFooterView(View v) {
if (mFooterViewInfos.size() > 0) {
boolean result = false;
ListAdapter adapter = getAdapter();
if (adapter != null && ((HeaderFooterViewGridAdapter) adapter).removeFooter(v)) {
result = true;
}
removeFixedViewInfo(v, mFooterViewInfos);
return result;
}
return false;
} | java | public boolean removeFooterView(View v) {
if (mFooterViewInfos.size() > 0) {
boolean result = false;
ListAdapter adapter = getAdapter();
if (adapter != null && ((HeaderFooterViewGridAdapter) adapter).removeFooter(v)) {
result = true;
}
removeFixedViewInfo(v, mFooterViewInfos);
return result;
}
return false;
} | [
"public",
"boolean",
"removeFooterView",
"(",
"View",
"v",
")",
"{",
"if",
"(",
"mFooterViewInfos",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"ListAdapter",
"adapter",
"=",
"getAdapter",
"(",
")",
";",
"if",
"("... | Removes a previously-added footer view.
@param v The view to remove
@return true if the view was removed, false if the view was not a footer view | [
"Removes",
"a",
"previously",
"-",
"added",
"footer",
"view",
"."
] | a3deb03fffaa5b7e6723994b8b79b4c8e3e54c34 | https://github.com/recruit-mp/android-HeaderFooterGridView/blob/a3deb03fffaa5b7e6723994b8b79b4c8e3e54c34/library/src/main/java/jp/co/recruit_mp/android/headerfootergridview/HeaderFooterGridView.java#L252-L263 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.reserve | public Messages reserve(int numberOfMessages, int timeout, int wait) throws IOException {
if (numberOfMessages < 1 || numberOfMessages > 100) {
throw new IllegalArgumentException("numberOfMessages has to be within 1..100");
}
MessagesReservationModel payload = new MessagesReservationModel(numberOfMessages, timeout, wait);
String url = "queues/" + name + "/reservations";
IronReader reader = client.post(url, gson.toJson(payload));
Messages messages = gson.fromJson(reader.reader, Messages.class);
reader.close();
return messages;
} | java | public Messages reserve(int numberOfMessages, int timeout, int wait) throws IOException {
if (numberOfMessages < 1 || numberOfMessages > 100) {
throw new IllegalArgumentException("numberOfMessages has to be within 1..100");
}
MessagesReservationModel payload = new MessagesReservationModel(numberOfMessages, timeout, wait);
String url = "queues/" + name + "/reservations";
IronReader reader = client.post(url, gson.toJson(payload));
Messages messages = gson.fromJson(reader.reader, Messages.class);
reader.close();
return messages;
} | [
"public",
"Messages",
"reserve",
"(",
"int",
"numberOfMessages",
",",
"int",
"timeout",
",",
"int",
"wait",
")",
"throws",
"IOException",
"{",
"if",
"(",
"numberOfMessages",
"<",
"1",
"||",
"numberOfMessages",
">",
"100",
")",
"{",
"throw",
"new",
"IllegalAr... | Retrieves Messages from the queue and reserves it. If there are no items on the queue, an
EmptyQueueException is thrown.
@param numberOfMessages The number of messages to receive. Max. is 100.
@param timeout timeout in seconds.
@param wait Time to long poll for messages, in seconds. Max is 30 seconds. Default 0.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Retrieves",
"Messages",
"from",
"the",
"queue",
"and",
"reserves",
"it",
".",
"If",
"there",
"are",
"no",
"items",
"on",
"the",
"queue",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L118-L129 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.peek | public Message peek() throws IOException {
Messages msgs = peek(1);
Message msg;
try {
msg = msgs.getMessage(0);
} catch (IndexOutOfBoundsException e) {
throw new EmptyQueueException();
}
return msg;
} | java | public Message peek() throws IOException {
Messages msgs = peek(1);
Message msg;
try {
msg = msgs.getMessage(0);
} catch (IndexOutOfBoundsException e) {
throw new EmptyQueueException();
}
return msg;
} | [
"public",
"Message",
"peek",
"(",
")",
"throws",
"IOException",
"{",
"Messages",
"msgs",
"=",
"peek",
"(",
"1",
")",
";",
"Message",
"msg",
";",
"try",
"{",
"msg",
"=",
"msgs",
".",
"getMessage",
"(",
"0",
")",
";",
"}",
"catch",
"(",
"IndexOutOfBoun... | Peeking at a queue returns the next messages on the queue, but it does not reserve them.
If there are no items on the queue, an EmptyQueueException is thrown.
@throws io.iron.ironmq.EmptyQueueException If the queue is empty.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Peeking",
"at",
"a",
"queue",
"returns",
"the",
"next",
"messages",
"on",
"the",
"queue",
"but",
"it",
"does",
"not",
"reserve",
"them",
".",
"If",
"there",
"are",
"no",
"items",
"on",
"the",
"queue",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L139-L149 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.peek | public Messages peek(int numberOfMessages) throws IOException {
if (numberOfMessages < 1 || numberOfMessages > 100) {
throw new IllegalArgumentException("numberOfMessages has to be within 1..100");
}
IronReader reader = client.get("queues/" + name + "/messages?n=" + numberOfMessages);
try {
return gson.fromJson(reader.reader, Messages.class);
} finally {
reader.close();
}
} | java | public Messages peek(int numberOfMessages) throws IOException {
if (numberOfMessages < 1 || numberOfMessages > 100) {
throw new IllegalArgumentException("numberOfMessages has to be within 1..100");
}
IronReader reader = client.get("queues/" + name + "/messages?n=" + numberOfMessages);
try {
return gson.fromJson(reader.reader, Messages.class);
} finally {
reader.close();
}
} | [
"public",
"Messages",
"peek",
"(",
"int",
"numberOfMessages",
")",
"throws",
"IOException",
"{",
"if",
"(",
"numberOfMessages",
"<",
"1",
"||",
"numberOfMessages",
">",
"100",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"numberOfMessages has to be w... | Peeking at a queue returns the next messages on the queue, but it does not reserve them.
@param numberOfMessages The maximum number of messages to peek. Default is 1. Maximum is 100. Note: You may not
receive all n messages on every request, the more sparse the queue, the less likely
you are to receive all n messages.
@throws io.iron.ironmq.EmptyQueueException If the queue is empty.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Peeking",
"at",
"a",
"queue",
"returns",
"the",
"next",
"messages",
"on",
"the",
"queue",
"but",
"it",
"does",
"not",
"reserve",
"them",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L161-L171 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.touchMessage | public MessageOptions touchMessage(String id, String reservationId, int timeout) throws IOException {
return touchMessage(id, reservationId, (long) timeout);
} | java | public MessageOptions touchMessage(String id, String reservationId, int timeout) throws IOException {
return touchMessage(id, reservationId, (long) timeout);
} | [
"public",
"MessageOptions",
"touchMessage",
"(",
"String",
"id",
",",
"String",
"reservationId",
",",
"int",
"timeout",
")",
"throws",
"IOException",
"{",
"return",
"touchMessage",
"(",
"id",
",",
"reservationId",
",",
"(",
"long",
")",
"timeout",
")",
";",
... | Touching a reserved message extends its timeout to the specified duration.
@param id The ID of the message to delete.
@param reservationId This id is returned when you reserve a message and must be provided to delete a message that is reserved.
@param timeout After timeout (in seconds), item will be placed back onto queue.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Touching",
"a",
"reserved",
"message",
"extends",
"its",
"timeout",
"to",
"the",
"specified",
"duration",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L236-L238 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.push | public String push(String msg, long delay) throws IOException {
Message message = new Message();
message.setBody(msg);
message.setDelay(delay);
Messages msgs = new Messages(message);
IronReader reader = client.post("queues/" + name + "/messages", msgs);
Ids ids = gson.fromJson(reader.reader, Ids.class);
reader.close();
return ids.getId(0);
} | java | public String push(String msg, long delay) throws IOException {
Message message = new Message();
message.setBody(msg);
message.setDelay(delay);
Messages msgs = new Messages(message);
IronReader reader = client.post("queues/" + name + "/messages", msgs);
Ids ids = gson.fromJson(reader.reader, Ids.class);
reader.close();
return ids.getId(0);
} | [
"public",
"String",
"push",
"(",
"String",
"msg",
",",
"long",
"delay",
")",
"throws",
"IOException",
"{",
"Message",
"message",
"=",
"new",
"Message",
"(",
")",
";",
"message",
".",
"setBody",
"(",
"msg",
")",
";",
"message",
".",
"setDelay",
"(",
"de... | Pushes a message onto the queue.
@param msg The body of the message to push.
@param delay The message's delay in seconds.
@return The new message's ID
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Pushes",
"a",
"message",
"onto",
"the",
"queue",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L389-L400 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.pushMessages | public Ids pushMessages(String[] msg, long delay) throws IOException {
ArrayList<Message> messages = new ArrayList<Message>();
for (String messageName: msg){
Message message = new Message();
message.setBody(messageName);
message.setDelay(delay);
messages.add(message);
}
MessagesArrayList msgs = new MessagesArrayList(messages);
IronReader reader = client.post("queues/" + name + "/messages", msgs);
Ids ids = gson.fromJson(reader.reader, Ids.class);
reader.close();
return ids;
} | java | public Ids pushMessages(String[] msg, long delay) throws IOException {
ArrayList<Message> messages = new ArrayList<Message>();
for (String messageName: msg){
Message message = new Message();
message.setBody(messageName);
message.setDelay(delay);
messages.add(message);
}
MessagesArrayList msgs = new MessagesArrayList(messages);
IronReader reader = client.post("queues/" + name + "/messages", msgs);
Ids ids = gson.fromJson(reader.reader, Ids.class);
reader.close();
return ids;
} | [
"public",
"Ids",
"pushMessages",
"(",
"String",
"[",
"]",
"msg",
",",
"long",
"delay",
")",
"throws",
"IOException",
"{",
"ArrayList",
"<",
"Message",
">",
"messages",
"=",
"new",
"ArrayList",
"<",
"Message",
">",
"(",
")",
";",
"for",
"(",
"String",
"... | Pushes a messages onto the queue.
@param msg The array of the messages to push.
@param delay The message's delay in seconds.
@return The IDs of new messages
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Pushes",
"a",
"messages",
"onto",
"the",
"queue",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L412-L427 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.getInfoAboutQueue | public QueueModel getInfoAboutQueue() throws IOException {
IronReader reader = client.get("queues/" + name);
QueueContainer queueContainer = gson.fromJson(reader.reader, QueueContainer.class);
reader.close();
return queueContainer.getQueue();
} | java | public QueueModel getInfoAboutQueue() throws IOException {
IronReader reader = client.get("queues/" + name);
QueueContainer queueContainer = gson.fromJson(reader.reader, QueueContainer.class);
reader.close();
return queueContainer.getQueue();
} | [
"public",
"QueueModel",
"getInfoAboutQueue",
"(",
")",
"throws",
"IOException",
"{",
"IronReader",
"reader",
"=",
"client",
".",
"get",
"(",
"\"queues/\"",
"+",
"name",
")",
";",
"QueueContainer",
"queueContainer",
"=",
"gson",
".",
"fromJson",
"(",
"reader",
... | Retrieves Info about queue. If there is no queue, an EmptyQueueException is thrown.
@throws io.iron.ironmq.EmptyQueueException If there is no queue.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Retrieves",
"Info",
"about",
"queue",
".",
"If",
"there",
"is",
"no",
"queue",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L451-L456 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.getMessageById | public Message getMessageById(String id) throws IOException {
String url = "queues/" + name + "/messages/" + id;
IronReader reader = client.get(url);
MessageContainer container = gson.fromJson(reader.reader, MessageContainer.class);
reader.close();
return container.getMessage();
} | java | public Message getMessageById(String id) throws IOException {
String url = "queues/" + name + "/messages/" + id;
IronReader reader = client.get(url);
MessageContainer container = gson.fromJson(reader.reader, MessageContainer.class);
reader.close();
return container.getMessage();
} | [
"public",
"Message",
"getMessageById",
"(",
"String",
"id",
")",
"throws",
"IOException",
"{",
"String",
"url",
"=",
"\"queues/\"",
"+",
"name",
"+",
"\"/messages/\"",
"+",
"id",
";",
"IronReader",
"reader",
"=",
"client",
".",
"get",
"(",
"url",
")",
";",... | Retrieves Message from the queue by message id. If there are no items on the queue, an
EmptyQueueException is thrown.
@param id The ID of the message to get.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Retrieves",
"Message",
"from",
"the",
"queue",
"by",
"message",
"id",
".",
"If",
"there",
"are",
"no",
"items",
"on",
"the",
"queue",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L465-L471 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.addSubscribers | public void addSubscribers(Subscribers subscribers) throws IOException {
String payload = gson.toJson(subscribers);
IronReader reader = client.post("queues/" + name + "/subscribers", payload);
reader.close();
} | java | public void addSubscribers(Subscribers subscribers) throws IOException {
String payload = gson.toJson(subscribers);
IronReader reader = client.post("queues/" + name + "/subscribers", payload);
reader.close();
} | [
"public",
"void",
"addSubscribers",
"(",
"Subscribers",
"subscribers",
")",
"throws",
"IOException",
"{",
"String",
"payload",
"=",
"gson",
".",
"toJson",
"(",
"subscribers",
")",
";",
"IronReader",
"reader",
"=",
"client",
".",
"post",
"(",
"\"queues/\"",
"+"... | Add subscribers to Queue. If there is no queue, an EmptyQueueException is thrown.
@param subscribers The array of subscribers.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Add",
"subscribers",
"to",
"Queue",
".",
"If",
"there",
"is",
"no",
"queue",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L550-L554 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.replaceSubscribers | public void replaceSubscribers(Subscribers subscribers) throws IOException {
String payload = gson.toJson(subscribers);
IronReader reader = client.put("queues/" + name + "/subscribers", payload);
reader.close();
} | java | public void replaceSubscribers(Subscribers subscribers) throws IOException {
String payload = gson.toJson(subscribers);
IronReader reader = client.put("queues/" + name + "/subscribers", payload);
reader.close();
} | [
"public",
"void",
"replaceSubscribers",
"(",
"Subscribers",
"subscribers",
")",
"throws",
"IOException",
"{",
"String",
"payload",
"=",
"gson",
".",
"toJson",
"(",
"subscribers",
")",
";",
"IronReader",
"reader",
"=",
"client",
".",
"put",
"(",
"\"queues/\"",
... | Sets list of subscribers to a queue. Older subscribers will be removed.
If there is no queue, an EmptyQueueException is thrown.
@param subscribers The array of subscribers.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Sets",
"list",
"of",
"subscribers",
"to",
"a",
"queue",
".",
"Older",
"subscribers",
"will",
"be",
"removed",
".",
"If",
"there",
"is",
"no",
"queue",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L615-L619 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.removeSubscribers | public void removeSubscribers(Subscribers subscribers) throws IOException {
String url = "queues/" + name + "/subscribers";
String jsonMessages = gson.toJson(subscribers);
IronReader reader = client.delete(url, jsonMessages);
reader.close();
} | java | public void removeSubscribers(Subscribers subscribers) throws IOException {
String url = "queues/" + name + "/subscribers";
String jsonMessages = gson.toJson(subscribers);
IronReader reader = client.delete(url, jsonMessages);
reader.close();
} | [
"public",
"void",
"removeSubscribers",
"(",
"Subscribers",
"subscribers",
")",
"throws",
"IOException",
"{",
"String",
"url",
"=",
"\"queues/\"",
"+",
"name",
"+",
"\"/subscribers\"",
";",
"String",
"jsonMessages",
"=",
"gson",
".",
"toJson",
"(",
"subscribers",
... | Remove subscribers from Queue. If there is no queue, an EmptyQueueException is thrown.
@param subscribers The array list of subscribers.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Remove",
"subscribers",
"from",
"Queue",
".",
"If",
"there",
"is",
"no",
"queue",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L647-L652 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.getPushStatusForMessage | public SubscribersInfo getPushStatusForMessage(String messageId) throws IOException {
String url = "queues/" + name + "/messages/" + messageId + "/subscribers";
IronReader reader = client.get(url);
SubscribersInfo subscribersInfo = gson.fromJson(reader.reader, SubscribersInfo.class);
reader.close();
return subscribersInfo;
} | java | public SubscribersInfo getPushStatusForMessage(String messageId) throws IOException {
String url = "queues/" + name + "/messages/" + messageId + "/subscribers";
IronReader reader = client.get(url);
SubscribersInfo subscribersInfo = gson.fromJson(reader.reader, SubscribersInfo.class);
reader.close();
return subscribersInfo;
} | [
"public",
"SubscribersInfo",
"getPushStatusForMessage",
"(",
"String",
"messageId",
")",
"throws",
"IOException",
"{",
"String",
"url",
"=",
"\"queues/\"",
"+",
"name",
"+",
"\"/messages/\"",
"+",
"messageId",
"+",
"\"/subscribers\"",
";",
"IronReader",
"reader",
"=... | Get push info of message by message id. If there is no message, an EmptyQueueException is thrown.
@param messageId The Message ID.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Get",
"push",
"info",
"of",
"message",
"by",
"message",
"id",
".",
"If",
"there",
"is",
"no",
"message",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L660-L666 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.deletePushMessageForSubscriber | public void deletePushMessageForSubscriber(String messageId, String reservationId, String subscriberName) throws IOException {
deleteMessage(messageId, reservationId, subscriberName);
} | java | public void deletePushMessageForSubscriber(String messageId, String reservationId, String subscriberName) throws IOException {
deleteMessage(messageId, reservationId, subscriberName);
} | [
"public",
"void",
"deletePushMessageForSubscriber",
"(",
"String",
"messageId",
",",
"String",
"reservationId",
",",
"String",
"subscriberName",
")",
"throws",
"IOException",
"{",
"deleteMessage",
"(",
"messageId",
",",
"reservationId",
",",
"subscriberName",
")",
";"... | Delete push message for subscriber by subscriber ID and message ID. If there is no message or subscriber,
an EmptyQueueException is thrown.
@param subscriberName The name of Subscriber.
@param messageId The Message ID.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Delete",
"push",
"message",
"for",
"subscriber",
"by",
"subscriber",
"ID",
"and",
"message",
"ID",
".",
"If",
"there",
"is",
"no",
"message",
"or",
"subscriber",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L676-L678 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.updateAlerts | public QueueModel updateAlerts(ArrayList<Alert> alerts) throws IOException {
QueueModel payload = new QueueModel(alerts);
return this.update(payload);
} | java | public QueueModel updateAlerts(ArrayList<Alert> alerts) throws IOException {
QueueModel payload = new QueueModel(alerts);
return this.update(payload);
} | [
"public",
"QueueModel",
"updateAlerts",
"(",
"ArrayList",
"<",
"Alert",
">",
"alerts",
")",
"throws",
"IOException",
"{",
"QueueModel",
"payload",
"=",
"new",
"QueueModel",
"(",
"alerts",
")",
";",
"return",
"this",
".",
"update",
"(",
"payload",
")",
";",
... | Replace current queue alerts with a given list of alerts. If there is no queue, an EmptyQueueException is thrown.
@param alerts The array list of alerts.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Replace",
"current",
"queue",
"alerts",
"with",
"a",
"given",
"list",
"of",
"alerts",
".",
"If",
"there",
"is",
"no",
"queue",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L813-L816 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.deleteAlertsFromQueue | public void deleteAlertsFromQueue(ArrayList<Alert> alert_ids) throws IOException {
String url = "queues/" + name + "/alerts";
Alerts alert = new Alerts(alert_ids);
String jsonMessages = gson.toJson(alert);
IronReader reader = client.delete(url, jsonMessages);
reader.close();
} | java | public void deleteAlertsFromQueue(ArrayList<Alert> alert_ids) throws IOException {
String url = "queues/" + name + "/alerts";
Alerts alert = new Alerts(alert_ids);
String jsonMessages = gson.toJson(alert);
IronReader reader = client.delete(url, jsonMessages);
reader.close();
} | [
"public",
"void",
"deleteAlertsFromQueue",
"(",
"ArrayList",
"<",
"Alert",
">",
"alert_ids",
")",
"throws",
"IOException",
"{",
"String",
"url",
"=",
"\"queues/\"",
"+",
"name",
"+",
"\"/alerts\"",
";",
"Alerts",
"alert",
"=",
"new",
"Alerts",
"(",
"alert_ids"... | Delete alerts from a queue. If there is no queue, an EmptyQueueException is thrown.
@param alert_ids The array list of alert ids.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Delete",
"alerts",
"from",
"a",
"queue",
".",
"If",
"there",
"is",
"no",
"queue",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L824-L830 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.deleteAlertFromQueueById | public void deleteAlertFromQueueById(String alert_id) throws IOException {
String url = "queues/" + name + "/alerts/" + alert_id;
IronReader reader = client.delete(url);
reader.close();
} | java | public void deleteAlertFromQueueById(String alert_id) throws IOException {
String url = "queues/" + name + "/alerts/" + alert_id;
IronReader reader = client.delete(url);
reader.close();
} | [
"public",
"void",
"deleteAlertFromQueueById",
"(",
"String",
"alert_id",
")",
"throws",
"IOException",
"{",
"String",
"url",
"=",
"\"queues/\"",
"+",
"name",
"+",
"\"/alerts/\"",
"+",
"alert_id",
";",
"IronReader",
"reader",
"=",
"client",
".",
"delete",
"(",
... | Delete alert from a queue by alert id. If there is no queue, an EmptyQueueException is thrown.
@param alert_id The alert id.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Delete",
"alert",
"from",
"a",
"queue",
"by",
"alert",
"id",
".",
"If",
"there",
"is",
"no",
"queue",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L838-L842 | train |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/keystone/Token.java | Token.isExpired | public boolean isExpired(int seconds) {
long diff = localIssuedAt.getTime() - issuedAt.getTime();
long localExpiresAtTime = expiresAt.getTime() + diff;
return (new Date().getTime() - seconds * 1000) >= localExpiresAtTime;
} | java | public boolean isExpired(int seconds) {
long diff = localIssuedAt.getTime() - issuedAt.getTime();
long localExpiresAtTime = expiresAt.getTime() + diff;
return (new Date().getTime() - seconds * 1000) >= localExpiresAtTime;
} | [
"public",
"boolean",
"isExpired",
"(",
"int",
"seconds",
")",
"{",
"long",
"diff",
"=",
"localIssuedAt",
".",
"getTime",
"(",
")",
"-",
"issuedAt",
".",
"getTime",
"(",
")",
";",
"long",
"localExpiresAtTime",
"=",
"expiresAt",
".",
"getTime",
"(",
")",
"... | Indicated if token will expire after N seconds.
@param seconds Number of seconds | [
"Indicated",
"if",
"token",
"will",
"expire",
"after",
"N",
"seconds",
"."
] | 62d6a86545ca7ef31b7b4797aae0c5b31394a507 | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/keystone/Token.java#L62-L66 | train |
goodow/realtime-channel | src/main/java/com/goodow/realtime/channel/impl/ReliableSubscribeBus.java | ReliableSubscribeBus.scheduleAcknowledgment | private void scheduleAcknowledgment(final String topic) {
if (!acknowledgeScheduled.has(topic)) {
acknowledgeScheduled.set(topic, true);
Platform.scheduler().scheduleDelay(acknowledgeDelayMillis, new Handler<Void>() {
@Override
public void handle(Void event) {
if (acknowledgeScheduled.has(topic)) {
acknowledgeScheduled.remove(topic);
// Check we're still out of date, and not already catching up.
double knownHeadSequence = knownHeadSequences.getNumber(topic);
double currentSequence = currentSequences.getNumber(topic);
if (knownHeadSequence > currentSequence
&& (!acknowledgeNumbers.has(topic) || knownHeadSequence > acknowledgeNumbers
.getNumber(topic))) {
acknowledgeNumbers.set(topic, knownHeadSequence);
log.log(Level.CONFIG, "Catching up to " + knownHeadSequence);
catchup(topic, currentSequence);
} else {
log.log(Level.FINE, "No need to catchup");
}
}
}
});
}
} | java | private void scheduleAcknowledgment(final String topic) {
if (!acknowledgeScheduled.has(topic)) {
acknowledgeScheduled.set(topic, true);
Platform.scheduler().scheduleDelay(acknowledgeDelayMillis, new Handler<Void>() {
@Override
public void handle(Void event) {
if (acknowledgeScheduled.has(topic)) {
acknowledgeScheduled.remove(topic);
// Check we're still out of date, and not already catching up.
double knownHeadSequence = knownHeadSequences.getNumber(topic);
double currentSequence = currentSequences.getNumber(topic);
if (knownHeadSequence > currentSequence
&& (!acknowledgeNumbers.has(topic) || knownHeadSequence > acknowledgeNumbers
.getNumber(topic))) {
acknowledgeNumbers.set(topic, knownHeadSequence);
log.log(Level.CONFIG, "Catching up to " + knownHeadSequence);
catchup(topic, currentSequence);
} else {
log.log(Level.FINE, "No need to catchup");
}
}
}
});
}
} | [
"private",
"void",
"scheduleAcknowledgment",
"(",
"final",
"String",
"topic",
")",
"{",
"if",
"(",
"!",
"acknowledgeScheduled",
".",
"has",
"(",
"topic",
")",
")",
"{",
"acknowledgeScheduled",
".",
"set",
"(",
"topic",
",",
"true",
")",
";",
"Platform",
".... | Acknowledgment Number is the next sequence number that the receiver is expecting | [
"Acknowledgment",
"Number",
"is",
"the",
"next",
"sequence",
"number",
"that",
"the",
"receiver",
"is",
"expecting"
] | 695a5d2035857404d053f7ec698176ff92c8b1e2 | https://github.com/goodow/realtime-channel/blob/695a5d2035857404d053f7ec698176ff92c8b1e2/src/main/java/com/goodow/realtime/channel/impl/ReliableSubscribeBus.java#L208-L232 | train |
goodow/realtime-channel | src/main/java/com/goodow/realtime/core/impl/FutureResultImpl.java | FutureResultImpl.setFailure | @Override
public FutureResultImpl<T> setFailure(Throwable throwable) {
this.throwable = throwable;
failed = true;
checkCallHandler();
return this;
} | java | @Override
public FutureResultImpl<T> setFailure(Throwable throwable) {
this.throwable = throwable;
failed = true;
checkCallHandler();
return this;
} | [
"@",
"Override",
"public",
"FutureResultImpl",
"<",
"T",
">",
"setFailure",
"(",
"Throwable",
"throwable",
")",
"{",
"this",
".",
"throwable",
"=",
"throwable",
";",
"failed",
"=",
"true",
";",
"checkCallHandler",
"(",
")",
";",
"return",
"this",
";",
"}"
... | Set the failure. Any handler will be called, if there is one | [
"Set",
"the",
"failure",
".",
"Any",
"handler",
"will",
"be",
"called",
"if",
"there",
"is",
"one"
] | 695a5d2035857404d053f7ec698176ff92c8b1e2 | https://github.com/goodow/realtime-channel/blob/695a5d2035857404d053f7ec698176ff92c8b1e2/src/main/java/com/goodow/realtime/core/impl/FutureResultImpl.java#L90-L96 | train |
goodow/realtime-channel | src/main/java/com/goodow/realtime/core/impl/FutureResultImpl.java | FutureResultImpl.setHandler | @Override
public FutureResultImpl<T> setHandler(Handler<AsyncResult<T>> handler) {
this.handler = handler;
checkCallHandler();
return this;
} | java | @Override
public FutureResultImpl<T> setHandler(Handler<AsyncResult<T>> handler) {
this.handler = handler;
checkCallHandler();
return this;
} | [
"@",
"Override",
"public",
"FutureResultImpl",
"<",
"T",
">",
"setHandler",
"(",
"Handler",
"<",
"AsyncResult",
"<",
"T",
">",
">",
"handler",
")",
"{",
"this",
".",
"handler",
"=",
"handler",
";",
"checkCallHandler",
"(",
")",
";",
"return",
"this",
";"... | Set a handler for the result. It will get called when it's complete | [
"Set",
"a",
"handler",
"for",
"the",
"result",
".",
"It",
"will",
"get",
"called",
"when",
"it",
"s",
"complete"
] | 695a5d2035857404d053f7ec698176ff92c8b1e2 | https://github.com/goodow/realtime-channel/blob/695a5d2035857404d053f7ec698176ff92c8b1e2/src/main/java/com/goodow/realtime/core/impl/FutureResultImpl.java#L101-L106 | train |
goodow/realtime-channel | src/main/java/com/goodow/realtime/core/impl/FutureResultImpl.java | FutureResultImpl.setResult | @Override
public FutureResultImpl<T> setResult(T result) {
this.result = result;
succeeded = true;
checkCallHandler();
return this;
} | java | @Override
public FutureResultImpl<T> setResult(T result) {
this.result = result;
succeeded = true;
checkCallHandler();
return this;
} | [
"@",
"Override",
"public",
"FutureResultImpl",
"<",
"T",
">",
"setResult",
"(",
"T",
"result",
")",
"{",
"this",
".",
"result",
"=",
"result",
";",
"succeeded",
"=",
"true",
";",
"checkCallHandler",
"(",
")",
";",
"return",
"this",
";",
"}"
] | Set the result. Any handler will be called, if there is one | [
"Set",
"the",
"result",
".",
"Any",
"handler",
"will",
"be",
"called",
"if",
"there",
"is",
"one"
] | 695a5d2035857404d053f7ec698176ff92c8b1e2 | https://github.com/goodow/realtime-channel/blob/695a5d2035857404d053f7ec698176ff92c8b1e2/src/main/java/com/goodow/realtime/core/impl/FutureResultImpl.java#L111-L117 | train |
goodow/realtime-channel | src/main/java/com/goodow/realtime/channel/util/FuzzingBackOffGenerator.java | FuzzingBackOffGenerator.next | public BackOffParameters next() {
int ret = Math.min(nextBackOffTime, maxBackOff);
nextBackOffTime += backOffTime;
if (nextBackOffTime <= 0) {
nextBackOffTime = Integer.MAX_VALUE;
}
backOffTime = ret;
int randomizeTime = (int) (backOffTime * (1.0 + (Math.random() * randomizationFactor)));
int minAllowedTime = (int) Math.round(randomizeTime - backOffTime * randomizationFactor);
return new BackOffParameters(randomizeTime, minAllowedTime);
} | java | public BackOffParameters next() {
int ret = Math.min(nextBackOffTime, maxBackOff);
nextBackOffTime += backOffTime;
if (nextBackOffTime <= 0) {
nextBackOffTime = Integer.MAX_VALUE;
}
backOffTime = ret;
int randomizeTime = (int) (backOffTime * (1.0 + (Math.random() * randomizationFactor)));
int minAllowedTime = (int) Math.round(randomizeTime - backOffTime * randomizationFactor);
return new BackOffParameters(randomizeTime, minAllowedTime);
} | [
"public",
"BackOffParameters",
"next",
"(",
")",
"{",
"int",
"ret",
"=",
"Math",
".",
"min",
"(",
"nextBackOffTime",
",",
"maxBackOff",
")",
";",
"nextBackOffTime",
"+=",
"backOffTime",
";",
"if",
"(",
"nextBackOffTime",
"<=",
"0",
")",
"{",
"nextBackOffTime... | Gets the next back off time. Until maxBackOff is reached. | [
"Gets",
"the",
"next",
"back",
"off",
"time",
".",
"Until",
"maxBackOff",
"is",
"reached",
"."
] | 695a5d2035857404d053f7ec698176ff92c8b1e2 | https://github.com/goodow/realtime-channel/blob/695a5d2035857404d053f7ec698176ff92c8b1e2/src/main/java/com/goodow/realtime/channel/util/FuzzingBackOffGenerator.java#L67-L79 | train |
jboss/jboss-jstl-api_spec | src/main/java/javax/servlet/jsp/jstl/core/IteratedExpression.java | IteratedExpression.getItem | public Object getItem(ELContext context, int i) {
if (originalListObject == null) {
originalListObject = orig.getValue(context);
if (originalListObject instanceof Collection) {
type = TypesEnum.ACollection;
} else if (originalListObject instanceof Iterator) {
type = TypesEnum.AnIterator;
} else if (originalListObject instanceof Enumeration) {
type = TypesEnum.AnEnumeration;
} else if (originalListObject instanceof Map) {
type = TypesEnum.AMap;
} else if (originalListObject instanceof String) { //StringTokens
type = TypesEnum.AString;
} else {
//it's of some other type ... should never get here
throw new RuntimeException("IteratedExpression.getItem: Object not of correct type.");
}
currentListObject = returnNewIterator(originalListObject, type);
}
Object currentObject = null;
if (i < currentIndex) {
currentListObject = returnNewIterator(originalListObject, type);
currentIndex = 0;
}
for (; currentIndex <= i; currentIndex++) {
if (currentListObject.hasNext()) {
currentObject = currentListObject.next();
} else {
throw new RuntimeException("IteratedExpression.getItem: Index out of Bounds");
}
}
return currentObject;
} | java | public Object getItem(ELContext context, int i) {
if (originalListObject == null) {
originalListObject = orig.getValue(context);
if (originalListObject instanceof Collection) {
type = TypesEnum.ACollection;
} else if (originalListObject instanceof Iterator) {
type = TypesEnum.AnIterator;
} else if (originalListObject instanceof Enumeration) {
type = TypesEnum.AnEnumeration;
} else if (originalListObject instanceof Map) {
type = TypesEnum.AMap;
} else if (originalListObject instanceof String) { //StringTokens
type = TypesEnum.AString;
} else {
//it's of some other type ... should never get here
throw new RuntimeException("IteratedExpression.getItem: Object not of correct type.");
}
currentListObject = returnNewIterator(originalListObject, type);
}
Object currentObject = null;
if (i < currentIndex) {
currentListObject = returnNewIterator(originalListObject, type);
currentIndex = 0;
}
for (; currentIndex <= i; currentIndex++) {
if (currentListObject.hasNext()) {
currentObject = currentListObject.next();
} else {
throw new RuntimeException("IteratedExpression.getItem: Index out of Bounds");
}
}
return currentObject;
} | [
"public",
"Object",
"getItem",
"(",
"ELContext",
"context",
",",
"int",
"i",
")",
"{",
"if",
"(",
"originalListObject",
"==",
"null",
")",
"{",
"originalListObject",
"=",
"orig",
".",
"getValue",
"(",
"context",
")",
";",
"if",
"(",
"originalListObject",
"... | Iterates the original expression and returns the value at the index.
@param context against which the expression should be evaluated
@param i the index of the value to return
@return the value at the index | [
"Iterates",
"the",
"original",
"expression",
"and",
"returns",
"the",
"value",
"at",
"the",
"index",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/javax/servlet/jsp/jstl/core/IteratedExpression.java#L68-L100 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/tag/common/xml/ParseSupport.java | ParseSupport.doEndTag | @Override
public int doEndTag() throws JspException {
// produce a Document by parsing whatever the attributes tell us to use
Object xmlText = this.xml;
if (xmlText == null) {
// if the attribute was specified, use the body as 'xml'
if (bodyContent != null && bodyContent.getString() != null) {
xmlText = bodyContent.getString().trim();
} else {
xmlText = "";
}
}
if (xmlText instanceof String) {
xmlText = new StringReader((String) xmlText);
}
if (!(xmlText instanceof Reader)) {
throw new JspTagException(Resources.getMessage("PARSE_INVALID_SOURCE"));
}
InputSource source = XmlUtil.newInputSource(((Reader) xmlText), systemId);
Document d;
if (filter != null) {
d = parseInputSourceWithFilter(source, filter);
} else {
d = parseInputSource(source);
}
// we've got a Document object; store it out as appropriate
// (let any exclusivity or other constraints be enforced by TEI/TLV)
if (var != null) {
pageContext.setAttribute(var, d, scope);
}
if (varDom != null) {
pageContext.setAttribute(varDom, d, scopeDom);
}
return EVAL_PAGE;
} | java | @Override
public int doEndTag() throws JspException {
// produce a Document by parsing whatever the attributes tell us to use
Object xmlText = this.xml;
if (xmlText == null) {
// if the attribute was specified, use the body as 'xml'
if (bodyContent != null && bodyContent.getString() != null) {
xmlText = bodyContent.getString().trim();
} else {
xmlText = "";
}
}
if (xmlText instanceof String) {
xmlText = new StringReader((String) xmlText);
}
if (!(xmlText instanceof Reader)) {
throw new JspTagException(Resources.getMessage("PARSE_INVALID_SOURCE"));
}
InputSource source = XmlUtil.newInputSource(((Reader) xmlText), systemId);
Document d;
if (filter != null) {
d = parseInputSourceWithFilter(source, filter);
} else {
d = parseInputSource(source);
}
// we've got a Document object; store it out as appropriate
// (let any exclusivity or other constraints be enforced by TEI/TLV)
if (var != null) {
pageContext.setAttribute(var, d, scope);
}
if (varDom != null) {
pageContext.setAttribute(varDom, d, scopeDom);
}
return EVAL_PAGE;
} | [
"@",
"Override",
"public",
"int",
"doEndTag",
"(",
")",
"throws",
"JspException",
"{",
"// produce a Document by parsing whatever the attributes tell us to use",
"Object",
"xmlText",
"=",
"this",
".",
"xml",
";",
"if",
"(",
"xmlText",
"==",
"null",
")",
"{",
"// if ... | parse 'source' or body, storing result in 'var' | [
"parse",
"source",
"or",
"body",
"storing",
"result",
"in",
"var"
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/tag/common/xml/ParseSupport.java#L89-L126 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/tag/common/xml/ParseSupport.java | ParseSupport.parseInputSourceWithFilter | private Document parseInputSourceWithFilter(InputSource s, XMLFilter f) throws JspException {
try {
XMLReader xr = XmlUtil.newXMLReader(entityResolver);
// (note that we overwrite the filter's parent. this seems
// to be expected usage. we could cache and reset the old
// parent, but you can't setParent(null), so this wouldn't
// be perfect.)
f.setParent(xr);
TransformerHandler th = XmlUtil.newTransformerHandler();
Document o = XmlUtil.newEmptyDocument();
th.setResult(new DOMResult(o));
f.setContentHandler(th);
f.parse(s);
return o;
} catch (IOException e) {
throw new JspException(e);
} catch (SAXException e) {
throw new JspException(e);
} catch (TransformerConfigurationException e) {
throw new JspException(e);
} catch (ParserConfigurationException e) {
throw new JspException(e);
}
} | java | private Document parseInputSourceWithFilter(InputSource s, XMLFilter f) throws JspException {
try {
XMLReader xr = XmlUtil.newXMLReader(entityResolver);
// (note that we overwrite the filter's parent. this seems
// to be expected usage. we could cache and reset the old
// parent, but you can't setParent(null), so this wouldn't
// be perfect.)
f.setParent(xr);
TransformerHandler th = XmlUtil.newTransformerHandler();
Document o = XmlUtil.newEmptyDocument();
th.setResult(new DOMResult(o));
f.setContentHandler(th);
f.parse(s);
return o;
} catch (IOException e) {
throw new JspException(e);
} catch (SAXException e) {
throw new JspException(e);
} catch (TransformerConfigurationException e) {
throw new JspException(e);
} catch (ParserConfigurationException e) {
throw new JspException(e);
}
} | [
"private",
"Document",
"parseInputSourceWithFilter",
"(",
"InputSource",
"s",
",",
"XMLFilter",
"f",
")",
"throws",
"JspException",
"{",
"try",
"{",
"XMLReader",
"xr",
"=",
"XmlUtil",
".",
"newXMLReader",
"(",
"entityResolver",
")",
";",
"// (note that we overwrit... | Parses the given InputSource after, applying the given XMLFilter. | [
"Parses",
"the",
"given",
"InputSource",
"after",
"applying",
"the",
"given",
"XMLFilter",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/tag/common/xml/ParseSupport.java#L142-L167 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/tag/common/xml/ParseSupport.java | ParseSupport.parseInputSource | private Document parseInputSource(InputSource s) throws JspException {
try {
DocumentBuilder db = XmlUtil.newDocumentBuilder();
db.setEntityResolver(entityResolver);
return db.parse(s);
} catch (SAXException e) {
throw new JspException(e);
} catch (IOException e) {
throw new JspException(e);
}
} | java | private Document parseInputSource(InputSource s) throws JspException {
try {
DocumentBuilder db = XmlUtil.newDocumentBuilder();
db.setEntityResolver(entityResolver);
return db.parse(s);
} catch (SAXException e) {
throw new JspException(e);
} catch (IOException e) {
throw new JspException(e);
}
} | [
"private",
"Document",
"parseInputSource",
"(",
"InputSource",
"s",
")",
"throws",
"JspException",
"{",
"try",
"{",
"DocumentBuilder",
"db",
"=",
"XmlUtil",
".",
"newDocumentBuilder",
"(",
")",
";",
"db",
".",
"setEntityResolver",
"(",
"entityResolver",
")",
";"... | Parses the given InputSource into a Document. | [
"Parses",
"the",
"given",
"InputSource",
"into",
"a",
"Document",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/tag/common/xml/ParseSupport.java#L172-L182 | train |
jboss/jboss-jstl-api_spec | src/main/java/javax/servlet/jsp/jstl/core/ConditionalTagSupport.java | ConditionalTagSupport.setScope | public void setScope(String scope) {
if (scope.equalsIgnoreCase("page")) {
this.scope = PageContext.PAGE_SCOPE;
} else if (scope.equalsIgnoreCase("request")) {
this.scope = PageContext.REQUEST_SCOPE;
} else if (scope.equalsIgnoreCase("session")) {
this.scope = PageContext.SESSION_SCOPE;
} else if (scope.equalsIgnoreCase("application")) {
this.scope = PageContext.APPLICATION_SCOPE;
}
// TODO: Add error handling? Needs direction from spec.
} | java | public void setScope(String scope) {
if (scope.equalsIgnoreCase("page")) {
this.scope = PageContext.PAGE_SCOPE;
} else if (scope.equalsIgnoreCase("request")) {
this.scope = PageContext.REQUEST_SCOPE;
} else if (scope.equalsIgnoreCase("session")) {
this.scope = PageContext.SESSION_SCOPE;
} else if (scope.equalsIgnoreCase("application")) {
this.scope = PageContext.APPLICATION_SCOPE;
}
// TODO: Add error handling? Needs direction from spec.
} | [
"public",
"void",
"setScope",
"(",
"String",
"scope",
")",
"{",
"if",
"(",
"scope",
".",
"equalsIgnoreCase",
"(",
"\"page\"",
")",
")",
"{",
"this",
".",
"scope",
"=",
"PageContext",
".",
"PAGE_SCOPE",
";",
"}",
"else",
"if",
"(",
"scope",
".",
"equals... | Sets the 'scope' attribute.
@param scope Scope of the 'var' attribute | [
"Sets",
"the",
"scope",
"attribute",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/javax/servlet/jsp/jstl/core/ConditionalTagSupport.java#L130-L141 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/tag/common/core/Util.java | Util.getContentTypeAttribute | public static String getContentTypeAttribute(String input, String name) {
int begin;
int end;
int index = input.toUpperCase().indexOf(name.toUpperCase());
if (index == -1) {
return null;
}
index = index + name.length(); // positioned after the attribute name
index = input.indexOf('=', index); // positioned at the '='
if (index == -1) {
return null;
}
index += 1; // positioned after the '='
input = input.substring(index).trim();
if (input.charAt(0) == '"') {
// attribute value is a quoted string
begin = 1;
end = input.indexOf('"', begin);
if (end == -1) {
return null;
}
} else {
begin = 0;
end = input.indexOf(';');
if (end == -1) {
end = input.indexOf(' ');
}
if (end == -1) {
end = input.length();
}
}
return input.substring(begin, end).trim();
} | java | public static String getContentTypeAttribute(String input, String name) {
int begin;
int end;
int index = input.toUpperCase().indexOf(name.toUpperCase());
if (index == -1) {
return null;
}
index = index + name.length(); // positioned after the attribute name
index = input.indexOf('=', index); // positioned at the '='
if (index == -1) {
return null;
}
index += 1; // positioned after the '='
input = input.substring(index).trim();
if (input.charAt(0) == '"') {
// attribute value is a quoted string
begin = 1;
end = input.indexOf('"', begin);
if (end == -1) {
return null;
}
} else {
begin = 0;
end = input.indexOf(';');
if (end == -1) {
end = input.indexOf(' ');
}
if (end == -1) {
end = input.length();
}
}
return input.substring(begin, end).trim();
} | [
"public",
"static",
"String",
"getContentTypeAttribute",
"(",
"String",
"input",
",",
"String",
"name",
")",
"{",
"int",
"begin",
";",
"int",
"end",
";",
"int",
"index",
"=",
"input",
".",
"toUpperCase",
"(",
")",
".",
"indexOf",
"(",
"name",
".",
"toUpp... | Get the value associated with a content-type attribute.
Syntax defined in RFC 2045, section 5.1. | [
"Get",
"the",
"value",
"associated",
"with",
"a",
"content",
"-",
"type",
"attribute",
".",
"Syntax",
"defined",
"in",
"RFC",
"2045",
"section",
"5",
".",
"1",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/tag/common/core/Util.java#L112-L145 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/lang/jstl/EnumeratedMap.java | EnumeratedMap.getAsMap | public Map getAsMap() {
if (mMap != null) {
return mMap;
} else {
Map m = convertToMap();
if (!isMutable()) {
mMap = m;
}
return m;
}
} | java | public Map getAsMap() {
if (mMap != null) {
return mMap;
} else {
Map m = convertToMap();
if (!isMutable()) {
mMap = m;
}
return m;
}
} | [
"public",
"Map",
"getAsMap",
"(",
")",
"{",
"if",
"(",
"mMap",
"!=",
"null",
")",
"{",
"return",
"mMap",
";",
"}",
"else",
"{",
"Map",
"m",
"=",
"convertToMap",
"(",
")",
";",
"if",
"(",
"!",
"isMutable",
"(",
")",
")",
"{",
"mMap",
"=",
"m",
... | Converts the MapSource to a Map. If the map is not mutable, this
is cached | [
"Converts",
"the",
"MapSource",
"to",
"a",
"Map",
".",
"If",
"the",
"map",
"is",
"not",
"mutable",
"this",
"is",
"cached"
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/lang/jstl/EnumeratedMap.java#L147-L157 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/lang/jstl/EnumeratedMap.java | EnumeratedMap.convertToMap | Map convertToMap() {
Map ret = new HashMap();
for (Enumeration e = enumerateKeys(); e.hasMoreElements();) {
Object key = e.nextElement();
Object value = getValue(key);
ret.put(key, value);
}
return ret;
} | java | Map convertToMap() {
Map ret = new HashMap();
for (Enumeration e = enumerateKeys(); e.hasMoreElements();) {
Object key = e.nextElement();
Object value = getValue(key);
ret.put(key, value);
}
return ret;
} | [
"Map",
"convertToMap",
"(",
")",
"{",
"Map",
"ret",
"=",
"new",
"HashMap",
"(",
")",
";",
"for",
"(",
"Enumeration",
"e",
"=",
"enumerateKeys",
"(",
")",
";",
"e",
".",
"hasMoreElements",
"(",
")",
";",
")",
"{",
"Object",
"key",
"=",
"e",
".",
"... | Converts to a Map | [
"Converts",
"to",
"a",
"Map"
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/lang/jstl/EnumeratedMap.java#L164-L172 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/tag/common/core/ParamSupport.java | ParamSupport.doEndTag | @Override
public int doEndTag() throws JspException {
Tag t = findAncestorWithClass(this, ParamParent.class);
if (t == null) {
throw new JspTagException(
Resources.getMessage("PARAM_OUTSIDE_PARENT"));
}
// take no action for null or empty names
if (name == null || name.equals("")) {
return EVAL_PAGE;
}
// send the parameter to the appropriate ancestor
ParamParent parent = (ParamParent) t;
String value = this.value;
if (value == null) {
if (bodyContent == null || bodyContent.getString() == null) {
value = "";
} else {
value = bodyContent.getString().trim();
}
}
if (encode) {
String enc = pageContext.getResponse().getCharacterEncoding();
try {
parent.addParameter(URLEncoder.encode(name, enc), URLEncoder.encode(value, enc));
} catch (UnsupportedEncodingException e) {
throw new JspTagException(e);
}
} else {
parent.addParameter(name, value);
}
return EVAL_PAGE;
} | java | @Override
public int doEndTag() throws JspException {
Tag t = findAncestorWithClass(this, ParamParent.class);
if (t == null) {
throw new JspTagException(
Resources.getMessage("PARAM_OUTSIDE_PARENT"));
}
// take no action for null or empty names
if (name == null || name.equals("")) {
return EVAL_PAGE;
}
// send the parameter to the appropriate ancestor
ParamParent parent = (ParamParent) t;
String value = this.value;
if (value == null) {
if (bodyContent == null || bodyContent.getString() == null) {
value = "";
} else {
value = bodyContent.getString().trim();
}
}
if (encode) {
String enc = pageContext.getResponse().getCharacterEncoding();
try {
parent.addParameter(URLEncoder.encode(name, enc), URLEncoder.encode(value, enc));
} catch (UnsupportedEncodingException e) {
throw new JspTagException(e);
}
} else {
parent.addParameter(name, value);
}
return EVAL_PAGE;
} | [
"@",
"Override",
"public",
"int",
"doEndTag",
"(",
")",
"throws",
"JspException",
"{",
"Tag",
"t",
"=",
"findAncestorWithClass",
"(",
"this",
",",
"ParamParent",
".",
"class",
")",
";",
"if",
"(",
"t",
"==",
"null",
")",
"{",
"throw",
"new",
"JspTagExcep... | simply send our name and value to our appropriate ancestor | [
"simply",
"send",
"our",
"name",
"and",
"value",
"to",
"our",
"appropriate",
"ancestor"
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/tag/common/core/ParamSupport.java#L73-L107 | train |
E7du/jfinal-ext3 | src/main/java/com/jfinal/ext/kit/ArrayKit.java | ArrayKit.union | public static String[] union(String[] arr1, String[] arr2) {
Set<String> set = new HashSet<String>();
for (String str : arr1) {
set.add(str);
}
for (String str : arr2) {
set.add(str);
}
String[] result = {};
return set.toArray(result);
} | java | public static String[] union(String[] arr1, String[] arr2) {
Set<String> set = new HashSet<String>();
for (String str : arr1) {
set.add(str);
}
for (String str : arr2) {
set.add(str);
}
String[] result = {};
return set.toArray(result);
} | [
"public",
"static",
"String",
"[",
"]",
"union",
"(",
"String",
"[",
"]",
"arr1",
",",
"String",
"[",
"]",
"arr2",
")",
"{",
"Set",
"<",
"String",
">",
"set",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"str",
... | Arr1 union Arr2
@param arr1
@param arr2 | [
"Arr1",
"union",
"Arr2"
] | 8ffcbd150fd50c72852bb778bd427b5eb19254dc | https://github.com/E7du/jfinal-ext3/blob/8ffcbd150fd50c72852bb778bd427b5eb19254dc/src/main/java/com/jfinal/ext/kit/ArrayKit.java#L32-L42 | train |
E7du/jfinal-ext3 | src/main/java/com/jfinal/ext/kit/ArrayKit.java | ArrayKit.intersect | public static String[] intersect(String[] arr1, String[] arr2) {
Map<String, Boolean> map = new HashMap<String, Boolean>();
LinkedList<String> list = new LinkedList<String>();
for (String str : arr1) {
if (!map.containsKey(str)) {
map.put(str, Boolean.FALSE);
}
}
for (String str : arr2) {
if (map.containsKey(str)) {
map.put(str, Boolean.TRUE);
}
}
for (Entry<String, Boolean> e : map.entrySet()) {
if (e.getValue().equals(Boolean.TRUE)) {
list.add(e.getKey());
}
}
String[] result = {};
return list.toArray(result);
} | java | public static String[] intersect(String[] arr1, String[] arr2) {
Map<String, Boolean> map = new HashMap<String, Boolean>();
LinkedList<String> list = new LinkedList<String>();
for (String str : arr1) {
if (!map.containsKey(str)) {
map.put(str, Boolean.FALSE);
}
}
for (String str : arr2) {
if (map.containsKey(str)) {
map.put(str, Boolean.TRUE);
}
}
for (Entry<String, Boolean> e : map.entrySet()) {
if (e.getValue().equals(Boolean.TRUE)) {
list.add(e.getKey());
}
}
String[] result = {};
return list.toArray(result);
} | [
"public",
"static",
"String",
"[",
"]",
"intersect",
"(",
"String",
"[",
"]",
"arr1",
",",
"String",
"[",
"]",
"arr2",
")",
"{",
"Map",
"<",
"String",
",",
"Boolean",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Boolean",
">",
"(",
")",
... | Arr1 intersect Arr2
@param arr1
@param arr2 | [
"Arr1",
"intersect",
"Arr2"
] | 8ffcbd150fd50c72852bb778bd427b5eb19254dc | https://github.com/E7du/jfinal-ext3/blob/8ffcbd150fd50c72852bb778bd427b5eb19254dc/src/main/java/com/jfinal/ext/kit/ArrayKit.java#L49-L71 | train |
E7du/jfinal-ext3 | src/main/java/com/jfinal/ext/kit/ArrayKit.java | ArrayKit.minus | public static String[] minus(String[] arr1, String[] arr2) {
LinkedList<String> list = new LinkedList<String>();
LinkedList<String> history = new LinkedList<String>();
String[] longerArr = arr1;
String[] shorterArr = arr2;
if (arr1.length > arr2.length) {
longerArr = arr2;
shorterArr = arr1;
}
for (String str : longerArr) {
if (!list.contains(str)) {
list.add(str);
}
}
for (String str : shorterArr) {
if (list.contains(str)) {
history.add(str);
list.remove(str);
} else {
if (!history.contains(str)) {
list.add(str);
}
}
}
String[] result = {};
return list.toArray(result);
} | java | public static String[] minus(String[] arr1, String[] arr2) {
LinkedList<String> list = new LinkedList<String>();
LinkedList<String> history = new LinkedList<String>();
String[] longerArr = arr1;
String[] shorterArr = arr2;
if (arr1.length > arr2.length) {
longerArr = arr2;
shorterArr = arr1;
}
for (String str : longerArr) {
if (!list.contains(str)) {
list.add(str);
}
}
for (String str : shorterArr) {
if (list.contains(str)) {
history.add(str);
list.remove(str);
} else {
if (!history.contains(str)) {
list.add(str);
}
}
}
String[] result = {};
return list.toArray(result);
} | [
"public",
"static",
"String",
"[",
"]",
"minus",
"(",
"String",
"[",
"]",
"arr1",
",",
"String",
"[",
"]",
"arr2",
")",
"{",
"LinkedList",
"<",
"String",
">",
"list",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
")",
";",
"LinkedList",
"<",
"... | Arr1 minus Arr2
@param arr1
@param arr2 | [
"Arr1",
"minus",
"Arr2"
] | 8ffcbd150fd50c72852bb778bd427b5eb19254dc | https://github.com/E7du/jfinal-ext3/blob/8ffcbd150fd50c72852bb778bd427b5eb19254dc/src/main/java/com/jfinal/ext/kit/ArrayKit.java#L78-L105 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/tag/common/sql/TransactionTagSupport.java | TransactionTagSupport.doEndTag | @Override
public int doEndTag() throws JspException {
try {
conn.commit();
} catch (SQLException e) {
throw new JspTagException(
Resources.getMessage("TRANSACTION_COMMIT_ERROR",
e.toString()), e);
}
return EVAL_PAGE;
} | java | @Override
public int doEndTag() throws JspException {
try {
conn.commit();
} catch (SQLException e) {
throw new JspTagException(
Resources.getMessage("TRANSACTION_COMMIT_ERROR",
e.toString()), e);
}
return EVAL_PAGE;
} | [
"@",
"Override",
"public",
"int",
"doEndTag",
"(",
")",
"throws",
"JspException",
"{",
"try",
"{",
"conn",
".",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"JspTagException",
"(",
"Resources",
".",
"getMessa... | Commits the transaction. | [
"Commits",
"the",
"transaction",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/tag/common/sql/TransactionTagSupport.java#L124-L134 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/tag/common/sql/TransactionTagSupport.java | TransactionTagSupport.doCatch | public void doCatch(Throwable t) throws Throwable {
if (conn != null) {
try {
conn.rollback();
} catch (SQLException e) {
// Ignore to not hide orignal exception
}
}
throw t;
} | java | public void doCatch(Throwable t) throws Throwable {
if (conn != null) {
try {
conn.rollback();
} catch (SQLException e) {
// Ignore to not hide orignal exception
}
}
throw t;
} | [
"public",
"void",
"doCatch",
"(",
"Throwable",
"t",
")",
"throws",
"Throwable",
"{",
"if",
"(",
"conn",
"!=",
"null",
")",
"{",
"try",
"{",
"conn",
".",
"rollback",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"// Ignore to not hide... | Rollbacks the transaction and rethrows the Throwable. | [
"Rollbacks",
"the",
"transaction",
"and",
"rethrows",
"the",
"Throwable",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/tag/common/sql/TransactionTagSupport.java#L139-L148 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/tag/common/sql/TransactionTagSupport.java | TransactionTagSupport.setIsolation | public void setIsolation(String iso) throws JspTagException {
if (TRANSACTION_READ_COMMITTED.equals(iso)) {
isolation = Connection.TRANSACTION_READ_COMMITTED;
} else if (TRANSACTION_READ_UNCOMMITTED.equals(iso)) {
isolation = Connection.TRANSACTION_READ_UNCOMMITTED;
} else if (TRANSACTION_REPEATABLE_READ.equals(iso)) {
isolation = Connection.TRANSACTION_REPEATABLE_READ;
} else if (TRANSACTION_SERIALIZABLE.equals(iso)) {
isolation = Connection.TRANSACTION_SERIALIZABLE;
} else {
throw new JspTagException(
Resources.getMessage("TRANSACTION_INVALID_ISOLATION"));
}
} | java | public void setIsolation(String iso) throws JspTagException {
if (TRANSACTION_READ_COMMITTED.equals(iso)) {
isolation = Connection.TRANSACTION_READ_COMMITTED;
} else if (TRANSACTION_READ_UNCOMMITTED.equals(iso)) {
isolation = Connection.TRANSACTION_READ_UNCOMMITTED;
} else if (TRANSACTION_REPEATABLE_READ.equals(iso)) {
isolation = Connection.TRANSACTION_REPEATABLE_READ;
} else if (TRANSACTION_SERIALIZABLE.equals(iso)) {
isolation = Connection.TRANSACTION_SERIALIZABLE;
} else {
throw new JspTagException(
Resources.getMessage("TRANSACTION_INVALID_ISOLATION"));
}
} | [
"public",
"void",
"setIsolation",
"(",
"String",
"iso",
")",
"throws",
"JspTagException",
"{",
"if",
"(",
"TRANSACTION_READ_COMMITTED",
".",
"equals",
"(",
"iso",
")",
")",
"{",
"isolation",
"=",
"Connection",
".",
"TRANSACTION_READ_COMMITTED",
";",
"}",
"else",... | Setter method for the transaction isolation level. | [
"Setter",
"method",
"for",
"the",
"transaction",
"isolation",
"level",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/tag/common/sql/TransactionTagSupport.java#L186-L200 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java | BeanInfoManager.getBeanInfoManager | public static BeanInfoManager getBeanInfoManager(Class pClass) {
BeanInfoManager ret = (BeanInfoManager)
mBeanInfoManagerByClass.get(pClass);
if (ret == null) {
ret = createBeanInfoManager(pClass);
}
return ret;
} | java | public static BeanInfoManager getBeanInfoManager(Class pClass) {
BeanInfoManager ret = (BeanInfoManager)
mBeanInfoManagerByClass.get(pClass);
if (ret == null) {
ret = createBeanInfoManager(pClass);
}
return ret;
} | [
"public",
"static",
"BeanInfoManager",
"getBeanInfoManager",
"(",
"Class",
"pClass",
")",
"{",
"BeanInfoManager",
"ret",
"=",
"(",
"BeanInfoManager",
")",
"mBeanInfoManagerByClass",
".",
"get",
"(",
"pClass",
")",
";",
"if",
"(",
"ret",
"==",
"null",
")",
"{",... | Returns the BeanInfoManager for the specified class | [
"Returns",
"the",
"BeanInfoManager",
"for",
"the",
"specified",
"class"
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java#L90-L97 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java | BeanInfoManager.getBeanInfoProperty | public static BeanInfoProperty getBeanInfoProperty
(Class pClass,
String pPropertyName,
Logger pLogger)
throws ELException {
return getBeanInfoManager(pClass).getProperty(pPropertyName, pLogger);
} | java | public static BeanInfoProperty getBeanInfoProperty
(Class pClass,
String pPropertyName,
Logger pLogger)
throws ELException {
return getBeanInfoManager(pClass).getProperty(pPropertyName, pLogger);
} | [
"public",
"static",
"BeanInfoProperty",
"getBeanInfoProperty",
"(",
"Class",
"pClass",
",",
"String",
"pPropertyName",
",",
"Logger",
"pLogger",
")",
"throws",
"ELException",
"{",
"return",
"getBeanInfoManager",
"(",
"pClass",
")",
".",
"getProperty",
"(",
"pPropert... | Returns the BeanInfoProperty for the specified property in the
given class, or null if not found. | [
"Returns",
"the",
"BeanInfoProperty",
"for",
"the",
"specified",
"property",
"in",
"the",
"given",
"class",
"or",
"null",
"if",
"not",
"found",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java#L129-L135 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java | BeanInfoManager.getBeanInfoIndexedProperty | public static BeanInfoIndexedProperty getBeanInfoIndexedProperty
(Class pClass,
String pIndexedPropertyName,
Logger pLogger)
throws ELException {
return getBeanInfoManager
(pClass).getIndexedProperty(pIndexedPropertyName, pLogger);
} | java | public static BeanInfoIndexedProperty getBeanInfoIndexedProperty
(Class pClass,
String pIndexedPropertyName,
Logger pLogger)
throws ELException {
return getBeanInfoManager
(pClass).getIndexedProperty(pIndexedPropertyName, pLogger);
} | [
"public",
"static",
"BeanInfoIndexedProperty",
"getBeanInfoIndexedProperty",
"(",
"Class",
"pClass",
",",
"String",
"pIndexedPropertyName",
",",
"Logger",
"pLogger",
")",
"throws",
"ELException",
"{",
"return",
"getBeanInfoManager",
"(",
"pClass",
")",
".",
"getIndexedP... | Returns the BeanInfoIndexedProperty for the specified property in
the given class, or null if not found. | [
"Returns",
"the",
"BeanInfoIndexedProperty",
"for",
"the",
"specified",
"property",
"in",
"the",
"given",
"class",
"or",
"null",
"if",
"not",
"found",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java#L143-L150 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java | BeanInfoManager.checkInitialized | void checkInitialized(Logger pLogger)
throws ELException {
if (!mInitialized) {
synchronized (this) {
if (!mInitialized) {
initialize(pLogger);
mInitialized = true;
}
}
}
} | java | void checkInitialized(Logger pLogger)
throws ELException {
if (!mInitialized) {
synchronized (this) {
if (!mInitialized) {
initialize(pLogger);
mInitialized = true;
}
}
}
} | [
"void",
"checkInitialized",
"(",
"Logger",
"pLogger",
")",
"throws",
"ELException",
"{",
"if",
"(",
"!",
"mInitialized",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"!",
"mInitialized",
")",
"{",
"initialize",
"(",
"pLogger",
")",
";",
"m... | Makes sure that this class has been initialized, and synchronizes
the initialization if it's required. | [
"Makes",
"sure",
"that",
"this",
"class",
"has",
"been",
"initialized",
"and",
"synchronizes",
"the",
"initialization",
"if",
"it",
"s",
"required",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java#L158-L168 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java | BeanInfoManager.initialize | void initialize(Logger pLogger)
throws ELException {
try {
mBeanInfo = Introspector.getBeanInfo(mBeanClass);
mPropertyByName = new HashMap();
mIndexedPropertyByName = new HashMap();
PropertyDescriptor[] pds = mBeanInfo.getPropertyDescriptors();
for (int i = 0; pds != null && i < pds.length; i++) {
// Treat as both an indexed property and a normal property
PropertyDescriptor pd = pds[i];
if (pd instanceof IndexedPropertyDescriptor) {
IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
Method readMethod = getPublicMethod(ipd.getIndexedReadMethod());
Method writeMethod = getPublicMethod(ipd.getIndexedWriteMethod());
BeanInfoIndexedProperty property = new BeanInfoIndexedProperty
(readMethod,
writeMethod,
ipd);
mIndexedPropertyByName.put(ipd.getName(), property);
}
Method readMethod = getPublicMethod(pd.getReadMethod());
Method writeMethod = getPublicMethod(pd.getWriteMethod());
BeanInfoProperty property = new BeanInfoProperty
(readMethod,
writeMethod,
pd);
mPropertyByName.put(pd.getName(), property);
}
mEventSetByName = new HashMap();
EventSetDescriptor[] esds = mBeanInfo.getEventSetDescriptors();
for (int i = 0; esds != null && i < esds.length; i++) {
EventSetDescriptor esd = esds[i];
mEventSetByName.put(esd.getName(), esd);
}
}
catch (IntrospectionException exc) {
if (pLogger.isLoggingWarning()) {
pLogger.logWarning
(Constants.EXCEPTION_GETTING_BEANINFO,
exc,
mBeanClass.getName());
}
}
} | java | void initialize(Logger pLogger)
throws ELException {
try {
mBeanInfo = Introspector.getBeanInfo(mBeanClass);
mPropertyByName = new HashMap();
mIndexedPropertyByName = new HashMap();
PropertyDescriptor[] pds = mBeanInfo.getPropertyDescriptors();
for (int i = 0; pds != null && i < pds.length; i++) {
// Treat as both an indexed property and a normal property
PropertyDescriptor pd = pds[i];
if (pd instanceof IndexedPropertyDescriptor) {
IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
Method readMethod = getPublicMethod(ipd.getIndexedReadMethod());
Method writeMethod = getPublicMethod(ipd.getIndexedWriteMethod());
BeanInfoIndexedProperty property = new BeanInfoIndexedProperty
(readMethod,
writeMethod,
ipd);
mIndexedPropertyByName.put(ipd.getName(), property);
}
Method readMethod = getPublicMethod(pd.getReadMethod());
Method writeMethod = getPublicMethod(pd.getWriteMethod());
BeanInfoProperty property = new BeanInfoProperty
(readMethod,
writeMethod,
pd);
mPropertyByName.put(pd.getName(), property);
}
mEventSetByName = new HashMap();
EventSetDescriptor[] esds = mBeanInfo.getEventSetDescriptors();
for (int i = 0; esds != null && i < esds.length; i++) {
EventSetDescriptor esd = esds[i];
mEventSetByName.put(esd.getName(), esd);
}
}
catch (IntrospectionException exc) {
if (pLogger.isLoggingWarning()) {
pLogger.logWarning
(Constants.EXCEPTION_GETTING_BEANINFO,
exc,
mBeanClass.getName());
}
}
} | [
"void",
"initialize",
"(",
"Logger",
"pLogger",
")",
"throws",
"ELException",
"{",
"try",
"{",
"mBeanInfo",
"=",
"Introspector",
".",
"getBeanInfo",
"(",
"mBeanClass",
")",
";",
"mPropertyByName",
"=",
"new",
"HashMap",
"(",
")",
";",
"mIndexedPropertyByName",
... | Initializes by mapping property names to BeanInfoProperties | [
"Initializes",
"by",
"mapping",
"property",
"names",
"to",
"BeanInfoProperties"
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java#L175-L223 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java | BeanInfoManager.getProperty | public BeanInfoProperty getProperty(String pPropertyName,
Logger pLogger)
throws ELException {
checkInitialized(pLogger);
return (BeanInfoProperty) mPropertyByName.get(pPropertyName);
} | java | public BeanInfoProperty getProperty(String pPropertyName,
Logger pLogger)
throws ELException {
checkInitialized(pLogger);
return (BeanInfoProperty) mPropertyByName.get(pPropertyName);
} | [
"public",
"BeanInfoProperty",
"getProperty",
"(",
"String",
"pPropertyName",
",",
"Logger",
"pLogger",
")",
"throws",
"ELException",
"{",
"checkInitialized",
"(",
"pLogger",
")",
";",
"return",
"(",
"BeanInfoProperty",
")",
"mPropertyByName",
".",
"get",
"(",
"pPr... | Returns the BeanInfoProperty for the given property name, or null
if not found. | [
"Returns",
"the",
"BeanInfoProperty",
"for",
"the",
"given",
"property",
"name",
"or",
"null",
"if",
"not",
"found",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java#L242-L247 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java | BeanInfoManager.getIndexedProperty | public BeanInfoIndexedProperty getIndexedProperty
(String pIndexedPropertyName,
Logger pLogger)
throws ELException {
checkInitialized(pLogger);
return (BeanInfoIndexedProperty)
mIndexedPropertyByName.get(pIndexedPropertyName);
} | java | public BeanInfoIndexedProperty getIndexedProperty
(String pIndexedPropertyName,
Logger pLogger)
throws ELException {
checkInitialized(pLogger);
return (BeanInfoIndexedProperty)
mIndexedPropertyByName.get(pIndexedPropertyName);
} | [
"public",
"BeanInfoIndexedProperty",
"getIndexedProperty",
"(",
"String",
"pIndexedPropertyName",
",",
"Logger",
"pLogger",
")",
"throws",
"ELException",
"{",
"checkInitialized",
"(",
"pLogger",
")",
";",
"return",
"(",
"BeanInfoIndexedProperty",
")",
"mIndexedPropertyByN... | Returns the BeanInfoIndexedProperty for the given property name,
or null if not found. | [
"Returns",
"the",
"BeanInfoIndexedProperty",
"for",
"the",
"given",
"property",
"name",
"or",
"null",
"if",
"not",
"found",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java#L255-L262 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java | BeanInfoManager.getEventSet | public EventSetDescriptor getEventSet(String pEventSetName,
Logger pLogger)
throws ELException {
checkInitialized(pLogger);
return (EventSetDescriptor) mEventSetByName.get(pEventSetName);
} | java | public EventSetDescriptor getEventSet(String pEventSetName,
Logger pLogger)
throws ELException {
checkInitialized(pLogger);
return (EventSetDescriptor) mEventSetByName.get(pEventSetName);
} | [
"public",
"EventSetDescriptor",
"getEventSet",
"(",
"String",
"pEventSetName",
",",
"Logger",
"pLogger",
")",
"throws",
"ELException",
"{",
"checkInitialized",
"(",
"pLogger",
")",
";",
"return",
"(",
"EventSetDescriptor",
")",
"mEventSetByName",
".",
"get",
"(",
... | Returns the EventSetDescriptor for the given event set name, or
null if not found. | [
"Returns",
"the",
"EventSetDescriptor",
"for",
"the",
"given",
"event",
"set",
"name",
"or",
"null",
"if",
"not",
"found",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java#L270-L275 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java | BeanInfoManager.getPublicMethod | static Method getPublicMethod(Method pMethod) {
if (pMethod == null) {
return null;
}
// See if the method is already available from a public class
Class cl = pMethod.getDeclaringClass();
if (Modifier.isPublic(cl.getModifiers())) {
return pMethod;
}
// Otherwise, try to find a public class that declares the method
Method ret = getPublicMethod(cl, pMethod);
if (ret != null) {
return ret;
} else {
return pMethod;
}
} | java | static Method getPublicMethod(Method pMethod) {
if (pMethod == null) {
return null;
}
// See if the method is already available from a public class
Class cl = pMethod.getDeclaringClass();
if (Modifier.isPublic(cl.getModifiers())) {
return pMethod;
}
// Otherwise, try to find a public class that declares the method
Method ret = getPublicMethod(cl, pMethod);
if (ret != null) {
return ret;
} else {
return pMethod;
}
} | [
"static",
"Method",
"getPublicMethod",
"(",
"Method",
"pMethod",
")",
"{",
"if",
"(",
"pMethod",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// See if the method is already available from a public class",
"Class",
"cl",
"=",
"pMethod",
".",
"getDeclaringCla... | Returns a publicly-accessible version of the given method, by
searching for a public declaring class. | [
"Returns",
"a",
"publicly",
"-",
"accessible",
"version",
"of",
"the",
"given",
"method",
"by",
"searching",
"for",
"a",
"public",
"declaring",
"class",
"."
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java#L289-L307 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java | BeanInfoManager.getPublicMethod | static Method getPublicMethod(Class pClass,
Method pMethod) {
// See if this is a public class declaring the method
if (Modifier.isPublic(pClass.getModifiers())) {
try {
Method m;
try {
m = pClass.getDeclaredMethod(pMethod.getName(),
pMethod.getParameterTypes());
} catch (java.security.AccessControlException ex) {
// kludge to accommodate J2EE RI's default settings
// TODO: see if we can simply replace
// getDeclaredMethod() with getMethod() ...?
m = pClass.getMethod(pMethod.getName(),
pMethod.getParameterTypes());
}
if (Modifier.isPublic(m.getModifiers())) {
return m;
}
}
catch (NoSuchMethodException exc) {
}
}
// Search the interfaces
{
Class[] interfaces = pClass.getInterfaces();
if (interfaces != null) {
for (int i = 0; i < interfaces.length; i++) {
Method m = getPublicMethod(interfaces[i], pMethod);
if (m != null) {
return m;
}
}
}
}
// Search the superclass
{
Class superclass = pClass.getSuperclass();
if (superclass != null) {
Method m = getPublicMethod(superclass, pMethod);
if (m != null) {
return m;
}
}
}
return null;
} | java | static Method getPublicMethod(Class pClass,
Method pMethod) {
// See if this is a public class declaring the method
if (Modifier.isPublic(pClass.getModifiers())) {
try {
Method m;
try {
m = pClass.getDeclaredMethod(pMethod.getName(),
pMethod.getParameterTypes());
} catch (java.security.AccessControlException ex) {
// kludge to accommodate J2EE RI's default settings
// TODO: see if we can simply replace
// getDeclaredMethod() with getMethod() ...?
m = pClass.getMethod(pMethod.getName(),
pMethod.getParameterTypes());
}
if (Modifier.isPublic(m.getModifiers())) {
return m;
}
}
catch (NoSuchMethodException exc) {
}
}
// Search the interfaces
{
Class[] interfaces = pClass.getInterfaces();
if (interfaces != null) {
for (int i = 0; i < interfaces.length; i++) {
Method m = getPublicMethod(interfaces[i], pMethod);
if (m != null) {
return m;
}
}
}
}
// Search the superclass
{
Class superclass = pClass.getSuperclass();
if (superclass != null) {
Method m = getPublicMethod(superclass, pMethod);
if (m != null) {
return m;
}
}
}
return null;
} | [
"static",
"Method",
"getPublicMethod",
"(",
"Class",
"pClass",
",",
"Method",
"pMethod",
")",
"{",
"// See if this is a public class declaring the method",
"if",
"(",
"Modifier",
".",
"isPublic",
"(",
"pClass",
".",
"getModifiers",
"(",
")",
")",
")",
"{",
"try",
... | If the given class is public and has a Method that declares the
same name and arguments as the given method, then that method is
returned. Otherwise the superclass and interfaces are searched
recursively. | [
"If",
"the",
"given",
"class",
"is",
"public",
"and",
"has",
"a",
"Method",
"that",
"declares",
"the",
"same",
"name",
"and",
"arguments",
"as",
"the",
"given",
"method",
"then",
"that",
"method",
"is",
"returned",
".",
"Otherwise",
"the",
"superclass",
"a... | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/lang/jstl/BeanInfoManager.java#L317-L366 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/tag/common/core/ImportSupport.java | ImportSupport.doStartTag | @Override
public int doStartTag() throws JspException {
// Sanity check
if (context != null
&& (!context.startsWith("/") || !url.startsWith("/"))) {
throw new JspTagException(
Resources.getMessage("IMPORT_BAD_RELATIVE"));
}
// reset parameter-related state
urlWithParams = null;
params = new ParamSupport.ParamManager();
// check the URL
if (url == null || url.equals("")) {
throw new NullAttributeException("import", "url");
}
// Record whether our URL is absolute or relative
isAbsoluteUrl = UrlUtil.isAbsoluteUrl(url);
try {
// If we need to expose a Reader, we've got to do it right away
if (varReader != null) {
r = acquireReader();
pageContext.setAttribute(varReader, r);
}
} catch (IOException ex) {
throw new JspTagException(ex.toString(), ex);
}
return EVAL_BODY_INCLUDE;
} | java | @Override
public int doStartTag() throws JspException {
// Sanity check
if (context != null
&& (!context.startsWith("/") || !url.startsWith("/"))) {
throw new JspTagException(
Resources.getMessage("IMPORT_BAD_RELATIVE"));
}
// reset parameter-related state
urlWithParams = null;
params = new ParamSupport.ParamManager();
// check the URL
if (url == null || url.equals("")) {
throw new NullAttributeException("import", "url");
}
// Record whether our URL is absolute or relative
isAbsoluteUrl = UrlUtil.isAbsoluteUrl(url);
try {
// If we need to expose a Reader, we've got to do it right away
if (varReader != null) {
r = acquireReader();
pageContext.setAttribute(varReader, r);
}
} catch (IOException ex) {
throw new JspTagException(ex.toString(), ex);
}
return EVAL_BODY_INCLUDE;
} | [
"@",
"Override",
"public",
"int",
"doStartTag",
"(",
")",
"throws",
"JspException",
"{",
"// Sanity check",
"if",
"(",
"context",
"!=",
"null",
"&&",
"(",
"!",
"context",
".",
"startsWith",
"(",
"\"/\"",
")",
"||",
"!",
"url",
".",
"startsWith",
"(",
"\"... | determines what kind of import and variable exposure to perform | [
"determines",
"what",
"kind",
"of",
"import",
"and",
"variable",
"exposure",
"to",
"perform"
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/tag/common/core/ImportSupport.java#L109-L141 | train |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/tag/common/core/ImportSupport.java | ImportSupport.doFinally | public void doFinally() {
try {
// If we exposed a Reader in doStartTag(), close it.
if (varReader != null) {
// 'r' can be null if an exception was thrown...
if (r != null) {
r.close();
}
pageContext.removeAttribute(varReader, PageContext.PAGE_SCOPE);
}
} catch (IOException ex) {
// ignore it; close() failed, but there's nothing more we can do
}
} | java | public void doFinally() {
try {
// If we exposed a Reader in doStartTag(), close it.
if (varReader != null) {
// 'r' can be null if an exception was thrown...
if (r != null) {
r.close();
}
pageContext.removeAttribute(varReader, PageContext.PAGE_SCOPE);
}
} catch (IOException ex) {
// ignore it; close() failed, but there's nothing more we can do
}
} | [
"public",
"void",
"doFinally",
"(",
")",
"{",
"try",
"{",
"// If we exposed a Reader in doStartTag(), close it.",
"if",
"(",
"varReader",
"!=",
"null",
")",
"{",
"// 'r' can be null if an exception was thrown...",
"if",
"(",
"r",
"!=",
"null",
")",
"{",
"r",
".",
... | cleans up if appropriate | [
"cleans",
"up",
"if",
"appropriate"
] | 4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/tag/common/core/ImportSupport.java#L173-L186 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.