id int32 0 165k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
137,000 | j256/simplejmx | src/main/java/com/j256/simplejmx/client/ClientUtils.java | ClientUtils.displayType | public static String displayType(String className, Object value) {
if (className == null) {
return null;
}
boolean array = false;
if (className.equals("[J")) {
array = true;
if (value == null) {
className = "unknown";
} else if (value instanceof boolean[]) {
className = "boolean";
} else if (value instanceof byte[]) {
className = "byte";
} else if (value instanceof char[]) {
className = "char";
} else if (value instanceof short[]) {
className = "short";
} else if (value instanceof int[]) {
className = "int";
} else if (value instanceof long[]) {
className = "long";
} else if (value instanceof float[]) {
className = "float";
} else if (value instanceof double[]) {
className = "double";
} else {
className = "unknown";
}
} else if (className.startsWith("[L")) {
className = className.substring(2, className.length() - 1);
}
if (className.startsWith("java.lang.")) {
className = className.substring(10);
} else if (className.startsWith("javax.management.openmbean.")) {
className = className.substring(27);
}
if (array) {
return "array of " + className;
} else {
return className;
}
} | java | public static String displayType(String className, Object value) {
if (className == null) {
return null;
}
boolean array = false;
if (className.equals("[J")) {
array = true;
if (value == null) {
className = "unknown";
} else if (value instanceof boolean[]) {
className = "boolean";
} else if (value instanceof byte[]) {
className = "byte";
} else if (value instanceof char[]) {
className = "char";
} else if (value instanceof short[]) {
className = "short";
} else if (value instanceof int[]) {
className = "int";
} else if (value instanceof long[]) {
className = "long";
} else if (value instanceof float[]) {
className = "float";
} else if (value instanceof double[]) {
className = "double";
} else {
className = "unknown";
}
} else if (className.startsWith("[L")) {
className = className.substring(2, className.length() - 1);
}
if (className.startsWith("java.lang.")) {
className = className.substring(10);
} else if (className.startsWith("javax.management.openmbean.")) {
className = className.substring(27);
}
if (array) {
return "array of " + className;
} else {
return className;
}
} | [
"public",
"static",
"String",
"displayType",
"(",
"String",
"className",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"className",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"boolean",
"array",
"=",
"false",
";",
"if",
"(",
"className",
".",
"... | Display type string from class name string. | [
"Display",
"type",
"string",
"from",
"class",
"name",
"string",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/ClientUtils.java#L69-L110 |
137,001 | j256/simplejmx | src/main/java/com/j256/simplejmx/client/CommandLineJmxClient.java | CommandLineJmxClient.runCommands | public void runCommands(final String[] commands) throws IOException {
doLines(0, new LineReader() {
private int commandC = 0;
@Override
public String getNextLine(String prompt) {
if (commandC >= commands.length) {
return null;
} else {
return commands[commandC++];
}
}
}, true);
} | java | public void runCommands(final String[] commands) throws IOException {
doLines(0, new LineReader() {
private int commandC = 0;
@Override
public String getNextLine(String prompt) {
if (commandC >= commands.length) {
return null;
} else {
return commands[commandC++];
}
}
}, true);
} | [
"public",
"void",
"runCommands",
"(",
"final",
"String",
"[",
"]",
"commands",
")",
"throws",
"IOException",
"{",
"doLines",
"(",
"0",
",",
"new",
"LineReader",
"(",
")",
"{",
"private",
"int",
"commandC",
"=",
"0",
";",
"@",
"Override",
"public",
"Strin... | Run commands from the String array. | [
"Run",
"commands",
"from",
"the",
"String",
"array",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/CommandLineJmxClient.java#L90-L103 |
137,002 | j256/simplejmx | src/main/java/com/j256/simplejmx/client/CommandLineJmxClient.java | CommandLineJmxClient.runBatchFile | public void runBatchFile(File batchFile) throws IOException {
final BufferedReader reader = new BufferedReader(new FileReader(batchFile));
try {
doLines(0, new LineReader() {
@Override
public String getNextLine(String prompt) throws IOException {
return reader.readLine();
}
}, true);
} finally {
reader.close();
}
} | java | public void runBatchFile(File batchFile) throws IOException {
final BufferedReader reader = new BufferedReader(new FileReader(batchFile));
try {
doLines(0, new LineReader() {
@Override
public String getNextLine(String prompt) throws IOException {
return reader.readLine();
}
}, true);
} finally {
reader.close();
}
} | [
"public",
"void",
"runBatchFile",
"(",
"File",
"batchFile",
")",
"throws",
"IOException",
"{",
"final",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"batchFile",
")",
")",
";",
"try",
"{",
"doLines",
"(",
"0",
",",... | Read in commands from the batch-file and execute them. | [
"Read",
"in",
"commands",
"from",
"the",
"batch",
"-",
"file",
"and",
"execute",
"them",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/CommandLineJmxClient.java#L108-L120 |
137,003 | j256/simplejmx | src/main/java/com/j256/simplejmx/client/CommandLineJmxClient.java | CommandLineJmxClient.doLines | private void doLines(int levelC, LineReader lineReader, boolean batch) throws IOException {
if (levelC > 20) {
System.out.print("Ignoring possible recursion after including 20 times");
return;
}
while (true) {
String line = lineReader.getNextLine(DEFAULT_PROMPT);
if (line == null) {
break;
}
// skip blank lines and comments
if (line.length() == 0 || line.startsWith("#") || line.startsWith("//")) {
continue;
}
if (batch) {
// if we are in batch mode, spit out the line we just read
System.out.println("> " + line);
}
String[] lineParts = line.split(" ");
String command = lineParts[0];
if (command.startsWith(HELP_COMMAND)) {
helpOutput();
} else if (command.startsWith("objects")) {
listBeans(lineParts);
} else if (command.startsWith("run")) {
if (lineParts.length == 2) {
runScript(lineParts[1], levelC);
} else {
System.out.println("Error. Usage: run script");
}
} else if (command.startsWith("attrs")) {
listAttributes(lineParts);
} else if (command.startsWith("get")) {
if (lineParts.length == 2) {
getAttributes(lineParts);
} else {
getAttribute(lineParts);
}
} else if (command.startsWith("set")) {
setAttribute(lineParts);
} else if (command.startsWith("opers") || command.startsWith("ops")) {
listOperations(lineParts);
} else if (command.startsWith("dolines")) {
invokeOperationLines(lineReader, lineParts, batch);
} else if (command.startsWith("do")) {
invokeOperation(lineParts);
} else if (command.startsWith("sleep")) {
if (lineParts.length == 2) {
try {
Thread.sleep(Long.parseLong(lineParts[1]));
} catch (NumberFormatException e) {
System.out.println("Error. Usage: sleep millis, invalid millis number '" + lineParts[1] + "'");
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
} else {
System.out.println("Error. Usage: sleep millis");
}
} else if (command.startsWith("examples")) {
exampleOutput();
} else if (command.startsWith("quit")) {
break;
} else {
System.out.println("Error. Unknown command. Type '" + HELP_COMMAND + "' for help: " + command);
}
}
} | java | private void doLines(int levelC, LineReader lineReader, boolean batch) throws IOException {
if (levelC > 20) {
System.out.print("Ignoring possible recursion after including 20 times");
return;
}
while (true) {
String line = lineReader.getNextLine(DEFAULT_PROMPT);
if (line == null) {
break;
}
// skip blank lines and comments
if (line.length() == 0 || line.startsWith("#") || line.startsWith("//")) {
continue;
}
if (batch) {
// if we are in batch mode, spit out the line we just read
System.out.println("> " + line);
}
String[] lineParts = line.split(" ");
String command = lineParts[0];
if (command.startsWith(HELP_COMMAND)) {
helpOutput();
} else if (command.startsWith("objects")) {
listBeans(lineParts);
} else if (command.startsWith("run")) {
if (lineParts.length == 2) {
runScript(lineParts[1], levelC);
} else {
System.out.println("Error. Usage: run script");
}
} else if (command.startsWith("attrs")) {
listAttributes(lineParts);
} else if (command.startsWith("get")) {
if (lineParts.length == 2) {
getAttributes(lineParts);
} else {
getAttribute(lineParts);
}
} else if (command.startsWith("set")) {
setAttribute(lineParts);
} else if (command.startsWith("opers") || command.startsWith("ops")) {
listOperations(lineParts);
} else if (command.startsWith("dolines")) {
invokeOperationLines(lineReader, lineParts, batch);
} else if (command.startsWith("do")) {
invokeOperation(lineParts);
} else if (command.startsWith("sleep")) {
if (lineParts.length == 2) {
try {
Thread.sleep(Long.parseLong(lineParts[1]));
} catch (NumberFormatException e) {
System.out.println("Error. Usage: sleep millis, invalid millis number '" + lineParts[1] + "'");
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
} else {
System.out.println("Error. Usage: sleep millis");
}
} else if (command.startsWith("examples")) {
exampleOutput();
} else if (command.startsWith("quit")) {
break;
} else {
System.out.println("Error. Unknown command. Type '" + HELP_COMMAND + "' for help: " + command);
}
}
} | [
"private",
"void",
"doLines",
"(",
"int",
"levelC",
",",
"LineReader",
"lineReader",
",",
"boolean",
"batch",
")",
"throws",
"IOException",
"{",
"if",
"(",
"levelC",
">",
"20",
")",
"{",
"System",
".",
"out",
".",
"print",
"(",
"\"Ignoring possible recursion... | Do the lines from the reader. This might go recursive if we run a script. | [
"Do",
"the",
"lines",
"from",
"the",
"reader",
".",
"This",
"might",
"go",
"recursive",
"if",
"we",
"run",
"a",
"script",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/CommandLineJmxClient.java#L153-L220 |
137,004 | j256/simplejmx | src/main/java/com/j256/simplejmx/client/CommandLineJmxClient.java | CommandLineJmxClient.runScript | private void runScript(String alias, int levelC) throws IOException {
String scriptFile = alias;
InputStream stream;
try {
stream = getInputStream(scriptFile);
if (stream == null) {
System.out.println("Error. Script file is not found: " + scriptFile);
return;
}
} catch (IOException e) {
System.out.println("Error. Could not load script file " + scriptFile + ": " + e.getMessage());
return;
}
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
try {
doLines(levelC + 1, new LineReader() {
@Override
public String getNextLine(String prompt) throws IOException {
return reader.readLine();
}
}, true);
} finally {
reader.close();
}
} | java | private void runScript(String alias, int levelC) throws IOException {
String scriptFile = alias;
InputStream stream;
try {
stream = getInputStream(scriptFile);
if (stream == null) {
System.out.println("Error. Script file is not found: " + scriptFile);
return;
}
} catch (IOException e) {
System.out.println("Error. Could not load script file " + scriptFile + ": " + e.getMessage());
return;
}
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
try {
doLines(levelC + 1, new LineReader() {
@Override
public String getNextLine(String prompt) throws IOException {
return reader.readLine();
}
}, true);
} finally {
reader.close();
}
} | [
"private",
"void",
"runScript",
"(",
"String",
"alias",
",",
"int",
"levelC",
")",
"throws",
"IOException",
"{",
"String",
"scriptFile",
"=",
"alias",
";",
"InputStream",
"stream",
";",
"try",
"{",
"stream",
"=",
"getInputStream",
"(",
"scriptFile",
")",
";"... | Run a script. This might go recursive if we run from within a script. | [
"Run",
"a",
"script",
".",
"This",
"might",
"go",
"recursive",
"if",
"we",
"run",
"from",
"within",
"a",
"script",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/CommandLineJmxClient.java#L319-L343 |
137,005 | j256/simplejmx | src/main/java/com/j256/simplejmx/server/ReflectionMbean.java | ReflectionMbean.buildMbeanInfo | private MBeanInfo buildMbeanInfo(JmxAttributeFieldInfo[] attributeFieldInfos,
JmxAttributeMethodInfo[] attributeMethodInfos, JmxOperationInfo[] operationInfos, boolean ignoreErrors) {
// NOTE: setup the maps that track previous class configuration
Map<String, JmxAttributeFieldInfo> attributeFieldInfoMap = null;
if (attributeFieldInfos != null) {
attributeFieldInfoMap = new HashMap<String, JmxAttributeFieldInfo>();
for (JmxAttributeFieldInfo info : attributeFieldInfos) {
attributeFieldInfoMap.put(info.getFieldName(), info);
}
}
Map<String, JmxAttributeMethodInfo> attributeMethodInfoMap = null;
if (attributeMethodInfos != null) {
attributeMethodInfoMap = new HashMap<String, JmxAttributeMethodInfo>();
for (JmxAttributeMethodInfo info : attributeMethodInfos) {
attributeMethodInfoMap.put(info.getMethodName(), info);
}
}
Map<String, JmxOperationInfo> attributeOperationInfoMap = null;
if (operationInfos != null) {
attributeOperationInfoMap = new HashMap<String, JmxOperationInfo>();
for (JmxOperationInfo info : operationInfos) {
attributeOperationInfoMap.put(info.getMethodName(), info);
}
}
Set<String> attributeNameSet = new HashSet<String>();
List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>();
// NOTE: methods override fields so subclasses can stop exposing of fields
discoverAttributeMethods(attributeMethodInfoMap, attributeNameSet, attributes, ignoreErrors);
discoverAttributeFields(attributeFieldInfoMap, attributeNameSet, attributes);
List<MBeanOperationInfo> operations = discoverOperations(attributeOperationInfoMap);
return new MBeanInfo(target.getClass().getName(), description,
attributes.toArray(new MBeanAttributeInfo[attributes.size()]), null,
operations.toArray(new MBeanOperationInfo[operations.size()]), null);
} | java | private MBeanInfo buildMbeanInfo(JmxAttributeFieldInfo[] attributeFieldInfos,
JmxAttributeMethodInfo[] attributeMethodInfos, JmxOperationInfo[] operationInfos, boolean ignoreErrors) {
// NOTE: setup the maps that track previous class configuration
Map<String, JmxAttributeFieldInfo> attributeFieldInfoMap = null;
if (attributeFieldInfos != null) {
attributeFieldInfoMap = new HashMap<String, JmxAttributeFieldInfo>();
for (JmxAttributeFieldInfo info : attributeFieldInfos) {
attributeFieldInfoMap.put(info.getFieldName(), info);
}
}
Map<String, JmxAttributeMethodInfo> attributeMethodInfoMap = null;
if (attributeMethodInfos != null) {
attributeMethodInfoMap = new HashMap<String, JmxAttributeMethodInfo>();
for (JmxAttributeMethodInfo info : attributeMethodInfos) {
attributeMethodInfoMap.put(info.getMethodName(), info);
}
}
Map<String, JmxOperationInfo> attributeOperationInfoMap = null;
if (operationInfos != null) {
attributeOperationInfoMap = new HashMap<String, JmxOperationInfo>();
for (JmxOperationInfo info : operationInfos) {
attributeOperationInfoMap.put(info.getMethodName(), info);
}
}
Set<String> attributeNameSet = new HashSet<String>();
List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>();
// NOTE: methods override fields so subclasses can stop exposing of fields
discoverAttributeMethods(attributeMethodInfoMap, attributeNameSet, attributes, ignoreErrors);
discoverAttributeFields(attributeFieldInfoMap, attributeNameSet, attributes);
List<MBeanOperationInfo> operations = discoverOperations(attributeOperationInfoMap);
return new MBeanInfo(target.getClass().getName(), description,
attributes.toArray(new MBeanAttributeInfo[attributes.size()]), null,
operations.toArray(new MBeanOperationInfo[operations.size()]), null);
} | [
"private",
"MBeanInfo",
"buildMbeanInfo",
"(",
"JmxAttributeFieldInfo",
"[",
"]",
"attributeFieldInfos",
",",
"JmxAttributeMethodInfo",
"[",
"]",
"attributeMethodInfos",
",",
"JmxOperationInfo",
"[",
"]",
"operationInfos",
",",
"boolean",
"ignoreErrors",
")",
"{",
"// N... | Build our JMX information object by using reflection. | [
"Build",
"our",
"JMX",
"information",
"object",
"by",
"using",
"reflection",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/server/ReflectionMbean.java#L189-L225 |
137,006 | j256/simplejmx | src/main/java/com/j256/simplejmx/server/ReflectionMbean.java | ReflectionMbean.discoverOperations | private List<MBeanOperationInfo> discoverOperations(Map<String, JmxOperationInfo> attributeOperationInfoMap) {
Set<MethodSignature> methodSignatureSet = new HashSet<MethodSignature>();
List<MBeanOperationInfo> operations = new ArrayList<MBeanOperationInfo>(operationMethodMap.size());
for (Class<?> clazz = target.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
discoverOperations(attributeOperationInfoMap, methodSignatureSet, operations, clazz);
}
return operations;
} | java | private List<MBeanOperationInfo> discoverOperations(Map<String, JmxOperationInfo> attributeOperationInfoMap) {
Set<MethodSignature> methodSignatureSet = new HashSet<MethodSignature>();
List<MBeanOperationInfo> operations = new ArrayList<MBeanOperationInfo>(operationMethodMap.size());
for (Class<?> clazz = target.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
discoverOperations(attributeOperationInfoMap, methodSignatureSet, operations, clazz);
}
return operations;
} | [
"private",
"List",
"<",
"MBeanOperationInfo",
">",
"discoverOperations",
"(",
"Map",
"<",
"String",
",",
"JmxOperationInfo",
">",
"attributeOperationInfoMap",
")",
"{",
"Set",
"<",
"MethodSignature",
">",
"methodSignatureSet",
"=",
"new",
"HashSet",
"<",
"MethodSign... | Find operation methods from our object that will be exposed via JMX. | [
"Find",
"operation",
"methods",
"from",
"our",
"object",
"that",
"will",
"be",
"exposed",
"via",
"JMX",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/server/ReflectionMbean.java#L389-L396 |
137,007 | j256/simplejmx | src/main/java/com/j256/simplejmx/server/ReflectionMbean.java | ReflectionMbean.buildOperationParameterInfo | private MBeanParameterInfo[] buildOperationParameterInfo(Method method, JmxOperationInfo operationInfo) {
Class<?>[] types = method.getParameterTypes();
MBeanParameterInfo[] parameterInfos = new MBeanParameterInfo[types.length];
String[] parameterNames = operationInfo.getParameterNames();
String[] parameterDescriptions = operationInfo.getParameterDescriptions();
for (int i = 0; i < types.length; i++) {
String parameterName;
if (parameterNames == null || i >= parameterNames.length) {
parameterName = "p" + (i + 1);
} else {
parameterName = parameterNames[i];
}
String typeName = types[i].getName();
String description;
if (parameterDescriptions == null || i >= parameterDescriptions.length) {
description = "parameter #" + (i + 1) + " of type: " + typeName;
} else {
description = parameterDescriptions[i];
}
parameterInfos[i] = new MBeanParameterInfo(parameterName, typeName, description);
}
return parameterInfos;
} | java | private MBeanParameterInfo[] buildOperationParameterInfo(Method method, JmxOperationInfo operationInfo) {
Class<?>[] types = method.getParameterTypes();
MBeanParameterInfo[] parameterInfos = new MBeanParameterInfo[types.length];
String[] parameterNames = operationInfo.getParameterNames();
String[] parameterDescriptions = operationInfo.getParameterDescriptions();
for (int i = 0; i < types.length; i++) {
String parameterName;
if (parameterNames == null || i >= parameterNames.length) {
parameterName = "p" + (i + 1);
} else {
parameterName = parameterNames[i];
}
String typeName = types[i].getName();
String description;
if (parameterDescriptions == null || i >= parameterDescriptions.length) {
description = "parameter #" + (i + 1) + " of type: " + typeName;
} else {
description = parameterDescriptions[i];
}
parameterInfos[i] = new MBeanParameterInfo(parameterName, typeName, description);
}
return parameterInfos;
} | [
"private",
"MBeanParameterInfo",
"[",
"]",
"buildOperationParameterInfo",
"(",
"Method",
"method",
",",
"JmxOperationInfo",
"operationInfo",
")",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"types",
"=",
"method",
".",
"getParameterTypes",
"(",
")",
";",
"MBeanParame... | Build our parameter information for an operation. | [
"Build",
"our",
"parameter",
"information",
"for",
"an",
"operation",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/server/ReflectionMbean.java#L447-L469 |
137,008 | j256/simplejmx | src/main/java/com/j256/simplejmx/common/ObjectNameUtil.java | ObjectNameUtil.makeObjectName | public static ObjectName makeObjectName(JmxResource jmxResource, JmxSelfNaming selfNamingObj) {
String domainName = selfNamingObj.getJmxDomainName();
if (domainName == null) {
if (jmxResource != null) {
domainName = jmxResource.domainName();
}
if (isEmpty(domainName)) {
throw new IllegalArgumentException(
"Could not create ObjectName because domain name not specified in getJmxDomainName() nor @JmxResource");
}
}
String beanName = selfNamingObj.getJmxBeanName();
if (beanName == null) {
if (jmxResource != null) {
beanName = getBeanName(jmxResource);
}
if (isEmpty(beanName)) {
beanName = selfNamingObj.getClass().getSimpleName();
}
}
String[] jmxResourceFolders = null;
if (jmxResource != null) {
jmxResourceFolders = jmxResource.folderNames();
}
return makeObjectName(domainName, beanName, selfNamingObj.getJmxFolderNames(), jmxResourceFolders);
} | java | public static ObjectName makeObjectName(JmxResource jmxResource, JmxSelfNaming selfNamingObj) {
String domainName = selfNamingObj.getJmxDomainName();
if (domainName == null) {
if (jmxResource != null) {
domainName = jmxResource.domainName();
}
if (isEmpty(domainName)) {
throw new IllegalArgumentException(
"Could not create ObjectName because domain name not specified in getJmxDomainName() nor @JmxResource");
}
}
String beanName = selfNamingObj.getJmxBeanName();
if (beanName == null) {
if (jmxResource != null) {
beanName = getBeanName(jmxResource);
}
if (isEmpty(beanName)) {
beanName = selfNamingObj.getClass().getSimpleName();
}
}
String[] jmxResourceFolders = null;
if (jmxResource != null) {
jmxResourceFolders = jmxResource.folderNames();
}
return makeObjectName(domainName, beanName, selfNamingObj.getJmxFolderNames(), jmxResourceFolders);
} | [
"public",
"static",
"ObjectName",
"makeObjectName",
"(",
"JmxResource",
"jmxResource",
",",
"JmxSelfNaming",
"selfNamingObj",
")",
"{",
"String",
"domainName",
"=",
"selfNamingObj",
".",
"getJmxDomainName",
"(",
")",
";",
"if",
"(",
"domainName",
"==",
"null",
")"... | Constructs an object-name from a jmx-resource and a self naming object.
@param jmxResource
Annotation from the class for which we are creating our ObjectName. It may be null.
@param selfNamingObj
Object that implements the self-naming interface.
@throws IllegalArgumentException
If we had problems building the name | [
"Constructs",
"an",
"object",
"-",
"name",
"from",
"a",
"jmx",
"-",
"resource",
"and",
"a",
"self",
"naming",
"object",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/common/ObjectNameUtil.java#L26-L51 |
137,009 | j256/simplejmx | src/main/java/com/j256/simplejmx/common/ObjectNameUtil.java | ObjectNameUtil.makeObjectName | public static ObjectName makeObjectName(JmxSelfNaming selfNamingObj) {
JmxResource jmxResource = selfNamingObj.getClass().getAnnotation(JmxResource.class);
return makeObjectName(jmxResource, selfNamingObj);
} | java | public static ObjectName makeObjectName(JmxSelfNaming selfNamingObj) {
JmxResource jmxResource = selfNamingObj.getClass().getAnnotation(JmxResource.class);
return makeObjectName(jmxResource, selfNamingObj);
} | [
"public",
"static",
"ObjectName",
"makeObjectName",
"(",
"JmxSelfNaming",
"selfNamingObj",
")",
"{",
"JmxResource",
"jmxResource",
"=",
"selfNamingObj",
".",
"getClass",
"(",
")",
".",
"getAnnotation",
"(",
"JmxResource",
".",
"class",
")",
";",
"return",
"makeObj... | Constructs an object-name from a self naming object only.
@param selfNamingObj
Object that implements the self-naming interface.
@throws IllegalArgumentException
If we had problems building the name | [
"Constructs",
"an",
"object",
"-",
"name",
"from",
"a",
"self",
"naming",
"object",
"only",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/common/ObjectNameUtil.java#L61-L64 |
137,010 | j256/simplejmx | src/main/java/com/j256/simplejmx/common/ObjectNameUtil.java | ObjectNameUtil.makeObjectName | public static ObjectName makeObjectName(JmxResource jmxResource, Object obj) {
String domainName = jmxResource.domainName();
if (isEmpty(domainName)) {
throw new IllegalArgumentException(
"Could not create ObjectName because domain name not specified in @JmxResource");
}
String beanName = getBeanName(jmxResource);
if (beanName == null) {
beanName = obj.getClass().getSimpleName();
}
return makeObjectName(domainName, beanName, null, jmxResource.folderNames());
} | java | public static ObjectName makeObjectName(JmxResource jmxResource, Object obj) {
String domainName = jmxResource.domainName();
if (isEmpty(domainName)) {
throw new IllegalArgumentException(
"Could not create ObjectName because domain name not specified in @JmxResource");
}
String beanName = getBeanName(jmxResource);
if (beanName == null) {
beanName = obj.getClass().getSimpleName();
}
return makeObjectName(domainName, beanName, null, jmxResource.folderNames());
} | [
"public",
"static",
"ObjectName",
"makeObjectName",
"(",
"JmxResource",
"jmxResource",
",",
"Object",
"obj",
")",
"{",
"String",
"domainName",
"=",
"jmxResource",
".",
"domainName",
"(",
")",
";",
"if",
"(",
"isEmpty",
"(",
"domainName",
")",
")",
"{",
"thro... | Constructs an object-name from a jmx-resource and a object which is not self-naming.
@param jmxResource
Annotation from the class for which we are creating our ObjectName.
@param obj
Object for which we are creating our ObjectName
@throws IllegalArgumentException
If we had problems building the name | [
"Constructs",
"an",
"object",
"-",
"name",
"from",
"a",
"jmx",
"-",
"resource",
"and",
"a",
"object",
"which",
"is",
"not",
"self",
"-",
"naming",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/common/ObjectNameUtil.java#L76-L87 |
137,011 | j256/simplejmx | src/main/java/com/j256/simplejmx/common/ObjectNameUtil.java | ObjectNameUtil.makeObjectName | public static ObjectName makeObjectName(String domainName, String beanName, String[] folderNameStrings) {
return makeObjectName(domainName, beanName, null, folderNameStrings);
} | java | public static ObjectName makeObjectName(String domainName, String beanName, String[] folderNameStrings) {
return makeObjectName(domainName, beanName, null, folderNameStrings);
} | [
"public",
"static",
"ObjectName",
"makeObjectName",
"(",
"String",
"domainName",
",",
"String",
"beanName",
",",
"String",
"[",
"]",
"folderNameStrings",
")",
"{",
"return",
"makeObjectName",
"(",
"domainName",
",",
"beanName",
",",
"null",
",",
"folderNameStrings... | Constructs an object-name from a domain-name, object-name, and folder-name strings.
@param domainName
This is the top level folder name for the beans.
@param beanName
This is the bean name in the lowest folder level.
@param folderNameStrings
These can be used to setup folders inside of the top folder. Each of the entries in the array can
either be in "value" or "name=value" format.
@throws IllegalArgumentException
If we had problems building the name | [
"Constructs",
"an",
"object",
"-",
"name",
"from",
"a",
"domain",
"-",
"name",
"object",
"-",
"name",
"and",
"folder",
"-",
"name",
"strings",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/common/ObjectNameUtil.java#L102-L104 |
137,012 | j256/simplejmx | src/main/java/com/j256/simplejmx/client/Main.java | Main.doMain | void doMain(String[] args, boolean throwOnError) throws Exception {
if (args.length == 0) {
usage(throwOnError, "no arguments specified");
return;
} else if (args.length > 2) {
usage(throwOnError, "improper number of arguments:" + Arrays.toString(args));
return;
}
// check for --usage or --help
if (args.length == 1 && ("--usage".equals(args[0]) || "--help".equals(args[0]))) {
usage(throwOnError, null);
return;
}
CommandLineJmxClient jmxClient;
if (args[0].indexOf('/') >= 0) {
jmxClient = new CommandLineJmxClient(args[0]);
} else {
String[] parts = args[0].split(":");
if (parts.length != 2) {
usage(throwOnError, "argument should be in 'hostname:port' format, not: " + args[0]);
return;
}
String hostName = parts[0];
int port = 0;
try {
port = Integer.parseInt(parts[1]);
} catch (NumberFormatException e) {
usage(throwOnError, "port number not in the right format: " + parts[1]);
return;
}
jmxClient = new CommandLineJmxClient(hostName, port);
}
if (args.length == 1) {
jmxClient.runCommandLine();
} else if (args.length == 2) {
jmxClient.runBatchFile(new File(args[1]));
}
} | java | void doMain(String[] args, boolean throwOnError) throws Exception {
if (args.length == 0) {
usage(throwOnError, "no arguments specified");
return;
} else if (args.length > 2) {
usage(throwOnError, "improper number of arguments:" + Arrays.toString(args));
return;
}
// check for --usage or --help
if (args.length == 1 && ("--usage".equals(args[0]) || "--help".equals(args[0]))) {
usage(throwOnError, null);
return;
}
CommandLineJmxClient jmxClient;
if (args[0].indexOf('/') >= 0) {
jmxClient = new CommandLineJmxClient(args[0]);
} else {
String[] parts = args[0].split(":");
if (parts.length != 2) {
usage(throwOnError, "argument should be in 'hostname:port' format, not: " + args[0]);
return;
}
String hostName = parts[0];
int port = 0;
try {
port = Integer.parseInt(parts[1]);
} catch (NumberFormatException e) {
usage(throwOnError, "port number not in the right format: " + parts[1]);
return;
}
jmxClient = new CommandLineJmxClient(hostName, port);
}
if (args.length == 1) {
jmxClient.runCommandLine();
} else if (args.length == 2) {
jmxClient.runBatchFile(new File(args[1]));
}
} | [
"void",
"doMain",
"(",
"String",
"[",
"]",
"args",
",",
"boolean",
"throwOnError",
")",
"throws",
"Exception",
"{",
"if",
"(",
"args",
".",
"length",
"==",
"0",
")",
"{",
"usage",
"(",
"throwOnError",
",",
"\"no arguments specified\"",
")",
";",
"return",
... | This is package for testing purposes.
@param throwOnError
If true then throw an exception when we quit otherwise exit. | [
"This",
"is",
"package",
"for",
"testing",
"purposes",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/Main.java#L28-L68 |
137,013 | j256/simplejmx | src/main/java/com/j256/simplejmx/client/JmxClient.java | JmxClient.getBeanDomains | public String[] getBeanDomains() throws JMException {
checkClientConnected();
try {
return mbeanConn.getDomains();
} catch (IOException e) {
throw createJmException("Problems getting jmx domains: " + e, e);
}
} | java | public String[] getBeanDomains() throws JMException {
checkClientConnected();
try {
return mbeanConn.getDomains();
} catch (IOException e) {
throw createJmException("Problems getting jmx domains: " + e, e);
}
} | [
"public",
"String",
"[",
"]",
"getBeanDomains",
"(",
")",
"throws",
"JMException",
"{",
"checkClientConnected",
"(",
")",
";",
"try",
"{",
"return",
"mbeanConn",
".",
"getDomains",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
... | Return an array of the bean's domain names. | [
"Return",
"an",
"array",
"of",
"the",
"bean",
"s",
"domain",
"names",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/JmxClient.java#L204-L211 |
137,014 | j256/simplejmx | src/main/java/com/j256/simplejmx/client/JmxClient.java | JmxClient.getAttributeInfo | public MBeanAttributeInfo getAttributeInfo(ObjectName name, String attrName) throws JMException {
checkClientConnected();
return getAttrInfo(name, attrName);
} | java | public MBeanAttributeInfo getAttributeInfo(ObjectName name, String attrName) throws JMException {
checkClientConnected();
return getAttrInfo(name, attrName);
} | [
"public",
"MBeanAttributeInfo",
"getAttributeInfo",
"(",
"ObjectName",
"name",
",",
"String",
"attrName",
")",
"throws",
"JMException",
"{",
"checkClientConnected",
"(",
")",
";",
"return",
"getAttrInfo",
"(",
"name",
",",
"attrName",
")",
";",
"}"
] | Return information for a particular attribute name. | [
"Return",
"information",
"for",
"a",
"particular",
"attribute",
"name",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/JmxClient.java#L259-L262 |
137,015 | j256/simplejmx | src/main/java/com/j256/simplejmx/client/JmxClient.java | JmxClient.getAttributeString | public String getAttributeString(String domain, String beanName, String attributeName) throws Exception {
return getAttributeString(ObjectNameUtil.makeObjectName(domain, beanName), attributeName);
} | java | public String getAttributeString(String domain, String beanName, String attributeName) throws Exception {
return getAttributeString(ObjectNameUtil.makeObjectName(domain, beanName), attributeName);
} | [
"public",
"String",
"getAttributeString",
"(",
"String",
"domain",
",",
"String",
"beanName",
",",
"String",
"attributeName",
")",
"throws",
"Exception",
"{",
"return",
"getAttributeString",
"(",
"ObjectNameUtil",
".",
"makeObjectName",
"(",
"domain",
",",
"beanName... | Return the value of a JMX attribute as a String. | [
"Return",
"the",
"value",
"of",
"a",
"JMX",
"attribute",
"as",
"a",
"String",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/JmxClient.java#L320-L322 |
137,016 | j256/simplejmx | src/main/java/com/j256/simplejmx/client/JmxClient.java | JmxClient.getAttributeString | public String getAttributeString(ObjectName name, String attributeName) throws Exception {
Object bean = getAttribute(name, attributeName);
if (bean == null) {
return null;
} else {
return ClientUtils.valueToString(bean);
}
} | java | public String getAttributeString(ObjectName name, String attributeName) throws Exception {
Object bean = getAttribute(name, attributeName);
if (bean == null) {
return null;
} else {
return ClientUtils.valueToString(bean);
}
} | [
"public",
"String",
"getAttributeString",
"(",
"ObjectName",
"name",
",",
"String",
"attributeName",
")",
"throws",
"Exception",
"{",
"Object",
"bean",
"=",
"getAttribute",
"(",
"name",
",",
"attributeName",
")",
";",
"if",
"(",
"bean",
"==",
"null",
")",
"{... | Return the value of a JMX attribute as a String or null if attribute has a null value. | [
"Return",
"the",
"value",
"of",
"a",
"JMX",
"attribute",
"as",
"a",
"String",
"or",
"null",
"if",
"attribute",
"has",
"a",
"null",
"value",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/JmxClient.java#L327-L334 |
137,017 | j256/simplejmx | src/main/java/com/j256/simplejmx/client/JmxClient.java | JmxClient.setAttribute | public void setAttribute(ObjectName name, String attrName, Object value) throws Exception {
checkClientConnected();
Attribute attribute = new Attribute(attrName, value);
mbeanConn.setAttribute(name, attribute);
} | java | public void setAttribute(ObjectName name, String attrName, Object value) throws Exception {
checkClientConnected();
Attribute attribute = new Attribute(attrName, value);
mbeanConn.setAttribute(name, attribute);
} | [
"public",
"void",
"setAttribute",
"(",
"ObjectName",
"name",
",",
"String",
"attrName",
",",
"Object",
"value",
")",
"throws",
"Exception",
"{",
"checkClientConnected",
"(",
")",
";",
"Attribute",
"attribute",
"=",
"new",
"Attribute",
"(",
"attrName",
",",
"va... | Set the JMX attribute to a particular value. | [
"Set",
"the",
"JMX",
"attribute",
"to",
"a",
"particular",
"value",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/JmxClient.java#L381-L385 |
137,018 | j256/simplejmx | src/main/java/com/j256/simplejmx/web/JmxWebServer.java | JmxWebServer.stop | public void stop() throws Exception {
if (server != null) {
server.setStopTimeout(100);
server.stop();
server = null;
}
} | java | public void stop() throws Exception {
if (server != null) {
server.setStopTimeout(100);
server.stop();
server = null;
}
} | [
"public",
"void",
"stop",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"server",
"!=",
"null",
")",
"{",
"server",
".",
"setStopTimeout",
"(",
"100",
")",
";",
"server",
".",
"stop",
"(",
")",
";",
"server",
"=",
"null",
";",
"}",
"}"
] | Stop the internal Jetty web server and associated classes. | [
"Stop",
"the",
"internal",
"Jetty",
"web",
"server",
"and",
"associated",
"classes",
"."
] | 1a04f52512dfa0a711ba0cc7023c604dbc82a352 | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/web/JmxWebServer.java#L59-L65 |
137,019 | rapid7/le_java | src/main/java/com/logentries/logback/ExceptionFormatter.java | ExceptionFormatter.formatException | public static String formatException(IThrowableProxy error) {
String ex = "";
ex += formatTopLevelError(error);
ex += formatStackTraceElements(error.getStackTraceElementProxyArray());
IThrowableProxy cause = error.getCause();
ex += DELIMITER;
while (cause != null) {
ex += formatTopLevelError(cause);
StackTraceElementProxy[] arr = cause.getStackTraceElementProxyArray();
ex += formatStackTraceElements(arr);
ex += DELIMITER;
cause = cause.getCause();
}
return ex;
} | java | public static String formatException(IThrowableProxy error) {
String ex = "";
ex += formatTopLevelError(error);
ex += formatStackTraceElements(error.getStackTraceElementProxyArray());
IThrowableProxy cause = error.getCause();
ex += DELIMITER;
while (cause != null) {
ex += formatTopLevelError(cause);
StackTraceElementProxy[] arr = cause.getStackTraceElementProxyArray();
ex += formatStackTraceElements(arr);
ex += DELIMITER;
cause = cause.getCause();
}
return ex;
} | [
"public",
"static",
"String",
"formatException",
"(",
"IThrowableProxy",
"error",
")",
"{",
"String",
"ex",
"=",
"\"\"",
";",
"ex",
"+=",
"formatTopLevelError",
"(",
"error",
")",
";",
"ex",
"+=",
"formatStackTraceElements",
"(",
"error",
".",
"getStackTraceElem... | Returns a formatted stack trace for an exception.
<p>This method provides a full (non-truncated) trace delimited by
{@link #DELIMITER}. Currently it doesn't make any use of Java 7's <a
href="http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html#suppressed-exceptions">exception
suppression</a>.</p>
@param error an {@link IThrowableProxy} object
@return stack trace string | [
"Returns",
"a",
"formatted",
"stack",
"trace",
"for",
"an",
"exception",
"."
] | ab042d98a0d2490eb2ded3a21e97d66139391202 | https://github.com/rapid7/le_java/blob/ab042d98a0d2490eb2ded3a21e97d66139391202/src/main/java/com/logentries/logback/ExceptionFormatter.java#L37-L51 |
137,020 | l0s/fernet-java8 | fernet-java8/src/main/java/com/macasaet/fernet/Token.java | Token.generate | public static Token generate(final Random random, final Key key, final String plainText) {
return generate(random, key, plainText.getBytes(charset));
} | java | public static Token generate(final Random random, final Key key, final String plainText) {
return generate(random, key, plainText.getBytes(charset));
} | [
"public",
"static",
"Token",
"generate",
"(",
"final",
"Random",
"random",
",",
"final",
"Key",
"key",
",",
"final",
"String",
"plainText",
")",
"{",
"return",
"generate",
"(",
"random",
",",
"key",
",",
"plainText",
".",
"getBytes",
"(",
"charset",
")",
... | Convenience method to generate a new Fernet token with a string payload.
@param random a source of entropy for your application
@param key the secret key for encrypting <em>plainText</em> and signing the token
@param plainText the payload to embed in the token
@return a unique Fernet token | [
"Convenience",
"method",
"to",
"generate",
"a",
"new",
"Fernet",
"token",
"with",
"a",
"string",
"payload",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-java8/src/main/java/com/macasaet/fernet/Token.java#L164-L166 |
137,021 | l0s/fernet-java8 | fernet-java8/src/main/java/com/macasaet/fernet/Token.java | Token.generate | public static Token generate(final Random random, final Key key, final byte[] payload) {
final IvParameterSpec initializationVector = generateInitializationVector(random);
final byte[] cipherText = key.encrypt(payload, initializationVector);
final Instant timestamp = Instant.now();
final byte[] hmac = key.sign(supportedVersion, timestamp, initializationVector, cipherText);
return new Token(supportedVersion, timestamp, initializationVector, cipherText, hmac);
} | java | public static Token generate(final Random random, final Key key, final byte[] payload) {
final IvParameterSpec initializationVector = generateInitializationVector(random);
final byte[] cipherText = key.encrypt(payload, initializationVector);
final Instant timestamp = Instant.now();
final byte[] hmac = key.sign(supportedVersion, timestamp, initializationVector, cipherText);
return new Token(supportedVersion, timestamp, initializationVector, cipherText, hmac);
} | [
"public",
"static",
"Token",
"generate",
"(",
"final",
"Random",
"random",
",",
"final",
"Key",
"key",
",",
"final",
"byte",
"[",
"]",
"payload",
")",
"{",
"final",
"IvParameterSpec",
"initializationVector",
"=",
"generateInitializationVector",
"(",
"random",
")... | Generate a new Fernet token.
@param random a source of entropy for your application
@param key the secret key for encrypting <em>payload</em> and signing the token
@param payload the unencrypted data to embed in the token
@return a unique Fernet token | [
"Generate",
"a",
"new",
"Fernet",
"token",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-java8/src/main/java/com/macasaet/fernet/Token.java#L176-L182 |
137,022 | l0s/fernet-java8 | fernet-java8/src/main/java/com/macasaet/fernet/Token.java | Token.validateAndDecrypt | @SuppressWarnings("PMD.LawOfDemeter")
public <T> T validateAndDecrypt(final Key key, final Validator<T> validator) {
return validator.validateAndDecrypt(key, this);
} | java | @SuppressWarnings("PMD.LawOfDemeter")
public <T> T validateAndDecrypt(final Key key, final Validator<T> validator) {
return validator.validateAndDecrypt(key, this);
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.LawOfDemeter\"",
")",
"public",
"<",
"T",
">",
"T",
"validateAndDecrypt",
"(",
"final",
"Key",
"key",
",",
"final",
"Validator",
"<",
"T",
">",
"validator",
")",
"{",
"return",
"validator",
".",
"validateAndDecrypt",
"(",
... | Check the validity of this token.
@param key the secret key against which to validate the token
@param validator an object that encapsulates the validation parameters (e.g. TTL)
@return the decrypted, deserialised payload of this token
@throws TokenValidationException if <em>key</em> was NOT used to generate this token | [
"Check",
"the",
"validity",
"of",
"this",
"token",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-java8/src/main/java/com/macasaet/fernet/Token.java#L192-L195 |
137,023 | l0s/fernet-java8 | fernet-java8/src/main/java/com/macasaet/fernet/Token.java | Token.validateAndDecrypt | @SuppressWarnings("PMD.LawOfDemeter")
public <T> T validateAndDecrypt(final Collection<? extends Key> keys, final Validator<T> validator) {
return validator.validateAndDecrypt(keys, this);
} | java | @SuppressWarnings("PMD.LawOfDemeter")
public <T> T validateAndDecrypt(final Collection<? extends Key> keys, final Validator<T> validator) {
return validator.validateAndDecrypt(keys, this);
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.LawOfDemeter\"",
")",
"public",
"<",
"T",
">",
"T",
"validateAndDecrypt",
"(",
"final",
"Collection",
"<",
"?",
"extends",
"Key",
">",
"keys",
",",
"final",
"Validator",
"<",
"T",
">",
"validator",
")",
"{",
"return",
"... | Check the validity of this token against a collection of keys. Use this if you have implemented key rotation.
@param keys the active keys which may have been used to generate token
@param validator an object that encapsulates the validation parameters (e.g. TTL)
@return the decrypted, deserialised payload of this token
@throws TokenValidationException if none of the keys were used to generate this token | [
"Check",
"the",
"validity",
"of",
"this",
"token",
"against",
"a",
"collection",
"of",
"keys",
".",
"Use",
"this",
"if",
"you",
"have",
"implemented",
"key",
"rotation",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-java8/src/main/java/com/macasaet/fernet/Token.java#L205-L208 |
137,024 | l0s/fernet-java8 | fernet-java8/src/main/java/com/macasaet/fernet/Token.java | Token.writeTo | @SuppressWarnings("PMD.LawOfDemeter")
public void writeTo(final OutputStream outputStream) throws IOException {
try (DataOutputStream dataStream = new DataOutputStream(outputStream)) {
dataStream.writeByte(getVersion());
dataStream.writeLong(getTimestamp().getEpochSecond());
dataStream.write(getInitializationVector().getIV());
dataStream.write(getCipherText());
dataStream.write(getHmac());
}
} | java | @SuppressWarnings("PMD.LawOfDemeter")
public void writeTo(final OutputStream outputStream) throws IOException {
try (DataOutputStream dataStream = new DataOutputStream(outputStream)) {
dataStream.writeByte(getVersion());
dataStream.writeLong(getTimestamp().getEpochSecond());
dataStream.write(getInitializationVector().getIV());
dataStream.write(getCipherText());
dataStream.write(getHmac());
}
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.LawOfDemeter\"",
")",
"public",
"void",
"writeTo",
"(",
"final",
"OutputStream",
"outputStream",
")",
"throws",
"IOException",
"{",
"try",
"(",
"DataOutputStream",
"dataStream",
"=",
"new",
"DataOutputStream",
"(",
"outputStream",
... | Write the raw bytes of this token to the specified output stream.
@param outputStream
the target
@throws IOException
if data cannot be written to the underlying stream | [
"Write",
"the",
"raw",
"bytes",
"of",
"this",
"token",
"to",
"the",
"specified",
"output",
"stream",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-java8/src/main/java/com/macasaet/fernet/Token.java#L248-L257 |
137,025 | l0s/fernet-java8 | fernet-java8/src/main/java/com/macasaet/fernet/Token.java | Token.isValidSignature | public boolean isValidSignature(final Key key) {
final byte[] computedHmac = key.sign(getVersion(), getTimestamp(), getInitializationVector(),
getCipherText());
return Arrays.equals(getHmac(), computedHmac);
} | java | public boolean isValidSignature(final Key key) {
final byte[] computedHmac = key.sign(getVersion(), getTimestamp(), getInitializationVector(),
getCipherText());
return Arrays.equals(getHmac(), computedHmac);
} | [
"public",
"boolean",
"isValidSignature",
"(",
"final",
"Key",
"key",
")",
"{",
"final",
"byte",
"[",
"]",
"computedHmac",
"=",
"key",
".",
"sign",
"(",
"getVersion",
"(",
")",
",",
"getTimestamp",
"(",
")",
",",
"getInitializationVector",
"(",
")",
",",
... | Recompute the HMAC signature of the token with the stored shared secret key.
@param key
the shared secret key against which to validate the token
@return true if and only if the signature on the token was generated using the supplied key | [
"Recompute",
"the",
"HMAC",
"signature",
"of",
"the",
"token",
"with",
"the",
"stored",
"shared",
"secret",
"key",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-java8/src/main/java/com/macasaet/fernet/Token.java#L305-L309 |
137,026 | rapid7/le_java | src/main/java/com/logentries/net/AsyncLogger.java | AsyncLogger.checkValidUUID | boolean checkValidUUID( String uuid){
if("".equals(uuid))
return false;
try {
UUID u = UUID.fromString(uuid);
}catch(IllegalArgumentException e){
return false;
}
return true;
} | java | boolean checkValidUUID( String uuid){
if("".equals(uuid))
return false;
try {
UUID u = UUID.fromString(uuid);
}catch(IllegalArgumentException e){
return false;
}
return true;
} | [
"boolean",
"checkValidUUID",
"(",
"String",
"uuid",
")",
"{",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"uuid",
")",
")",
"return",
"false",
";",
"try",
"{",
"UUID",
"u",
"=",
"UUID",
".",
"fromString",
"(",
"uuid",
")",
";",
"}",
"catch",
"(",
"Illeg... | Checks that the UUID is valid | [
"Checks",
"that",
"the",
"UUID",
"is",
"valid"
] | ab042d98a0d2490eb2ded3a21e97d66139391202 | https://github.com/rapid7/le_java/blob/ab042d98a0d2490eb2ded3a21e97d66139391202/src/main/java/com/logentries/net/AsyncLogger.java#L347-L358 |
137,027 | rapid7/le_java | src/main/java/com/logentries/net/AsyncLogger.java | AsyncLogger.getEnvVar | String getEnvVar( String key)
{
String envVal = System.getenv(key);
return envVal != null ? envVal : "";
} | java | String getEnvVar( String key)
{
String envVal = System.getenv(key);
return envVal != null ? envVal : "";
} | [
"String",
"getEnvVar",
"(",
"String",
"key",
")",
"{",
"String",
"envVal",
"=",
"System",
".",
"getenv",
"(",
"key",
")",
";",
"return",
"envVal",
"!=",
"null",
"?",
"envVal",
":",
"\"\"",
";",
"}"
] | Try and retrieve environment variable for given key, return empty string if not found | [
"Try",
"and",
"retrieve",
"environment",
"variable",
"for",
"given",
"key",
"return",
"empty",
"string",
"if",
"not",
"found"
] | ab042d98a0d2490eb2ded3a21e97d66139391202 | https://github.com/rapid7/le_java/blob/ab042d98a0d2490eb2ded3a21e97d66139391202/src/main/java/com/logentries/net/AsyncLogger.java#L364-L369 |
137,028 | rapid7/le_java | src/main/java/com/logentries/net/AsyncLogger.java | AsyncLogger.checkCredentials | boolean checkCredentials() {
if(!httpPut)
{
if (token.equals(CONFIG_TOKEN) || token.equals(""))
{
//Check if set in an environment variable, used with PaaS providers
String envToken = getEnvVar( CONFIG_TOKEN);
if (envToken == ""){
dbg(INVALID_TOKEN);
return false;
}
this.setToken(envToken);
}
return checkValidUUID(this.getToken());
}else{
if ( !checkValidUUID(this.getKey()) || this.getLocation().equals(""))
return false;
return true;
}
} | java | boolean checkCredentials() {
if(!httpPut)
{
if (token.equals(CONFIG_TOKEN) || token.equals(""))
{
//Check if set in an environment variable, used with PaaS providers
String envToken = getEnvVar( CONFIG_TOKEN);
if (envToken == ""){
dbg(INVALID_TOKEN);
return false;
}
this.setToken(envToken);
}
return checkValidUUID(this.getToken());
}else{
if ( !checkValidUUID(this.getKey()) || this.getLocation().equals(""))
return false;
return true;
}
} | [
"boolean",
"checkCredentials",
"(",
")",
"{",
"if",
"(",
"!",
"httpPut",
")",
"{",
"if",
"(",
"token",
".",
"equals",
"(",
"CONFIG_TOKEN",
")",
"||",
"token",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"//Check if set in an environment variable, used with PaaS... | Checks that key and location are set. | [
"Checks",
"that",
"key",
"and",
"location",
"are",
"set",
"."
] | ab042d98a0d2490eb2ded3a21e97d66139391202 | https://github.com/rapid7/le_java/blob/ab042d98a0d2490eb2ded3a21e97d66139391202/src/main/java/com/logentries/net/AsyncLogger.java#L374-L399 |
137,029 | rapid7/le_java | src/main/java/com/logentries/net/AsyncLogger.java | AsyncLogger.dbg | void dbg(String msg) {
if (debug ) {
if (!msg.endsWith(LINE_SEP)) {
System.err.println(LE + msg);
} else {
System.err.print(LE + msg);
}
}
} | java | void dbg(String msg) {
if (debug ) {
if (!msg.endsWith(LINE_SEP)) {
System.err.println(LE + msg);
} else {
System.err.print(LE + msg);
}
}
} | [
"void",
"dbg",
"(",
"String",
"msg",
")",
"{",
"if",
"(",
"debug",
")",
"{",
"if",
"(",
"!",
"msg",
".",
"endsWith",
"(",
"LINE_SEP",
")",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"LE",
"+",
"msg",
")",
";",
"}",
"else",
"{",
"Sys... | Prints the message given. Used for internal debugging.
@param msg message to display | [
"Prints",
"the",
"message",
"given",
".",
"Used",
"for",
"internal",
"debugging",
"."
] | ab042d98a0d2490eb2ded3a21e97d66139391202 | https://github.com/rapid7/le_java/blob/ab042d98a0d2490eb2ded3a21e97d66139391202/src/main/java/com/logentries/net/AsyncLogger.java#L471-L479 |
137,030 | l0s/fernet-java8 | fernet-jersey-auth/src/main/java/com/macasaet/fernet/jersey/TokenHeaderUtility.java | TokenHeaderUtility.getAuthorizationToken | @SuppressWarnings("PMD.AvoidLiteralsInIfCondition")
public Token getAuthorizationToken(final ContainerRequest request) {
String authorizationString = request.getHeaderString("Authorization");
if (authorizationString != null && !"".equals(authorizationString)) {
authorizationString = authorizationString.trim();
final String[] components = authorizationString.split("\\s");
if (components.length != 2) {
throw new NotAuthorizedException(authenticationType);
}
final String scheme = components[0];
if (!authenticationType.equalsIgnoreCase(scheme)) {
throw new NotAuthorizedException(authenticationType);
}
final String tokenString = components[1];
return Token.fromString(tokenString);
}
return null;
} | java | @SuppressWarnings("PMD.AvoidLiteralsInIfCondition")
public Token getAuthorizationToken(final ContainerRequest request) {
String authorizationString = request.getHeaderString("Authorization");
if (authorizationString != null && !"".equals(authorizationString)) {
authorizationString = authorizationString.trim();
final String[] components = authorizationString.split("\\s");
if (components.length != 2) {
throw new NotAuthorizedException(authenticationType);
}
final String scheme = components[0];
if (!authenticationType.equalsIgnoreCase(scheme)) {
throw new NotAuthorizedException(authenticationType);
}
final String tokenString = components[1];
return Token.fromString(tokenString);
}
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.AvoidLiteralsInIfCondition\"",
")",
"public",
"Token",
"getAuthorizationToken",
"(",
"final",
"ContainerRequest",
"request",
")",
"{",
"String",
"authorizationString",
"=",
"request",
".",
"getHeaderString",
"(",
"\"Authorization\"",
"... | Extract a Fernet token from an RFC6750 Authorization header.
@param request a REST request which may or may not include an RFC6750 Authorization header.
@return a Fernet token or null if no RFC6750 Authorization header is provided. | [
"Extract",
"a",
"Fernet",
"token",
"from",
"an",
"RFC6750",
"Authorization",
"header",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-jersey-auth/src/main/java/com/macasaet/fernet/jersey/TokenHeaderUtility.java#L40-L57 |
137,031 | l0s/fernet-java8 | fernet-jersey-auth/src/main/java/com/macasaet/fernet/jersey/TokenHeaderUtility.java | TokenHeaderUtility.getXAuthorizationToken | public Token getXAuthorizationToken(final ContainerRequest request) {
final String xAuthorizationString = request.getHeaderString("X-Authorization");
if (xAuthorizationString != null && !"".equals(xAuthorizationString)) {
return Token.fromString(xAuthorizationString.trim());
}
return null;
} | java | public Token getXAuthorizationToken(final ContainerRequest request) {
final String xAuthorizationString = request.getHeaderString("X-Authorization");
if (xAuthorizationString != null && !"".equals(xAuthorizationString)) {
return Token.fromString(xAuthorizationString.trim());
}
return null;
} | [
"public",
"Token",
"getXAuthorizationToken",
"(",
"final",
"ContainerRequest",
"request",
")",
"{",
"final",
"String",
"xAuthorizationString",
"=",
"request",
".",
"getHeaderString",
"(",
"\"X-Authorization\"",
")",
";",
"if",
"(",
"xAuthorizationString",
"!=",
"null"... | Extract a Fernet token from an X-Authorization header.
@param request a REST request which may or may not include an X-Authorization header.
@return a Fernet token or null if no X-Authorization header is provided. | [
"Extract",
"a",
"Fernet",
"token",
"from",
"an",
"X",
"-",
"Authorization",
"header",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-jersey-auth/src/main/java/com/macasaet/fernet/jersey/TokenHeaderUtility.java#L65-L71 |
137,032 | l0s/fernet-java8 | fernet-aws-secrets-manager-rotator/src/main/java/com/macasaet/fernet/aws/secretsmanager/rotation/AbstractFernetKeyRotator.java | AbstractFernetKeyRotator.seed | protected void seed() {
if (!seeded.get()) {
synchronized (random) {
if (!seeded.get()) {
getLogger().debug("Seeding random number generator");
final GenerateRandomRequest request = new GenerateRandomRequest();
request.setNumberOfBytes(512);
final GenerateRandomResult result = getKms().generateRandom(request);
final ByteBuffer randomBytes = result.getPlaintext();
final byte[] bytes = new byte[randomBytes.remaining()];
randomBytes.get(bytes);
random.setSeed(bytes);
seeded.set(true);
getLogger().debug("Seeded random number generator");
}
}
}
} | java | protected void seed() {
if (!seeded.get()) {
synchronized (random) {
if (!seeded.get()) {
getLogger().debug("Seeding random number generator");
final GenerateRandomRequest request = new GenerateRandomRequest();
request.setNumberOfBytes(512);
final GenerateRandomResult result = getKms().generateRandom(request);
final ByteBuffer randomBytes = result.getPlaintext();
final byte[] bytes = new byte[randomBytes.remaining()];
randomBytes.get(bytes);
random.setSeed(bytes);
seeded.set(true);
getLogger().debug("Seeded random number generator");
}
}
}
} | [
"protected",
"void",
"seed",
"(",
")",
"{",
"if",
"(",
"!",
"seeded",
".",
"get",
"(",
")",
")",
"{",
"synchronized",
"(",
"random",
")",
"{",
"if",
"(",
"!",
"seeded",
".",
"get",
"(",
")",
")",
"{",
"getLogger",
"(",
")",
".",
"debug",
"(",
... | This seeds the random number generator using KMS if and only it hasn't already been seeded.
This requires the permission: <code>kms:GenerateRandom</code> | [
"This",
"seeds",
"the",
"random",
"number",
"generator",
"using",
"KMS",
"if",
"and",
"only",
"it",
"hasn",
"t",
"already",
"been",
"seeded",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-aws-secrets-manager-rotator/src/main/java/com/macasaet/fernet/aws/secretsmanager/rotation/AbstractFernetKeyRotator.java#L202-L219 |
137,033 | l0s/fernet-java8 | fernet-aws-secrets-manager-rotator/src/main/java/com/macasaet/fernet/aws/secretsmanager/rotation/SecretsManager.java | SecretsManager.getSecretStage | public ByteBuffer getSecretStage(final String secretId, final Stage stage) {
final GetSecretValueRequest getSecretValueRequest = new GetSecretValueRequest();
getSecretValueRequest.setSecretId(secretId);
getSecretValueRequest.setVersionStage(stage.getAwsName());
final GetSecretValueResult result = getDelegate().getSecretValue(getSecretValueRequest);
return result.getSecretBinary();
} | java | public ByteBuffer getSecretStage(final String secretId, final Stage stage) {
final GetSecretValueRequest getSecretValueRequest = new GetSecretValueRequest();
getSecretValueRequest.setSecretId(secretId);
getSecretValueRequest.setVersionStage(stage.getAwsName());
final GetSecretValueResult result = getDelegate().getSecretValue(getSecretValueRequest);
return result.getSecretBinary();
} | [
"public",
"ByteBuffer",
"getSecretStage",
"(",
"final",
"String",
"secretId",
",",
"final",
"Stage",
"stage",
")",
"{",
"final",
"GetSecretValueRequest",
"getSecretValueRequest",
"=",
"new",
"GetSecretValueRequest",
"(",
")",
";",
"getSecretValueRequest",
".",
"setSec... | Retrieve a specific stage of the secret.
@param secretId the ARN of the secret
@param stage the stage of the secret to retrieve
@return the Fernet key or keys in binary form | [
"Retrieve",
"a",
"specific",
"stage",
"of",
"the",
"secret",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-aws-secrets-manager-rotator/src/main/java/com/macasaet/fernet/aws/secretsmanager/rotation/SecretsManager.java#L107-L113 |
137,034 | l0s/fernet-java8 | fernet-java8/src/main/java/com/macasaet/fernet/Key.java | Key.generateKey | public static Key generateKey(final Random random) {
final byte[] signingKey = new byte[signingKeyBytes];
random.nextBytes(signingKey);
final byte[] encryptionKey = new byte[encryptionKeyBytes];
random.nextBytes(encryptionKey);
return new Key(signingKey, encryptionKey);
} | java | public static Key generateKey(final Random random) {
final byte[] signingKey = new byte[signingKeyBytes];
random.nextBytes(signingKey);
final byte[] encryptionKey = new byte[encryptionKeyBytes];
random.nextBytes(encryptionKey);
return new Key(signingKey, encryptionKey);
} | [
"public",
"static",
"Key",
"generateKey",
"(",
"final",
"Random",
"random",
")",
"{",
"final",
"byte",
"[",
"]",
"signingKey",
"=",
"new",
"byte",
"[",
"signingKeyBytes",
"]",
";",
"random",
".",
"nextBytes",
"(",
"signingKey",
")",
";",
"final",
"byte",
... | Generate a random key
@param random
source of entropy
@return a new shared secret key | [
"Generate",
"a",
"random",
"key"
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-java8/src/main/java/com/macasaet/fernet/Key.java#L109-L115 |
137,035 | l0s/fernet-java8 | fernet-java8/src/main/java/com/macasaet/fernet/Key.java | Key.sign | public byte[] sign(final byte version, final Instant timestamp, final IvParameterSpec initializationVector,
final byte[] cipherText) {
try (ByteArrayOutputStream byteStream = new ByteArrayOutputStream(
getTokenPrefixBytes() + cipherText.length)) {
return sign(version, timestamp, initializationVector, cipherText, byteStream);
} catch (final IOException e) {
// this should not happen as I/O is to memory only
throw new IllegalStateException(e.getMessage(), e);
}
} | java | public byte[] sign(final byte version, final Instant timestamp, final IvParameterSpec initializationVector,
final byte[] cipherText) {
try (ByteArrayOutputStream byteStream = new ByteArrayOutputStream(
getTokenPrefixBytes() + cipherText.length)) {
return sign(version, timestamp, initializationVector, cipherText, byteStream);
} catch (final IOException e) {
// this should not happen as I/O is to memory only
throw new IllegalStateException(e.getMessage(), e);
}
} | [
"public",
"byte",
"[",
"]",
"sign",
"(",
"final",
"byte",
"version",
",",
"final",
"Instant",
"timestamp",
",",
"final",
"IvParameterSpec",
"initializationVector",
",",
"final",
"byte",
"[",
"]",
"cipherText",
")",
"{",
"try",
"(",
"ByteArrayOutputStream",
"by... | Generate an HMAC SHA-256 signature from the components of a Fernet token.
@param version
the Fernet version number
@param timestamp
the seconds after the epoch that the token was generated
@param initializationVector
the encryption and decryption initialization vector
@param cipherText
the encrypted content of the token
@return the HMAC signature | [
"Generate",
"an",
"HMAC",
"SHA",
"-",
"256",
"signature",
"from",
"the",
"components",
"of",
"a",
"Fernet",
"token",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-java8/src/main/java/com/macasaet/fernet/Key.java#L130-L139 |
137,036 | l0s/fernet-java8 | fernet-java8/src/main/java/com/macasaet/fernet/Key.java | Key.encrypt | @SuppressWarnings("PMD.LawOfDemeter")
public byte[] encrypt(final byte[] payload, final IvParameterSpec initializationVector) {
final SecretKeySpec encryptionKeySpec = getEncryptionKeySpec();
try {
final Cipher cipher = Cipher.getInstance(cipherTransformation);
cipher.init(ENCRYPT_MODE, encryptionKeySpec, initializationVector);
return cipher.doFinal(payload);
} catch (final NoSuchAlgorithmException | NoSuchPaddingException e) {
// these should not happen as we use an algorithm (AES) and padding (PKCS5) that are guaranteed to exist
throw new IllegalStateException("Unable to access cipher " + cipherTransformation + ": " + e.getMessage(), e);
} catch (final InvalidKeyException | InvalidAlgorithmParameterException e) {
// this should not happen as the key is validated ahead of time and
// we use an algorithm guaranteed to exist
throw new IllegalStateException(
"Unable to initialise encryption cipher with algorithm " + encryptionKeySpec.getAlgorithm()
+ " and format " + encryptionKeySpec.getFormat() + ": " + e.getMessage(),
e);
} catch (final IllegalBlockSizeException | BadPaddingException e) {
// these should not happen as we control the block size and padding
throw new IllegalStateException("Unable to encrypt data: " + e.getMessage(), e);
}
} | java | @SuppressWarnings("PMD.LawOfDemeter")
public byte[] encrypt(final byte[] payload, final IvParameterSpec initializationVector) {
final SecretKeySpec encryptionKeySpec = getEncryptionKeySpec();
try {
final Cipher cipher = Cipher.getInstance(cipherTransformation);
cipher.init(ENCRYPT_MODE, encryptionKeySpec, initializationVector);
return cipher.doFinal(payload);
} catch (final NoSuchAlgorithmException | NoSuchPaddingException e) {
// these should not happen as we use an algorithm (AES) and padding (PKCS5) that are guaranteed to exist
throw new IllegalStateException("Unable to access cipher " + cipherTransformation + ": " + e.getMessage(), e);
} catch (final InvalidKeyException | InvalidAlgorithmParameterException e) {
// this should not happen as the key is validated ahead of time and
// we use an algorithm guaranteed to exist
throw new IllegalStateException(
"Unable to initialise encryption cipher with algorithm " + encryptionKeySpec.getAlgorithm()
+ " and format " + encryptionKeySpec.getFormat() + ": " + e.getMessage(),
e);
} catch (final IllegalBlockSizeException | BadPaddingException e) {
// these should not happen as we control the block size and padding
throw new IllegalStateException("Unable to encrypt data: " + e.getMessage(), e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.LawOfDemeter\"",
")",
"public",
"byte",
"[",
"]",
"encrypt",
"(",
"final",
"byte",
"[",
"]",
"payload",
",",
"final",
"IvParameterSpec",
"initializationVector",
")",
"{",
"final",
"SecretKeySpec",
"encryptionKeySpec",
"=",
"get... | Encrypt a payload to embed in a Fernet token
@param payload the raw bytes of the data to store in a token
@param initializationVector random bytes from a high-entropy source to initialise the AES cipher
@return the AES-encrypted payload. The length will always be a multiple of 16 (128 bits).
@see #decrypt(byte[], IvParameterSpec) | [
"Encrypt",
"a",
"payload",
"to",
"embed",
"in",
"a",
"Fernet",
"token"
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-java8/src/main/java/com/macasaet/fernet/Key.java#L149-L170 |
137,037 | l0s/fernet-java8 | fernet-java8/src/main/java/com/macasaet/fernet/Key.java | Key.decrypt | @SuppressWarnings("PMD.LawOfDemeter")
public byte[] decrypt(final byte[] cipherText, final IvParameterSpec initializationVector) {
try {
final Cipher cipher = Cipher.getInstance(getCipherTransformation());
cipher.init(DECRYPT_MODE, getEncryptionKeySpec(), initializationVector);
return cipher.doFinal(cipherText);
} catch (final NoSuchAlgorithmException | NoSuchPaddingException
| InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException e) {
// this should not happen as we use an algorithm (AES) and padding
// (PKCS5) that are guaranteed to exist.
// in addition, we validate the encryption key and initialization vector up front
throw new IllegalStateException(e.getMessage(), e);
} catch (final BadPaddingException bpe) {
throw new TokenValidationException("Invalid padding in token: " + bpe.getMessage(), bpe);
}
} | java | @SuppressWarnings("PMD.LawOfDemeter")
public byte[] decrypt(final byte[] cipherText, final IvParameterSpec initializationVector) {
try {
final Cipher cipher = Cipher.getInstance(getCipherTransformation());
cipher.init(DECRYPT_MODE, getEncryptionKeySpec(), initializationVector);
return cipher.doFinal(cipherText);
} catch (final NoSuchAlgorithmException | NoSuchPaddingException
| InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException e) {
// this should not happen as we use an algorithm (AES) and padding
// (PKCS5) that are guaranteed to exist.
// in addition, we validate the encryption key and initialization vector up front
throw new IllegalStateException(e.getMessage(), e);
} catch (final BadPaddingException bpe) {
throw new TokenValidationException("Invalid padding in token: " + bpe.getMessage(), bpe);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.LawOfDemeter\"",
")",
"public",
"byte",
"[",
"]",
"decrypt",
"(",
"final",
"byte",
"[",
"]",
"cipherText",
",",
"final",
"IvParameterSpec",
"initializationVector",
")",
"{",
"try",
"{",
"final",
"Cipher",
"cipher",
"=",
"Ci... | Decrypt the payload of a Fernet token.
@param cipherText the padded encrypted payload of a token. The length <em>must</em> be a multiple of 16 (128 bits).
@param initializationVector the random bytes used in the AES encryption of the token
@return the decrypted payload
@see Key#encrypt(byte[], IvParameterSpec) | [
"Decrypt",
"the",
"payload",
"of",
"a",
"Fernet",
"token",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-java8/src/main/java/com/macasaet/fernet/Key.java#L180-L195 |
137,038 | l0s/fernet-java8 | fernet-java8/src/main/java/com/macasaet/fernet/Key.java | Key.writeTo | public void writeTo(final OutputStream outputStream) throws IOException {
outputStream.write(getSigningKey());
outputStream.write(getEncryptionKey());
} | java | public void writeTo(final OutputStream outputStream) throws IOException {
outputStream.write(getSigningKey());
outputStream.write(getEncryptionKey());
} | [
"public",
"void",
"writeTo",
"(",
"final",
"OutputStream",
"outputStream",
")",
"throws",
"IOException",
"{",
"outputStream",
".",
"write",
"(",
"getSigningKey",
"(",
")",
")",
";",
"outputStream",
".",
"write",
"(",
"getEncryptionKey",
"(",
")",
")",
";",
"... | Write the raw bytes of this key to the specified output stream.
@param outputStream
the target
@throws IOException
if the underlying I/O device cannot be written to | [
"Write",
"the",
"raw",
"bytes",
"of",
"this",
"key",
"to",
"the",
"specified",
"output",
"stream",
"."
] | 427244bc1af605ffca0ac2469d66b297ea9f77b3 | https://github.com/l0s/fernet-java8/blob/427244bc1af605ffca0ac2469d66b297ea9f77b3/fernet-java8/src/main/java/com/macasaet/fernet/Key.java#L219-L222 |
137,039 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/component/partrenderer/RenderUtils.java | RenderUtils.renderJQueryPluginCall | public static void renderJQueryPluginCall(final String elementId, final String pluginFunctionCall,
final ResponseWriter writer, final UIComponent uiComponent)
throws IOException {
final String jsCall = createJQueryPluginCall(elementId, pluginFunctionCall);
writer.startElement("script", uiComponent);
writer.writeText(jsCall, null);
writer.endElement("script");
} | java | public static void renderJQueryPluginCall(final String elementId, final String pluginFunctionCall,
final ResponseWriter writer, final UIComponent uiComponent)
throws IOException {
final String jsCall = createJQueryPluginCall(elementId, pluginFunctionCall);
writer.startElement("script", uiComponent);
writer.writeText(jsCall, null);
writer.endElement("script");
} | [
"public",
"static",
"void",
"renderJQueryPluginCall",
"(",
"final",
"String",
"elementId",
",",
"final",
"String",
"pluginFunctionCall",
",",
"final",
"ResponseWriter",
"writer",
",",
"final",
"UIComponent",
"uiComponent",
")",
"throws",
"IOException",
"{",
"final",
... | Renders a script element with a function call for a jquery plugin
@param elementId the html id of the element without leading # (e.g. 'myElementId')
@param pluginFunctionCall the plugin function call (e.g. 'tooltip()')
@param writer component writer
@param uiComponent component to add script
@throws java.io.IOException if writer throws an error | [
"Renders",
"a",
"script",
"element",
"with",
"a",
"function",
"call",
"for",
"a",
"jquery",
"plugin"
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/component/partrenderer/RenderUtils.java#L23-L31 |
137,040 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/event/HandleResourceListener.java | HandleResourceListener.processEvent | @Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
final UIViewRoot source = (UIViewRoot) event.getSource();
final FacesContext context = FacesContext.getCurrentInstance();
final WebXmlParameters webXmlParameters = new WebXmlParameters(context.getExternalContext());
final boolean provideJQuery = webXmlParameters.isProvideJQuery();
final boolean provideBootstrap = webXmlParameters.isProvideBoostrap();
final boolean useCompressedResources = webXmlParameters.isUseCompressedResources();
final boolean disablePrimeFacesJQuery = webXmlParameters.isIntegrationPrimeFacesDisableJQuery();
final List<UIComponent> resources = new ArrayList<>(source.getComponentResources(context, HEAD));
// Production mode and compressed
if (useCompressedResources && context.getApplication().getProjectStage() == ProjectStage.Production) {
handleCompressedResources(context, provideJQuery, provideBootstrap, resources, source);
} else {
handleConfigurableResources(context, provideJQuery, provideBootstrap, resources, source);
}
if (disablePrimeFacesJQuery) {
for (UIComponent resource : resources) {
final String resourceLibrary = (String) resource.getAttributes().get("library");
final String resourceName = (String) resource.getAttributes().get("name");
if ("primefaces".equals(resourceLibrary) && "jquery/jquery.js".equals(resourceName)) {
source.removeComponentResource(context, resource);
}
}
}
} | java | @Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
final UIViewRoot source = (UIViewRoot) event.getSource();
final FacesContext context = FacesContext.getCurrentInstance();
final WebXmlParameters webXmlParameters = new WebXmlParameters(context.getExternalContext());
final boolean provideJQuery = webXmlParameters.isProvideJQuery();
final boolean provideBootstrap = webXmlParameters.isProvideBoostrap();
final boolean useCompressedResources = webXmlParameters.isUseCompressedResources();
final boolean disablePrimeFacesJQuery = webXmlParameters.isIntegrationPrimeFacesDisableJQuery();
final List<UIComponent> resources = new ArrayList<>(source.getComponentResources(context, HEAD));
// Production mode and compressed
if (useCompressedResources && context.getApplication().getProjectStage() == ProjectStage.Production) {
handleCompressedResources(context, provideJQuery, provideBootstrap, resources, source);
} else {
handleConfigurableResources(context, provideJQuery, provideBootstrap, resources, source);
}
if (disablePrimeFacesJQuery) {
for (UIComponent resource : resources) {
final String resourceLibrary = (String) resource.getAttributes().get("library");
final String resourceName = (String) resource.getAttributes().get("name");
if ("primefaces".equals(resourceLibrary) && "jquery/jquery.js".equals(resourceName)) {
source.removeComponentResource(context, resource);
}
}
}
} | [
"@",
"Override",
"public",
"void",
"processEvent",
"(",
"SystemEvent",
"event",
")",
"throws",
"AbortProcessingException",
"{",
"final",
"UIViewRoot",
"source",
"=",
"(",
"UIViewRoot",
")",
"event",
".",
"getSource",
"(",
")",
";",
"final",
"FacesContext",
"cont... | Process event. Just the first time. | [
"Process",
"event",
".",
"Just",
"the",
"first",
"time",
"."
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/event/HandleResourceListener.java#L40-L68 |
137,041 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/event/HandleResourceListener.java | HandleResourceListener.handleCompressedResources | private void handleCompressedResources(final FacesContext context,
final boolean provideJQuery,
final boolean provideBootstrap,
final List<UIComponent> resources,
final UIViewRoot view) {
removeAllResourcesFromViewRoot(context, resources, view);
if (provideBootstrap && provideJQuery) {
this.addGeneratedCSSResource(context, "dist-butterfaces-bootstrap.min.css", view);
this.addGeneratedJSResource(context, "butterfaces-all-with-jquery-and-bootstrap-bundle.min.js",
"butterfaces-dist-bundle-js", view);
} else if (provideBootstrap) {
this.addGeneratedCSSResource(context, "dist-butterfaces-bootstrap.min.css", view);
this.addGeneratedJSResource(context, "butterfaces-all-with-bootstrap-bundle.min.js",
"butterfaces-dist-bundle-js", view);
} else if (provideJQuery) {
this.addGeneratedCSSResource(context, "dist-butterfaces-only.min.css", view);
this.addGeneratedJSResource(context, "butterfaces-all-with-jquery-bundle.min.js",
"butterfaces-dist-bundle-js", view);
} else {
this.addGeneratedCSSResource(context, "dist-butterfaces-only.min.css", view);
this.addGeneratedJSResource(context, "butterfaces-all-bundle.min.js", "butterfaces-dist-bundle-js", view);
}
// butterfaces first, and then libraries from the project to override css and js
for (UIComponent resource : resources) {
context.getViewRoot().addComponentResource(context, resource, HEAD);
}
} | java | private void handleCompressedResources(final FacesContext context,
final boolean provideJQuery,
final boolean provideBootstrap,
final List<UIComponent> resources,
final UIViewRoot view) {
removeAllResourcesFromViewRoot(context, resources, view);
if (provideBootstrap && provideJQuery) {
this.addGeneratedCSSResource(context, "dist-butterfaces-bootstrap.min.css", view);
this.addGeneratedJSResource(context, "butterfaces-all-with-jquery-and-bootstrap-bundle.min.js",
"butterfaces-dist-bundle-js", view);
} else if (provideBootstrap) {
this.addGeneratedCSSResource(context, "dist-butterfaces-bootstrap.min.css", view);
this.addGeneratedJSResource(context, "butterfaces-all-with-bootstrap-bundle.min.js",
"butterfaces-dist-bundle-js", view);
} else if (provideJQuery) {
this.addGeneratedCSSResource(context, "dist-butterfaces-only.min.css", view);
this.addGeneratedJSResource(context, "butterfaces-all-with-jquery-bundle.min.js",
"butterfaces-dist-bundle-js", view);
} else {
this.addGeneratedCSSResource(context, "dist-butterfaces-only.min.css", view);
this.addGeneratedJSResource(context, "butterfaces-all-bundle.min.js", "butterfaces-dist-bundle-js", view);
}
// butterfaces first, and then libraries from the project to override css and js
for (UIComponent resource : resources) {
context.getViewRoot().addComponentResource(context, resource, HEAD);
}
} | [
"private",
"void",
"handleCompressedResources",
"(",
"final",
"FacesContext",
"context",
",",
"final",
"boolean",
"provideJQuery",
",",
"final",
"boolean",
"provideBootstrap",
",",
"final",
"List",
"<",
"UIComponent",
">",
"resources",
",",
"final",
"UIViewRoot",
"v... | Use compressed resources. | [
"Use",
"compressed",
"resources",
"."
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/event/HandleResourceListener.java#L73-L101 |
137,042 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/event/HandleResourceListener.java | HandleResourceListener.removeAllResourcesFromViewRoot | private void removeAllResourcesFromViewRoot(final FacesContext context,
final List<UIComponent> resources,
final UIViewRoot view) {
final Iterator<UIComponent> it = resources.iterator();
while (it.hasNext()) {
final UIComponent resource = it.next();
final String resourceLibrary = (String) resource.getAttributes().get("library");
removeResource(context, resource, view);
if (resourceLibrary != null && resourceLibrary.startsWith("butterfaces"))
it.remove();
}
} | java | private void removeAllResourcesFromViewRoot(final FacesContext context,
final List<UIComponent> resources,
final UIViewRoot view) {
final Iterator<UIComponent> it = resources.iterator();
while (it.hasNext()) {
final UIComponent resource = it.next();
final String resourceLibrary = (String) resource.getAttributes().get("library");
removeResource(context, resource, view);
if (resourceLibrary != null && resourceLibrary.startsWith("butterfaces"))
it.remove();
}
} | [
"private",
"void",
"removeAllResourcesFromViewRoot",
"(",
"final",
"FacesContext",
"context",
",",
"final",
"List",
"<",
"UIComponent",
">",
"resources",
",",
"final",
"UIViewRoot",
"view",
")",
"{",
"final",
"Iterator",
"<",
"UIComponent",
">",
"it",
"=",
"reso... | Remove resources from the view. | [
"Remove",
"resources",
"from",
"the",
"view",
"."
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/event/HandleResourceListener.java#L106-L119 |
137,043 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/event/HandleResourceListener.java | HandleResourceListener.handleConfigurableResources | private void handleConfigurableResources(FacesContext context,
boolean provideJQuery,
boolean provideBootstrap,
List<UIComponent> resources,
UIViewRoot view) {
boolean isResourceAccepted;
for (UIComponent resource : resources) {
final String resourceLibrary = (String) resource.getAttributes().get("library");
final String resourceName = (String) resource.getAttributes().get("name");
isResourceAccepted = true;
if (resourceName != null && CONFIGURABLE_LIBRARY_NAME.equals(resourceLibrary)) {
if (!provideJQuery && resourceName.equals("butterfaces-third-party-jquery.js")) {
isResourceAccepted = false;
} else if (!provideBootstrap && resourceName.equals("butterfaces-third-party-bootstrap.js")) {
isResourceAccepted = false;
}
}
if (!isResourceAccepted)
removeResource(context, resource, view);
}
} | java | private void handleConfigurableResources(FacesContext context,
boolean provideJQuery,
boolean provideBootstrap,
List<UIComponent> resources,
UIViewRoot view) {
boolean isResourceAccepted;
for (UIComponent resource : resources) {
final String resourceLibrary = (String) resource.getAttributes().get("library");
final String resourceName = (String) resource.getAttributes().get("name");
isResourceAccepted = true;
if (resourceName != null && CONFIGURABLE_LIBRARY_NAME.equals(resourceLibrary)) {
if (!provideJQuery && resourceName.equals("butterfaces-third-party-jquery.js")) {
isResourceAccepted = false;
} else if (!provideBootstrap && resourceName.equals("butterfaces-third-party-bootstrap.js")) {
isResourceAccepted = false;
}
}
if (!isResourceAccepted)
removeResource(context, resource, view);
}
} | [
"private",
"void",
"handleConfigurableResources",
"(",
"FacesContext",
"context",
",",
"boolean",
"provideJQuery",
",",
"boolean",
"provideBootstrap",
",",
"List",
"<",
"UIComponent",
">",
"resources",
",",
"UIViewRoot",
"view",
")",
"{",
"boolean",
"isResourceAccepte... | Use normal resources | [
"Use",
"normal",
"resources"
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/event/HandleResourceListener.java#L124-L147 |
137,044 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/event/HandleResourceListener.java | HandleResourceListener.addGeneratedJSResource | private void addGeneratedJSResource(FacesContext context, String resourceName, String library, UIViewRoot view) {
addGeneratedResource(context, resourceName, "javax.faces.resource.Script", library, view);
} | java | private void addGeneratedJSResource(FacesContext context, String resourceName, String library, UIViewRoot view) {
addGeneratedResource(context, resourceName, "javax.faces.resource.Script", library, view);
} | [
"private",
"void",
"addGeneratedJSResource",
"(",
"FacesContext",
"context",
",",
"String",
"resourceName",
",",
"String",
"library",
",",
"UIViewRoot",
"view",
")",
"{",
"addGeneratedResource",
"(",
"context",
",",
"resourceName",
",",
"\"javax.faces.resource.Script\""... | Add a new JS resource. | [
"Add",
"a",
"new",
"JS",
"resource",
"."
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/event/HandleResourceListener.java#L152-L154 |
137,045 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/event/HandleResourceListener.java | HandleResourceListener.addGeneratedCSSResource | private void addGeneratedCSSResource(FacesContext context, String resourceName, UIViewRoot view) {
addGeneratedResource(context, resourceName, "javax.faces.resource.Stylesheet", "butterfaces-dist-css", view);
} | java | private void addGeneratedCSSResource(FacesContext context, String resourceName, UIViewRoot view) {
addGeneratedResource(context, resourceName, "javax.faces.resource.Stylesheet", "butterfaces-dist-css", view);
} | [
"private",
"void",
"addGeneratedCSSResource",
"(",
"FacesContext",
"context",
",",
"String",
"resourceName",
",",
"UIViewRoot",
"view",
")",
"{",
"addGeneratedResource",
"(",
"context",
",",
"resourceName",
",",
"\"javax.faces.resource.Stylesheet\"",
",",
"\"butterfaces-d... | Add a new css resource. | [
"Add",
"a",
"new",
"css",
"resource",
"."
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/event/HandleResourceListener.java#L159-L161 |
137,046 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/event/HandleResourceListener.java | HandleResourceListener.addGeneratedResource | private void addGeneratedResource(FacesContext context, String resourceName, String rendererType, String value,
UIViewRoot view) {
final UIOutput resource = new UIOutput();
resource.getAttributes().put("name", resourceName);
resource.setRendererType(rendererType);
resource.getAttributes().put("library", value);
view.addComponentResource(context, resource, HEAD);
} | java | private void addGeneratedResource(FacesContext context, String resourceName, String rendererType, String value,
UIViewRoot view) {
final UIOutput resource = new UIOutput();
resource.getAttributes().put("name", resourceName);
resource.setRendererType(rendererType);
resource.getAttributes().put("library", value);
view.addComponentResource(context, resource, HEAD);
} | [
"private",
"void",
"addGeneratedResource",
"(",
"FacesContext",
"context",
",",
"String",
"resourceName",
",",
"String",
"rendererType",
",",
"String",
"value",
",",
"UIViewRoot",
"view",
")",
"{",
"final",
"UIOutput",
"resource",
"=",
"new",
"UIOutput",
"(",
")... | Add a new resource. | [
"Add",
"a",
"new",
"resource",
"."
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/event/HandleResourceListener.java#L166-L173 |
137,047 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/event/HandleResourceListener.java | HandleResourceListener.removeResource | private void removeResource(FacesContext context, UIComponent resource, UIViewRoot view) {
view.removeComponentResource(context, resource, HEAD);
view.removeComponentResource(context, resource, TARGET);
} | java | private void removeResource(FacesContext context, UIComponent resource, UIViewRoot view) {
view.removeComponentResource(context, resource, HEAD);
view.removeComponentResource(context, resource, TARGET);
} | [
"private",
"void",
"removeResource",
"(",
"FacesContext",
"context",
",",
"UIComponent",
"resource",
",",
"UIViewRoot",
"view",
")",
"{",
"view",
".",
"removeComponentResource",
"(",
"context",
",",
"resource",
",",
"HEAD",
")",
";",
"view",
".",
"removeComponen... | Remove resource from head and target. | [
"Remove",
"resource",
"from",
"head",
"and",
"target",
"."
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/event/HandleResourceListener.java#L178-L181 |
137,048 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/component/renderkit/html_basic/text/part/TrivialComponentsEntriesNodePartRenderer.java | TrivialComponentsEntriesNodePartRenderer.renderNodes | public int renderNodes(final StringBuilder stringBuilder,
final List<Node> nodes,
final int index,
final List<String> mustacheKeys,
final Map<Integer, Node> cachedNodes) {
int newIndex = index;
final Iterator<Node> iterator = nodes.iterator();
while (iterator.hasNext()) {
final Node node = iterator.next();
newIndex = this.renderNode(stringBuilder, mustacheKeys, cachedNodes, newIndex, node, true);
if (iterator.hasNext()) {
stringBuilder.append(",");
}
}
return newIndex;
} | java | public int renderNodes(final StringBuilder stringBuilder,
final List<Node> nodes,
final int index,
final List<String> mustacheKeys,
final Map<Integer, Node> cachedNodes) {
int newIndex = index;
final Iterator<Node> iterator = nodes.iterator();
while (iterator.hasNext()) {
final Node node = iterator.next();
newIndex = this.renderNode(stringBuilder, mustacheKeys, cachedNodes, newIndex, node, true);
if (iterator.hasNext()) {
stringBuilder.append(",");
}
}
return newIndex;
} | [
"public",
"int",
"renderNodes",
"(",
"final",
"StringBuilder",
"stringBuilder",
",",
"final",
"List",
"<",
"Node",
">",
"nodes",
",",
"final",
"int",
"index",
",",
"final",
"List",
"<",
"String",
">",
"mustacheKeys",
",",
"final",
"Map",
"<",
"Integer",
",... | Renders a list of entities required by trivial components tree.
@param nodes a list of nodes that should be rendered
@param index index of corresponding node (should match cachedNodes
@param mustacheKeys optional mustache keys
@param cachedNodes a map of node number to node
@param stringBuilder the builder
@return the last rendered index + 1 | [
"Renders",
"a",
"list",
"of",
"entities",
"required",
"by",
"trivial",
"components",
"tree",
"."
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/component/renderkit/html_basic/text/part/TrivialComponentsEntriesNodePartRenderer.java#L36-L55 |
137,049 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/component/html/table/HtmlTable.java | HtmlTable.clearMetaInfo | public void clearMetaInfo(FacesContext context, UIComponent table) {
context.getAttributes().remove(createKey(table));
} | java | public void clearMetaInfo(FacesContext context, UIComponent table) {
context.getAttributes().remove(createKey(table));
} | [
"public",
"void",
"clearMetaInfo",
"(",
"FacesContext",
"context",
",",
"UIComponent",
"table",
")",
"{",
"context",
".",
"getAttributes",
"(",
")",
".",
"remove",
"(",
"createKey",
"(",
"table",
")",
")",
";",
"}"
] | Removes the cached TableColumnCache from the specified component.
@param context the <code>FacesContext</code> for the current request
@param table the table from which the TableColumnCache will be removed | [
"Removes",
"the",
"cached",
"TableColumnCache",
"from",
"the",
"specified",
"component",
"."
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/component/html/table/HtmlTable.java#L113-L115 |
137,050 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/component/base/renderer/HtmlBasicRenderer.java | HtmlBasicRenderer.renderBooleanValue | protected void renderBooleanValue(final UIComponent component,
final ResponseWriter writer,
final String attributeName) throws IOException {
if (component.getAttributes().get(attributeName) != null && Boolean.valueOf(component.getAttributes().get(attributeName).toString())) {
writer.writeAttribute(attributeName, true, attributeName);
}
} | java | protected void renderBooleanValue(final UIComponent component,
final ResponseWriter writer,
final String attributeName) throws IOException {
if (component.getAttributes().get(attributeName) != null && Boolean.valueOf(component.getAttributes().get(attributeName).toString())) {
writer.writeAttribute(attributeName, true, attributeName);
}
} | [
"protected",
"void",
"renderBooleanValue",
"(",
"final",
"UIComponent",
"component",
",",
"final",
"ResponseWriter",
"writer",
",",
"final",
"String",
"attributeName",
")",
"throws",
"IOException",
"{",
"if",
"(",
"component",
".",
"getAttributes",
"(",
")",
".",
... | Render boolean value if attribute is set to true.
@param attributeName attribute name
@param component the component
@param writer html response writer
@throws IOException thrown by writer | [
"Render",
"boolean",
"value",
"if",
"attribute",
"is",
"set",
"to",
"true",
"."
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/component/base/renderer/HtmlBasicRenderer.java#L149-L155 |
137,051 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/component/base/renderer/HtmlBasicRenderer.java | HtmlBasicRenderer.renderStringValue | protected void renderStringValue(final UIComponent component,
final ResponseWriter writer,
final String attributeName) throws IOException {
if (component.getAttributes().get(attributeName) != null
&& StringUtils.isNotEmpty(component.getAttributes().get(attributeName).toString())
&& shouldRenderAttribute(component.getAttributes().get(attributeName))) {
writer.writeAttribute(attributeName, component.getAttributes().get(attributeName).toString().trim(), attributeName);
}
} | java | protected void renderStringValue(final UIComponent component,
final ResponseWriter writer,
final String attributeName) throws IOException {
if (component.getAttributes().get(attributeName) != null
&& StringUtils.isNotEmpty(component.getAttributes().get(attributeName).toString())
&& shouldRenderAttribute(component.getAttributes().get(attributeName))) {
writer.writeAttribute(attributeName, component.getAttributes().get(attributeName).toString().trim(), attributeName);
}
} | [
"protected",
"void",
"renderStringValue",
"(",
"final",
"UIComponent",
"component",
",",
"final",
"ResponseWriter",
"writer",
",",
"final",
"String",
"attributeName",
")",
"throws",
"IOException",
"{",
"if",
"(",
"component",
".",
"getAttributes",
"(",
")",
".",
... | Render string value if attribute is not empty.
@param attributeName attribute name
@param component the component
@param writer html response writer
@throws IOException thrown by writer | [
"Render",
"string",
"value",
"if",
"attribute",
"is",
"not",
"empty",
"."
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/component/base/renderer/HtmlBasicRenderer.java#L165-L173 |
137,052 | ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/component/base/renderer/HtmlBasicRenderer.java | HtmlBasicRenderer.renderStringValue | protected void renderStringValue(final UIComponent component,
final ResponseWriter writer,
final String attributeName,
final String matchingValue) throws IOException {
if (component.getAttributes().get(attributeName) != null
&& matchingValue.equalsIgnoreCase(component.getAttributes().get(attributeName).toString())
&& shouldRenderAttribute(component.getAttributes().get(attributeName))) {
writer.writeAttribute(attributeName, matchingValue, attributeName);
}
} | java | protected void renderStringValue(final UIComponent component,
final ResponseWriter writer,
final String attributeName,
final String matchingValue) throws IOException {
if (component.getAttributes().get(attributeName) != null
&& matchingValue.equalsIgnoreCase(component.getAttributes().get(attributeName).toString())
&& shouldRenderAttribute(component.getAttributes().get(attributeName))) {
writer.writeAttribute(attributeName, matchingValue, attributeName);
}
} | [
"protected",
"void",
"renderStringValue",
"(",
"final",
"UIComponent",
"component",
",",
"final",
"ResponseWriter",
"writer",
",",
"final",
"String",
"attributeName",
",",
"final",
"String",
"matchingValue",
")",
"throws",
"IOException",
"{",
"if",
"(",
"component",... | Render string value if attribute is equals to matching value.
@param attributeName attribute name
@param component the component
@param writer html response writer
@param matchingValue matchingValue
@throws IOException thrown by writer | [
"Render",
"string",
"value",
"if",
"attribute",
"is",
"equals",
"to",
"matching",
"value",
"."
] | e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/component/base/renderer/HtmlBasicRenderer.java#L184-L193 |
137,053 | jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/HttpClient.java | HttpClient.get | public int get(String url) throws Exception {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.build();
try(Response response = client.newCall(request).execute()) {
if (!response.isSuccessful()) {
throw new Exception("error sending HTTP GET to this URL: " + url);
}
return response.code();
}
} | java | public int get(String url) throws Exception {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.build();
try(Response response = client.newCall(request).execute()) {
if (!response.isSuccessful()) {
throw new Exception("error sending HTTP GET to this URL: " + url);
}
return response.code();
}
} | [
"public",
"int",
"get",
"(",
"String",
"url",
")",
"throws",
"Exception",
"{",
"OkHttpClient",
"client",
"=",
"new",
"OkHttpClient",
"(",
")",
";",
"Request",
"request",
"=",
"new",
"Request",
".",
"Builder",
"(",
")",
".",
"url",
"(",
"url",
")",
".",... | HTTP GET to URL, return status
@param url URL
@return status code (for example 200)
@throws Exception When error | [
"HTTP",
"GET",
"to",
"URL",
"return",
"status"
] | 42e1f57bd936e21fe9df642e722726e71f667442 | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/HttpClient.java#L16-L27 |
137,054 | jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/generator/SitemapGenerator.java | SitemapGenerator.constructAdditionalNamespacesString | private String constructAdditionalNamespacesString(List<AdditionalNamespace> additionalNamespaceList) {
String result = "";
if (additionalNamespaceList.contains(AdditionalNamespace.IMAGE)) {
result += " xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\" ";
}
if (additionalNamespaceList.contains(AdditionalNamespace.XHTML)) {
result += " xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" ";
}
return result;
} | java | private String constructAdditionalNamespacesString(List<AdditionalNamespace> additionalNamespaceList) {
String result = "";
if (additionalNamespaceList.contains(AdditionalNamespace.IMAGE)) {
result += " xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\" ";
}
if (additionalNamespaceList.contains(AdditionalNamespace.XHTML)) {
result += " xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" ";
}
return result;
} | [
"private",
"String",
"constructAdditionalNamespacesString",
"(",
"List",
"<",
"AdditionalNamespace",
">",
"additionalNamespaceList",
")",
"{",
"String",
"result",
"=",
"\"\"",
";",
"if",
"(",
"additionalNamespaceList",
".",
"contains",
"(",
"AdditionalNamespace",
".",
... | Construct additional namespaces string
@param additionalNamespaceList
@return | [
"Construct",
"additional",
"namespaces",
"string"
] | 42e1f57bd936e21fe9df642e722726e71f667442 | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/generator/SitemapGenerator.java#L45-L54 |
137,055 | jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractGenerator.java | AbstractGenerator.addPage | public I addPage(WebPage webPage) {
beforeAddPageEvent(webPage);
urls.put(baseUrl + webPage.constructName(), webPage);
return getThis();
} | java | public I addPage(WebPage webPage) {
beforeAddPageEvent(webPage);
urls.put(baseUrl + webPage.constructName(), webPage);
return getThis();
} | [
"public",
"I",
"addPage",
"(",
"WebPage",
"webPage",
")",
"{",
"beforeAddPageEvent",
"(",
"webPage",
")",
";",
"urls",
".",
"put",
"(",
"baseUrl",
"+",
"webPage",
".",
"constructName",
"(",
")",
",",
"webPage",
")",
";",
"return",
"getThis",
"(",
")",
... | Add single page to sitemap
@param webPage single page
@return this | [
"Add",
"single",
"page",
"to",
"sitemap"
] | 42e1f57bd936e21fe9df642e722726e71f667442 | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractGenerator.java#L60-L64 |
137,056 | jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractGenerator.java | AbstractGenerator.addPage | public I addPage(StringSupplierWithException<String> supplier) {
try {
addPage(supplier.get());
} catch (Exception e) {
sneakyThrow(e);
}
return getThis();
} | java | public I addPage(StringSupplierWithException<String> supplier) {
try {
addPage(supplier.get());
} catch (Exception e) {
sneakyThrow(e);
}
return getThis();
} | [
"public",
"I",
"addPage",
"(",
"StringSupplierWithException",
"<",
"String",
">",
"supplier",
")",
"{",
"try",
"{",
"addPage",
"(",
"supplier",
".",
"get",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"sneakyThrow",
"(",
"e",
")",... | Add single page to sitemap.
@param supplier Supplier method which sneaks any checked exception
https://www.baeldung.com/java-sneaky-throws
Allows for calling method which performs some operation and then returns name of page.
@return this | [
"Add",
"single",
"page",
"to",
"sitemap",
"."
] | 42e1f57bd936e21fe9df642e722726e71f667442 | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractGenerator.java#L83-L90 |
137,057 | jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractGenerator.java | AbstractGenerator.run | public I run(RunnableWithException runnable) {
try {
runnable.run();
} catch (Exception e) {
sneakyThrow(e);
}
return getThis();
} | java | public I run(RunnableWithException runnable) {
try {
runnable.run();
} catch (Exception e) {
sneakyThrow(e);
}
return getThis();
} | [
"public",
"I",
"run",
"(",
"RunnableWithException",
"runnable",
")",
"{",
"try",
"{",
"runnable",
".",
"run",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"sneakyThrow",
"(",
"e",
")",
";",
"}",
"return",
"getThis",
"(",
")",
";",
... | Run some method
@param runnable Runnable method which sneaks any checked exception
https://www.baeldung.com/java-sneaky-throws
Usage:
SitemapIndexGenerator.of(homepage)
.run(() -> methodToCall())
.addPage(WebPage.of("test))
.toString()
@return this | [
"Run",
"some",
"method"
] | 42e1f57bd936e21fe9df642e722726e71f667442 | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractGenerator.java#L199-L206 |
137,058 | jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractSitemapGenerator.java | AbstractSitemapGenerator.toGzipByteArray | public byte[] toGzipByteArray() {
String sitemap = this.toString();
ByteArrayInputStream inputStream = new ByteArrayInputStream(sitemap.getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream outputStream = gzipIt(inputStream);
return outputStream.toByteArray();
} | java | public byte[] toGzipByteArray() {
String sitemap = this.toString();
ByteArrayInputStream inputStream = new ByteArrayInputStream(sitemap.getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream outputStream = gzipIt(inputStream);
return outputStream.toByteArray();
} | [
"public",
"byte",
"[",
"]",
"toGzipByteArray",
"(",
")",
"{",
"String",
"sitemap",
"=",
"this",
".",
"toString",
"(",
")",
";",
"ByteArrayInputStream",
"inputStream",
"=",
"new",
"ByteArrayInputStream",
"(",
"sitemap",
".",
"getBytes",
"(",
"StandardCharsets",
... | Construct sitemap into gzipped file
@return byte array | [
"Construct",
"sitemap",
"into",
"gzipped",
"file"
] | 42e1f57bd936e21fe9df642e722726e71f667442 | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractSitemapGenerator.java#L96-L101 |
137,059 | jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractSitemapGenerator.java | AbstractSitemapGenerator.saveSitemap | @Deprecated
public void saveSitemap(File file, String[] sitemap) throws IOException {
try(BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
for (String string : sitemap) {
writer.write(string);
}
}
} | java | @Deprecated
public void saveSitemap(File file, String[] sitemap) throws IOException {
try(BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
for (String string : sitemap) {
writer.write(string);
}
}
} | [
"@",
"Deprecated",
"public",
"void",
"saveSitemap",
"(",
"File",
"file",
",",
"String",
"[",
"]",
"sitemap",
")",
"throws",
"IOException",
"{",
"try",
"(",
"BufferedWriter",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"FileWriter",
"(",
"file",
")",
... | Save sitemap to output file
@param file
Output file
@param sitemap
Sitemap as array of Strings (created by constructSitemap()
method)
@throws IOException
when error
@deprecated Use {@link #toFile(Path)} instead | [
"Save",
"sitemap",
"to",
"output",
"file"
] | 42e1f57bd936e21fe9df642e722726e71f667442 | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractSitemapGenerator.java#L115-L122 |
137,060 | jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractSitemapGenerator.java | AbstractSitemapGenerator.toFile | public void toFile(File file) throws IOException {
String[] sitemap = toStringArray();
try(BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
for (String string : sitemap) {
writer.write(string);
}
}
} | java | public void toFile(File file) throws IOException {
String[] sitemap = toStringArray();
try(BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
for (String string : sitemap) {
writer.write(string);
}
}
} | [
"public",
"void",
"toFile",
"(",
"File",
"file",
")",
"throws",
"IOException",
"{",
"String",
"[",
"]",
"sitemap",
"=",
"toStringArray",
"(",
")",
";",
"try",
"(",
"BufferedWriter",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"FileWriter",
"(",
"fi... | Construct and save sitemap to output file
@param file
Output file
@throws IOException
when error | [
"Construct",
"and",
"save",
"sitemap",
"to",
"output",
"file"
] | 42e1f57bd936e21fe9df642e722726e71f667442 | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractSitemapGenerator.java#L132-L139 |
137,061 | jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractSitemapGenerator.java | AbstractSitemapGenerator.escapeXmlSpecialCharacters | protected String escapeXmlSpecialCharacters(String url) {
// https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents
return url
.replace("&", "&") // must be escaped first!!!
.replace("\"", """)
.replace("'", "'")
.replace("<", "<")
.replace(">", ">");
} | java | protected String escapeXmlSpecialCharacters(String url) {
// https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents
return url
.replace("&", "&") // must be escaped first!!!
.replace("\"", """)
.replace("'", "'")
.replace("<", "<")
.replace(">", ">");
} | [
"protected",
"String",
"escapeXmlSpecialCharacters",
"(",
"String",
"url",
")",
"{",
"// https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents",
"return",
"url",
".",
"replace",
"(",
"\"&\"",
",",
"\"&\"",
")",
"// must be escaped fi... | Escape special characters in XML
@param url Url to be escaped
@return Escaped url | [
"Escape",
"special",
"characters",
"in",
"XML"
] | 42e1f57bd936e21fe9df642e722726e71f667442 | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractSitemapGenerator.java#L238-L246 |
137,062 | jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractSitemapGenerator.java | AbstractSitemapGenerator.defaultPriority | public T defaultPriority(Double priority) {
if (priority < 0.0 || priority > 1.0) {
throw new InvalidPriorityException("Priority must be between 0 and 1.0");
}
defaultPriority = priority;
return getThis();
} | java | public T defaultPriority(Double priority) {
if (priority < 0.0 || priority > 1.0) {
throw new InvalidPriorityException("Priority must be between 0 and 1.0");
}
defaultPriority = priority;
return getThis();
} | [
"public",
"T",
"defaultPriority",
"(",
"Double",
"priority",
")",
"{",
"if",
"(",
"priority",
"<",
"0.0",
"||",
"priority",
">",
"1.0",
")",
"{",
"throw",
"new",
"InvalidPriorityException",
"(",
"\"Priority must be between 0 and 1.0\"",
")",
";",
"}",
"defaultPr... | Sets default priority for all subsequent WebPages
@param priority Default priority
@return this | [
"Sets",
"default",
"priority",
"for",
"all",
"subsequent",
"WebPages"
] | 42e1f57bd936e21fe9df642e722726e71f667442 | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractSitemapGenerator.java#L330-L336 |
137,063 | jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/generator/SitemapIndexGenerator.java | SitemapIndexGenerator.toStringArray | @Override
public String[] toStringArray() {
ArrayList<String> out = new ArrayList<>();
out.add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
out.add("<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n");
ArrayList<WebPage> values = new ArrayList<>(urls.values());
Collections.sort(values);
for (WebPage webPage : values) {
out.add(constructUrl(webPage));
}
out.add("</sitemapindex>");
return out.toArray(new String[] {});
} | java | @Override
public String[] toStringArray() {
ArrayList<String> out = new ArrayList<>();
out.add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
out.add("<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n");
ArrayList<WebPage> values = new ArrayList<>(urls.values());
Collections.sort(values);
for (WebPage webPage : values) {
out.add(constructUrl(webPage));
}
out.add("</sitemapindex>");
return out.toArray(new String[] {});
} | [
"@",
"Override",
"public",
"String",
"[",
"]",
"toStringArray",
"(",
")",
"{",
"ArrayList",
"<",
"String",
">",
"out",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"out",
".",
"add",
"(",
"\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\"",
")",
";",
... | Construct sitemap to String array
@return String array | [
"Construct",
"sitemap",
"to",
"String",
"array"
] | 42e1f57bd936e21fe9df642e722726e71f667442 | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/generator/SitemapIndexGenerator.java#L41-L53 |
137,064 | phax/ph-bdve | ph-bdve/src/main/java/com/helger/bdve/source/ValidationSource.java | ValidationSource.create | @Nonnull
public static ValidationSource create (@Nullable final String sSystemID, @Nonnull final Node aNode)
{
ValueEnforcer.notNull (aNode, "Node");
// Use the owner Document as fixed node
return new ValidationSource (sSystemID, XMLHelper.getOwnerDocument (aNode), false);
} | java | @Nonnull
public static ValidationSource create (@Nullable final String sSystemID, @Nonnull final Node aNode)
{
ValueEnforcer.notNull (aNode, "Node");
// Use the owner Document as fixed node
return new ValidationSource (sSystemID, XMLHelper.getOwnerDocument (aNode), false);
} | [
"@",
"Nonnull",
"public",
"static",
"ValidationSource",
"create",
"(",
"@",
"Nullable",
"final",
"String",
"sSystemID",
",",
"@",
"Nonnull",
"final",
"Node",
"aNode",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aNode",
",",
"\"Node\"",
")",
";",
"// Use... | Create a complete validation source from an existing DOM node.
@param sSystemID
System ID to use. May be <code>null</code>.
@param aNode
The node to use. May not be <code>null</code>.
@return Never <code>null</code>. | [
"Create",
"a",
"complete",
"validation",
"source",
"from",
"an",
"existing",
"DOM",
"node",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve/src/main/java/com/helger/bdve/source/ValidationSource.java#L105-L111 |
137,065 | phax/ph-bdve | ph-bdve/src/main/java/com/helger/bdve/source/ValidationSource.java | ValidationSource.createXMLSource | @Nonnull
public static ValidationSource createXMLSource (@Nonnull final IReadableResource aResource)
{
// Read on demand only
return new ValidationSource (aResource.getPath (), () -> DOMReader.readXMLDOM (aResource), false)
{
@Override
@Nonnull
public Source getAsTransformSource ()
{
// Use resource as TransformSource to get error line and column
return TransformSourceFactory.create (aResource);
}
};
} | java | @Nonnull
public static ValidationSource createXMLSource (@Nonnull final IReadableResource aResource)
{
// Read on demand only
return new ValidationSource (aResource.getPath (), () -> DOMReader.readXMLDOM (aResource), false)
{
@Override
@Nonnull
public Source getAsTransformSource ()
{
// Use resource as TransformSource to get error line and column
return TransformSourceFactory.create (aResource);
}
};
} | [
"@",
"Nonnull",
"public",
"static",
"ValidationSource",
"createXMLSource",
"(",
"@",
"Nonnull",
"final",
"IReadableResource",
"aResource",
")",
"{",
"// Read on demand only",
"return",
"new",
"ValidationSource",
"(",
"aResource",
".",
"getPath",
"(",
")",
",",
"(",
... | Assume the provided resource as an XML file, parse it and use the contained
DOM Node as the basis for validation.
@param aResource
The original resource. May not be <code>null</code>.
@return The validation source to be used. Never <code>null</code>. | [
"Assume",
"the",
"provided",
"resource",
"as",
"an",
"XML",
"file",
"parse",
"it",
"and",
"use",
"the",
"contained",
"DOM",
"Node",
"as",
"the",
"basis",
"for",
"validation",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve/src/main/java/com/helger/bdve/source/ValidationSource.java#L121-L135 |
137,066 | phax/ph-bdve | ph-bdve-ubl/src/main/java/com/helger/bdve/ubl/UBLValidation.java | UBLValidation.initUBL20 | public static void initUBL20 (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");
// For better error messages
LocationBeautifierSPI.addMappings (UBL20NamespaceContext.getInstance ());
final boolean bNotDeprecated = false;
for (final EUBL20DocumentType e : EUBL20DocumentType.values ())
{
final String sName = e.getLocalName ();
final VESID aVESID = new VESID (GROUP_ID, sName.toLowerCase (Locale.US), VERSION_20);
// No Schematrons here
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID,
"UBL " + sName + " " + VERSION_20,
bNotDeprecated,
ValidationExecutorXSD.create (e)));
}
} | java | public static void initUBL20 (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");
// For better error messages
LocationBeautifierSPI.addMappings (UBL20NamespaceContext.getInstance ());
final boolean bNotDeprecated = false;
for (final EUBL20DocumentType e : EUBL20DocumentType.values ())
{
final String sName = e.getLocalName ();
final VESID aVESID = new VESID (GROUP_ID, sName.toLowerCase (Locale.US), VERSION_20);
// No Schematrons here
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID,
"UBL " + sName + " " + VERSION_20,
bNotDeprecated,
ValidationExecutorXSD.create (e)));
}
} | [
"public",
"static",
"void",
"initUBL20",
"(",
"@",
"Nonnull",
"final",
"ValidationExecutorSetRegistry",
"aRegistry",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aRegistry",
",",
"\"Registry\"",
")",
";",
"// For better error messages",
"LocationBeautifierSPI",
".",... | Register all standard UBL 2.0 validation execution sets to the provided
registry.
@param aRegistry
The registry to add the artefacts. May not be <code>null</code>. | [
"Register",
"all",
"standard",
"UBL",
"2",
".",
"0",
"validation",
"execution",
"sets",
"to",
"the",
"provided",
"registry",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve-ubl/src/main/java/com/helger/bdve/ubl/UBLValidation.java#L342-L361 |
137,067 | phax/ph-bdve | ph-bdve-ubl/src/main/java/com/helger/bdve/ubl/UBLValidation.java | UBLValidation.initUBL21 | public static void initUBL21 (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");
// For better error messages
LocationBeautifierSPI.addMappings (UBL21NamespaceContext.getInstance ());
final boolean bNotDeprecated = false;
for (final EUBL21DocumentType e : EUBL21DocumentType.values ())
{
final String sName = e.getLocalName ();
final VESID aVESID = new VESID (GROUP_ID, sName.toLowerCase (Locale.US), VERSION_21);
// No Schematrons here
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID,
"UBL " + sName + " " + VERSION_21,
bNotDeprecated,
ValidationExecutorXSD.create (e)));
}
} | java | public static void initUBL21 (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");
// For better error messages
LocationBeautifierSPI.addMappings (UBL21NamespaceContext.getInstance ());
final boolean bNotDeprecated = false;
for (final EUBL21DocumentType e : EUBL21DocumentType.values ())
{
final String sName = e.getLocalName ();
final VESID aVESID = new VESID (GROUP_ID, sName.toLowerCase (Locale.US), VERSION_21);
// No Schematrons here
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID,
"UBL " + sName + " " + VERSION_21,
bNotDeprecated,
ValidationExecutorXSD.create (e)));
}
} | [
"public",
"static",
"void",
"initUBL21",
"(",
"@",
"Nonnull",
"final",
"ValidationExecutorSetRegistry",
"aRegistry",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aRegistry",
",",
"\"Registry\"",
")",
";",
"// For better error messages",
"LocationBeautifierSPI",
".",... | Register all standard UBL 2.1 validation execution sets to the provided
registry.
@param aRegistry
The registry to add the artefacts. May not be <code>null</code>. | [
"Register",
"all",
"standard",
"UBL",
"2",
".",
"1",
"validation",
"execution",
"sets",
"to",
"the",
"provided",
"registry",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve-ubl/src/main/java/com/helger/bdve/ubl/UBLValidation.java#L370-L389 |
137,068 | phax/ph-bdve | ph-bdve-ubl/src/main/java/com/helger/bdve/ubl/UBLValidation.java | UBLValidation.initUBL22 | public static void initUBL22 (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");
// For better error messages
LocationBeautifierSPI.addMappings (UBL22NamespaceContext.getInstance ());
final boolean bNotDeprecated = false;
for (final EUBL22DocumentType e : EUBL22DocumentType.values ())
{
final String sName = e.getLocalName ();
final VESID aVESID = new VESID (GROUP_ID, sName.toLowerCase (Locale.US), VERSION_22);
// No Schematrons here
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID,
"UBL " + sName + " " + VERSION_22,
bNotDeprecated,
ValidationExecutorXSD.create (e)));
}
} | java | public static void initUBL22 (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");
// For better error messages
LocationBeautifierSPI.addMappings (UBL22NamespaceContext.getInstance ());
final boolean bNotDeprecated = false;
for (final EUBL22DocumentType e : EUBL22DocumentType.values ())
{
final String sName = e.getLocalName ();
final VESID aVESID = new VESID (GROUP_ID, sName.toLowerCase (Locale.US), VERSION_22);
// No Schematrons here
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID,
"UBL " + sName + " " + VERSION_22,
bNotDeprecated,
ValidationExecutorXSD.create (e)));
}
} | [
"public",
"static",
"void",
"initUBL22",
"(",
"@",
"Nonnull",
"final",
"ValidationExecutorSetRegistry",
"aRegistry",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aRegistry",
",",
"\"Registry\"",
")",
";",
"// For better error messages",
"LocationBeautifierSPI",
".",... | Register all standard UBL 2.2 validation execution sets to the provided
registry.
@param aRegistry
The registry to add the artefacts. May not be <code>null</code>. | [
"Register",
"all",
"standard",
"UBL",
"2",
".",
"2",
"validation",
"execution",
"sets",
"to",
"the",
"provided",
"registry",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve-ubl/src/main/java/com/helger/bdve/ubl/UBLValidation.java#L398-L417 |
137,069 | phax/ph-bdve | ph-bdve-simplerinvoicing/src/main/java/com/helger/bdve/simplerinvoicing/SimplerInvoicingValidation.java | SimplerInvoicingValidation.initSimplerInvoicing | public static void initSimplerInvoicing (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");
// For better error messages
LocationBeautifierSPI.addMappings (UBL21NamespaceContext.getInstance ());
// SimplerInvoicing is self-contained
final boolean bNotDeprecated = false;
// 1.1
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_SI_INVOICE_V11,
"Simplerinvoicing Invoice 1.1",
bNotDeprecated,
ValidationExecutorXSD.create (EUBL21DocumentType.INVOICE),
_createXSLT (INVOICE_SI11)));
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_SI_INVOICE_V11_STRICT,
"Simplerinvoicing Invoice 1.1 (strict)",
bNotDeprecated,
ValidationExecutorXSD.create (EUBL21DocumentType.INVOICE),
_createXSLT (INVOICE_SI11_STRICT)));
// 1.2
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_SI_INVOICE_V12,
"Simplerinvoicing Invoice 1.2",
bNotDeprecated,
ValidationExecutorXSD.create (EUBL21DocumentType.INVOICE),
_createXSLT (INVOICE_SI12)));
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_SI_ORDER_V12,
"Simplerinvoicing Order 1.2",
bNotDeprecated,
ValidationExecutorXSD.create (EUBL21DocumentType.ORDER),
_createXSLT (ORDER_SI12)));
// 2.0
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_SI_INVOICE_V20,
"Simplerinvoicing Invoice 2.0",
bNotDeprecated,
ValidationExecutorXSD.create (EUBL21DocumentType.INVOICE),
_createXSLT (INVOICE_SI20)));
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_SI_CREDIT_NOTE_V20,
"Simplerinvoicing CreditNote 2.0",
bNotDeprecated,
ValidationExecutorXSD.create (EUBL21DocumentType.CREDIT_NOTE),
_createXSLT (INVOICE_SI20)));
} | java | public static void initSimplerInvoicing (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");
// For better error messages
LocationBeautifierSPI.addMappings (UBL21NamespaceContext.getInstance ());
// SimplerInvoicing is self-contained
final boolean bNotDeprecated = false;
// 1.1
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_SI_INVOICE_V11,
"Simplerinvoicing Invoice 1.1",
bNotDeprecated,
ValidationExecutorXSD.create (EUBL21DocumentType.INVOICE),
_createXSLT (INVOICE_SI11)));
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_SI_INVOICE_V11_STRICT,
"Simplerinvoicing Invoice 1.1 (strict)",
bNotDeprecated,
ValidationExecutorXSD.create (EUBL21DocumentType.INVOICE),
_createXSLT (INVOICE_SI11_STRICT)));
// 1.2
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_SI_INVOICE_V12,
"Simplerinvoicing Invoice 1.2",
bNotDeprecated,
ValidationExecutorXSD.create (EUBL21DocumentType.INVOICE),
_createXSLT (INVOICE_SI12)));
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_SI_ORDER_V12,
"Simplerinvoicing Order 1.2",
bNotDeprecated,
ValidationExecutorXSD.create (EUBL21DocumentType.ORDER),
_createXSLT (ORDER_SI12)));
// 2.0
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_SI_INVOICE_V20,
"Simplerinvoicing Invoice 2.0",
bNotDeprecated,
ValidationExecutorXSD.create (EUBL21DocumentType.INVOICE),
_createXSLT (INVOICE_SI20)));
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_SI_CREDIT_NOTE_V20,
"Simplerinvoicing CreditNote 2.0",
bNotDeprecated,
ValidationExecutorXSD.create (EUBL21DocumentType.CREDIT_NOTE),
_createXSLT (INVOICE_SI20)));
} | [
"public",
"static",
"void",
"initSimplerInvoicing",
"(",
"@",
"Nonnull",
"final",
"ValidationExecutorSetRegistry",
"aRegistry",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aRegistry",
",",
"\"Registry\"",
")",
";",
"// For better error messages",
"LocationBeautifierS... | Register all standard SimplerInvoicing validation execution sets to the
provided registry.
@param aRegistry
The registry to add the artefacts. May not be <code>null</code>. | [
"Register",
"all",
"standard",
"SimplerInvoicing",
"validation",
"execution",
"sets",
"to",
"the",
"provided",
"registry",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve-simplerinvoicing/src/main/java/com/helger/bdve/simplerinvoicing/SimplerInvoicingValidation.java#L92-L136 |
137,070 | phax/ph-bdve | ph-bdve/src/main/java/com/helger/bdve/executorset/ValidationExecutorSetRegistry.java | ValidationExecutorSetRegistry.registerValidationExecutorSet | @Nonnull
public <T extends IValidationExecutorSet> T registerValidationExecutorSet (@Nonnull final T aVES)
{
ValueEnforcer.notNull (aVES, "VES");
final VESID aKey = aVES.getID ();
m_aRWLock.writeLocked ( () -> {
if (m_aMap.containsKey (aKey))
throw new IllegalStateException ("Another validation executor set with the ID '" +
aKey +
"' is already registered!");
m_aMap.put (aKey, aVES);
});
return aVES;
} | java | @Nonnull
public <T extends IValidationExecutorSet> T registerValidationExecutorSet (@Nonnull final T aVES)
{
ValueEnforcer.notNull (aVES, "VES");
final VESID aKey = aVES.getID ();
m_aRWLock.writeLocked ( () -> {
if (m_aMap.containsKey (aKey))
throw new IllegalStateException ("Another validation executor set with the ID '" +
aKey +
"' is already registered!");
m_aMap.put (aKey, aVES);
});
return aVES;
} | [
"@",
"Nonnull",
"public",
"<",
"T",
"extends",
"IValidationExecutorSet",
">",
"T",
"registerValidationExecutorSet",
"(",
"@",
"Nonnull",
"final",
"T",
"aVES",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aVES",
",",
"\"VES\"",
")",
";",
"final",
"VESID",
... | Register a validation executor set into this registry.
@param aVES
The object to register. MAy not be <code>null</code>.
@return The passed parameter
@throws IllegalStateException
If another object with the same ID is already registered in this
registry.
@param <T>
The {@link IValidationExecutorSet} implementation that is added and
returned. | [
"Register",
"a",
"validation",
"executor",
"set",
"into",
"this",
"registry",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve/src/main/java/com/helger/bdve/executorset/ValidationExecutorSetRegistry.java#L77-L91 |
137,071 | phax/ph-bdve | ph-bdve/src/main/java/com/helger/bdve/executorset/ValidationExecutorSetRegistry.java | ValidationExecutorSetRegistry.getOfID | @Nullable
public IValidationExecutorSet getOfID (@Nullable final VESID aID)
{
if (aID == null)
return null;
return m_aRWLock.readLocked ( () -> m_aMap.get (aID));
} | java | @Nullable
public IValidationExecutorSet getOfID (@Nullable final VESID aID)
{
if (aID == null)
return null;
return m_aRWLock.readLocked ( () -> m_aMap.get (aID));
} | [
"@",
"Nullable",
"public",
"IValidationExecutorSet",
"getOfID",
"(",
"@",
"Nullable",
"final",
"VESID",
"aID",
")",
"{",
"if",
"(",
"aID",
"==",
"null",
")",
"return",
"null",
";",
"return",
"m_aRWLock",
".",
"readLocked",
"(",
"(",
")",
"->",
"m_aMap",
... | Find the validation executor set with the specified ID.
@param aID
The ID to search. May be <code>null</code>.
@return <code>null</code> if no such validation executor set is registered. | [
"Find",
"the",
"validation",
"executor",
"set",
"with",
"the",
"specified",
"ID",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve/src/main/java/com/helger/bdve/executorset/ValidationExecutorSetRegistry.java#L140-L147 |
137,072 | phax/ph-bdve | ph-bdve-peppol/src/main/java/com/helger/bdve/peppol/PeppolValidation.java | PeppolValidation.initStandard | @SuppressWarnings ("deprecation")
public static void initStandard (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
// For better error messages
LocationBeautifierSPI.addMappings (UBL21NamespaceContext.getInstance ());
PeppolValidation350.init (aRegistry);
PeppolValidation360.init (aRegistry);
PeppolValidation370.init (aRegistry);
} | java | @SuppressWarnings ("deprecation")
public static void initStandard (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
// For better error messages
LocationBeautifierSPI.addMappings (UBL21NamespaceContext.getInstance ());
PeppolValidation350.init (aRegistry);
PeppolValidation360.init (aRegistry);
PeppolValidation370.init (aRegistry);
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"static",
"void",
"initStandard",
"(",
"@",
"Nonnull",
"final",
"ValidationExecutorSetRegistry",
"aRegistry",
")",
"{",
"// For better error messages",
"LocationBeautifierSPI",
".",
"addMappings",
"(",
"UBL21... | Register all standard PEPPOL validation execution sets to the provided
registry.
@param aRegistry
The registry to add the artefacts. May not be <code>null</code>. | [
"Register",
"all",
"standard",
"PEPPOL",
"validation",
"execution",
"sets",
"to",
"the",
"provided",
"registry",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve-peppol/src/main/java/com/helger/bdve/peppol/PeppolValidation.java#L103-L112 |
137,073 | phax/ph-bdve | ph-bdve-cii/src/main/java/com/helger/bdve/cii/CIIValidation.java | CIIValidation.initCIID16B | public static void initCIID16B (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");
// For better error messages
LocationBeautifierSPI.addMappings (CIID16BNamespaceContext.getInstance ());
final boolean bNotDeprecated = false;
for (final ECIID16BDocumentType e : ECIID16BDocumentType.values ())
{
final String sName = e.getLocalName ();
final VESID aVESID = new VESID (GROUP_ID, sName.toLowerCase (Locale.US), VERSION_D16B);
// No Schematrons here
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID,
"CII " + sName + " " + VERSION_D16B,
bNotDeprecated,
ValidationExecutorXSD.create (e)));
}
} | java | public static void initCIID16B (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");
// For better error messages
LocationBeautifierSPI.addMappings (CIID16BNamespaceContext.getInstance ());
final boolean bNotDeprecated = false;
for (final ECIID16BDocumentType e : ECIID16BDocumentType.values ())
{
final String sName = e.getLocalName ();
final VESID aVESID = new VESID (GROUP_ID, sName.toLowerCase (Locale.US), VERSION_D16B);
// No Schematrons here
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID,
"CII " + sName + " " + VERSION_D16B,
bNotDeprecated,
ValidationExecutorXSD.create (e)));
}
} | [
"public",
"static",
"void",
"initCIID16B",
"(",
"@",
"Nonnull",
"final",
"ValidationExecutorSetRegistry",
"aRegistry",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aRegistry",
",",
"\"Registry\"",
")",
";",
"// For better error messages",
"LocationBeautifierSPI",
".... | Register all standard CII D16B validation execution sets to the provided
registry.
@param aRegistry
The registry to add the artefacts. May not be <code>null</code>. | [
"Register",
"all",
"standard",
"CII",
"D16B",
"validation",
"execution",
"sets",
"to",
"the",
"provided",
"registry",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve-cii/src/main/java/com/helger/bdve/cii/CIIValidation.java#L58-L77 |
137,074 | phax/ph-bdve | ph-bdve/src/main/java/com/helger/bdve/execute/ValidationExecutionManager.java | ValidationExecutionManager.addExecutors | @Nonnull
public final ValidationExecutionManager addExecutors (@Nullable final IValidationExecutor... aExecutors)
{
if (aExecutors != null)
for (final IValidationExecutor aExecutor : aExecutors)
addExecutor (aExecutor);
return this;
} | java | @Nonnull
public final ValidationExecutionManager addExecutors (@Nullable final IValidationExecutor... aExecutors)
{
if (aExecutors != null)
for (final IValidationExecutor aExecutor : aExecutors)
addExecutor (aExecutor);
return this;
} | [
"@",
"Nonnull",
"public",
"final",
"ValidationExecutionManager",
"addExecutors",
"(",
"@",
"Nullable",
"final",
"IValidationExecutor",
"...",
"aExecutors",
")",
"{",
"if",
"(",
"aExecutors",
"!=",
"null",
")",
"for",
"(",
"final",
"IValidationExecutor",
"aExecutor",... | Add 0-n executors at once.
@param aExecutors
The executors to be added. May be <code>null</code> but may not
contain <code>null</code> values.
@return this for chaining
@see #addExecutor(IValidationExecutor) | [
"Add",
"0",
"-",
"n",
"executors",
"at",
"once",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve/src/main/java/com/helger/bdve/execute/ValidationExecutionManager.java#L110-L117 |
137,075 | phax/ph-bdve | ph-bdve/src/main/java/com/helger/bdve/execute/ValidationExecutionManager.java | ValidationExecutionManager.executeValidation | @Nonnull
public ValidationResultList executeValidation (@Nonnull final IValidationSource aSource)
{
return executeValidation (aSource, (Locale) null);
} | java | @Nonnull
public ValidationResultList executeValidation (@Nonnull final IValidationSource aSource)
{
return executeValidation (aSource, (Locale) null);
} | [
"@",
"Nonnull",
"public",
"ValidationResultList",
"executeValidation",
"(",
"@",
"Nonnull",
"final",
"IValidationSource",
"aSource",
")",
"{",
"return",
"executeValidation",
"(",
"aSource",
",",
"(",
"Locale",
")",
"null",
")",
";",
"}"
] | Perform a validation with all the contained executors and the system
default locale.
@param aSource
The source artefact to be validated. May not be <code>null</code>.
contained executor a result is added to the result list.
@return The validation result list. Never <code>null</code>. For each
contained executor a result is added to the result list.
@see #executeValidation(IValidationSource, ValidationResultList, Locale)
@since 5.1.1 | [
"Perform",
"a",
"validation",
"with",
"all",
"the",
"contained",
"executors",
"and",
"the",
"system",
"default",
"locale",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve/src/main/java/com/helger/bdve/execute/ValidationExecutionManager.java#L278-L282 |
137,076 | phax/ph-bdve | ph-bdve/src/main/java/com/helger/bdve/executorset/ValidationExecutorSet.java | ValidationExecutorSet.createDerived | @Nonnull
public static ValidationExecutorSet createDerived (@Nonnull final IValidationExecutorSet aBaseVES,
@Nonnull final VESID aID,
@Nonnull @Nonempty final String sDisplayName,
final boolean bIsDeprecated,
@Nonnull final IValidationExecutor... aValidationExecutors)
{
ValueEnforcer.notNull (aBaseVES, "BaseVES");
ValueEnforcer.notNull (aID, "ID");
ValueEnforcer.notEmpty (sDisplayName, "DisplayName");
ValueEnforcer.notEmptyNoNullValue (aValidationExecutors, "ValidationExecutors");
final ValidationExecutorSet ret = new ValidationExecutorSet (aID,
sDisplayName,
bIsDeprecated || aBaseVES.isDeprecated ());
// Copy all existing ones
for (final IValidationExecutor aVE : aBaseVES)
ret.addExecutor (aVE);
// Add Schematrons
for (final IValidationExecutor aVE : aValidationExecutors)
ret.addExecutor (aVE);
return ret;
} | java | @Nonnull
public static ValidationExecutorSet createDerived (@Nonnull final IValidationExecutorSet aBaseVES,
@Nonnull final VESID aID,
@Nonnull @Nonempty final String sDisplayName,
final boolean bIsDeprecated,
@Nonnull final IValidationExecutor... aValidationExecutors)
{
ValueEnforcer.notNull (aBaseVES, "BaseVES");
ValueEnforcer.notNull (aID, "ID");
ValueEnforcer.notEmpty (sDisplayName, "DisplayName");
ValueEnforcer.notEmptyNoNullValue (aValidationExecutors, "ValidationExecutors");
final ValidationExecutorSet ret = new ValidationExecutorSet (aID,
sDisplayName,
bIsDeprecated || aBaseVES.isDeprecated ());
// Copy all existing ones
for (final IValidationExecutor aVE : aBaseVES)
ret.addExecutor (aVE);
// Add Schematrons
for (final IValidationExecutor aVE : aValidationExecutors)
ret.addExecutor (aVE);
return ret;
} | [
"@",
"Nonnull",
"public",
"static",
"ValidationExecutorSet",
"createDerived",
"(",
"@",
"Nonnull",
"final",
"IValidationExecutorSet",
"aBaseVES",
",",
"@",
"Nonnull",
"final",
"VESID",
"aID",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sDisplayName",
... | Create a derived VES from an existing VES. This means that only Schematrons
can be added, but the XSDs are taken from the base VES only.
@param aBaseVES
The base VES to copy from. May not be <code>null</code>.
@param aID
The ID to use. May not be <code>null</code>.
@param sDisplayName
The name of the VES. May neither be <code>null</code> nor empty.
@param bIsDeprecated
<code>true</code> if this VES is considered deprecated,
<code>false</code> if not.
@param aValidationExecutors
The resources to be associated with the VES. May not be
<code>null</code>.
@return The newly created VES. Never <code>null</code>. | [
"Create",
"a",
"derived",
"VES",
"from",
"an",
"existing",
"VES",
".",
"This",
"means",
"that",
"only",
"Schematrons",
"can",
"be",
"added",
"but",
"the",
"XSDs",
"are",
"taken",
"from",
"the",
"base",
"VES",
"only",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve/src/main/java/com/helger/bdve/executorset/ValidationExecutorSet.java#L195-L220 |
137,077 | phax/ph-bdve | ph-bdve/src/main/java/com/helger/bdve/result/ValidationResultList.java | ValidationResultList.getAllCount | @Nonnegative
public int getAllCount (@Nullable final Predicate <? super IError> aFilter)
{
int ret = 0;
for (final ValidationResult aItem : this)
ret += aItem.getErrorList ().getCount (aFilter);
return ret;
} | java | @Nonnegative
public int getAllCount (@Nullable final Predicate <? super IError> aFilter)
{
int ret = 0;
for (final ValidationResult aItem : this)
ret += aItem.getErrorList ().getCount (aFilter);
return ret;
} | [
"@",
"Nonnegative",
"public",
"int",
"getAllCount",
"(",
"@",
"Nullable",
"final",
"Predicate",
"<",
"?",
"super",
"IError",
">",
"aFilter",
")",
"{",
"int",
"ret",
"=",
"0",
";",
"for",
"(",
"final",
"ValidationResult",
"aItem",
":",
"this",
")",
"ret",... | Count all items according to the provided filter.
@param aFilter
Optional filter to use. May be <code>null</code>.
@return The number of errors matching the provided filter. | [
"Count",
"all",
"items",
"according",
"to",
"the",
"provided",
"filter",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve/src/main/java/com/helger/bdve/result/ValidationResultList.java#L113-L120 |
137,078 | phax/ph-bdve | ph-bdve/src/main/java/com/helger/bdve/result/ValidationResultList.java | ValidationResultList.forEachFlattened | public void forEachFlattened (@Nonnull final Consumer <? super IError> aConsumer)
{
for (final ValidationResult aItem : this)
aItem.getErrorList ().forEach (aConsumer);
} | java | public void forEachFlattened (@Nonnull final Consumer <? super IError> aConsumer)
{
for (final ValidationResult aItem : this)
aItem.getErrorList ().forEach (aConsumer);
} | [
"public",
"void",
"forEachFlattened",
"(",
"@",
"Nonnull",
"final",
"Consumer",
"<",
"?",
"super",
"IError",
">",
"aConsumer",
")",
"{",
"for",
"(",
"final",
"ValidationResult",
"aItem",
":",
"this",
")",
"aItem",
".",
"getErrorList",
"(",
")",
".",
"forEa... | Invoke the provided consumer on all items.
@param aConsumer
Consumer to be invoked for each {@link IError}. May not be
<code>null</code>.
@since 4.0.0 | [
"Invoke",
"the",
"provided",
"consumer",
"on",
"all",
"items",
"."
] | 2438f491174cd8989567fcdf129b273bd217e89f | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve/src/main/java/com/helger/bdve/result/ValidationResultList.java#L130-L134 |
137,079 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/codec/MessageDigests.java | MessageDigests.md5Hex | public static String md5Hex(final String input) {
if (input == null) {
throw new NullPointerException("String is null");
}
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
// this should never happen
throw new RuntimeException(e);
}
byte[] hash = digest.digest(input.getBytes());
return DatatypeConverter.printHexBinary(hash);
} | java | public static String md5Hex(final String input) {
if (input == null) {
throw new NullPointerException("String is null");
}
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
// this should never happen
throw new RuntimeException(e);
}
byte[] hash = digest.digest(input.getBytes());
return DatatypeConverter.printHexBinary(hash);
} | [
"public",
"static",
"String",
"md5Hex",
"(",
"final",
"String",
"input",
")",
"{",
"if",
"(",
"input",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"String is null\"",
")",
";",
"}",
"MessageDigest",
"digest",
"=",
"null",
";",
"t... | Generates an MD5 hash hex string for the input string
@param input The input string
@return MD5 hash hex string | [
"Generates",
"an",
"MD5",
"hash",
"hex",
"string",
"for",
"the",
"input",
"string"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/codec/MessageDigests.java#L35-L52 |
137,080 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/log/direct/LogManager.java | LogManager.startup | private static synchronized void startup() {
try {
CONFIG = ApiConfigurations.fromProperties();
String clientName = ApiClients.getApiClient(LogManager.class, "/stackify-api-common.properties", "stackify-api-common");
LOG_APPENDER = new LogAppender<LogEvent>(clientName, new LogEventAdapter(CONFIG.getEnvDetail()), MaskerConfiguration.fromProperties(), CONFIG.getSkipJson());
LOG_APPENDER.activate(CONFIG);
} catch (Throwable t) {
LOGGER.error("Exception starting Stackify Log API service", t);
}
} | java | private static synchronized void startup() {
try {
CONFIG = ApiConfigurations.fromProperties();
String clientName = ApiClients.getApiClient(LogManager.class, "/stackify-api-common.properties", "stackify-api-common");
LOG_APPENDER = new LogAppender<LogEvent>(clientName, new LogEventAdapter(CONFIG.getEnvDetail()), MaskerConfiguration.fromProperties(), CONFIG.getSkipJson());
LOG_APPENDER.activate(CONFIG);
} catch (Throwable t) {
LOGGER.error("Exception starting Stackify Log API service", t);
}
} | [
"private",
"static",
"synchronized",
"void",
"startup",
"(",
")",
"{",
"try",
"{",
"CONFIG",
"=",
"ApiConfigurations",
".",
"fromProperties",
"(",
")",
";",
"String",
"clientName",
"=",
"ApiClients",
".",
"getApiClient",
"(",
"LogManager",
".",
"class",
",",
... | Start up the background thread that is processing logs | [
"Start",
"up",
"the",
"background",
"thread",
"that",
"is",
"processing",
"logs"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/log/direct/LogManager.java#L68-L79 |
137,081 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/log/direct/LogManager.java | LogManager.shutdown | public static synchronized void shutdown() {
if (LOG_APPENDER != null) {
try {
LOG_APPENDER.close();
} catch (Throwable t) {
LOGGER.error("Exception stopping Stackify Log API service", t);
}
}
} | java | public static synchronized void shutdown() {
if (LOG_APPENDER != null) {
try {
LOG_APPENDER.close();
} catch (Throwable t) {
LOGGER.error("Exception stopping Stackify Log API service", t);
}
}
} | [
"public",
"static",
"synchronized",
"void",
"shutdown",
"(",
")",
"{",
"if",
"(",
"LOG_APPENDER",
"!=",
"null",
")",
"{",
"try",
"{",
"LOG_APPENDER",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"LOGGER",
".",
"error",
... | Shut down the background thread that is processing logs | [
"Shut",
"down",
"the",
"background",
"thread",
"that",
"is",
"processing",
"logs"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/log/direct/LogManager.java#L84-L92 |
137,082 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/error/ErrorGovernor.java | ErrorGovernor.errorShouldBeSent | public boolean errorShouldBeSent(final StackifyError error) {
if (error == null) {
throw new NullPointerException("StackifyError is null");
}
boolean shouldBeProcessed = false;
long epochMinute = getUnixEpochMinutes();
synchronized (errorCounter) {
// increment the counter for this error
int errorCount = errorCounter.incrementCounter(error, epochMinute);
// check our throttling criteria
if (errorCount <= MAX_DUP_ERROR_PER_MINUTE) {
shouldBeProcessed = true;
}
// see if we need to purge our counters of expired entries
if (nextErrorToCounterCleanUp < epochMinute) {
errorCounter.purgeCounters(epochMinute);
nextErrorToCounterCleanUp = epochMinute + CLEAN_UP_MINUTES;
}
}
return shouldBeProcessed;
} | java | public boolean errorShouldBeSent(final StackifyError error) {
if (error == null) {
throw new NullPointerException("StackifyError is null");
}
boolean shouldBeProcessed = false;
long epochMinute = getUnixEpochMinutes();
synchronized (errorCounter) {
// increment the counter for this error
int errorCount = errorCounter.incrementCounter(error, epochMinute);
// check our throttling criteria
if (errorCount <= MAX_DUP_ERROR_PER_MINUTE) {
shouldBeProcessed = true;
}
// see if we need to purge our counters of expired entries
if (nextErrorToCounterCleanUp < epochMinute) {
errorCounter.purgeCounters(epochMinute);
nextErrorToCounterCleanUp = epochMinute + CLEAN_UP_MINUTES;
}
}
return shouldBeProcessed;
} | [
"public",
"boolean",
"errorShouldBeSent",
"(",
"final",
"StackifyError",
"error",
")",
"{",
"if",
"(",
"error",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"StackifyError is null\"",
")",
";",
"}",
"boolean",
"shouldBeProcessed",
"=",
... | Determines if the error should be sent based on our throttling criteria
@param error The error
@return True if this error should be sent to Stackify, false otherwise | [
"Determines",
"if",
"the",
"error",
"should",
"be",
"sent",
"based",
"on",
"our",
"throttling",
"criteria"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/error/ErrorGovernor.java#L55-L85 |
137,083 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/log/ServletLogContext.java | ServletLogContext.putTransactionId | public static void putTransactionId(final String transactionId) {
if ((transactionId != null) && (0 < transactionId.length())) {
MDC.put(TRANSACTION_ID, transactionId);
}
} | java | public static void putTransactionId(final String transactionId) {
if ((transactionId != null) && (0 < transactionId.length())) {
MDC.put(TRANSACTION_ID, transactionId);
}
} | [
"public",
"static",
"void",
"putTransactionId",
"(",
"final",
"String",
"transactionId",
")",
"{",
"if",
"(",
"(",
"transactionId",
"!=",
"null",
")",
"&&",
"(",
"0",
"<",
"transactionId",
".",
"length",
"(",
")",
")",
")",
"{",
"MDC",
".",
"put",
"(",... | Sets the transaction id in the logging context
@param transactionId The transaction id | [
"Sets",
"the",
"transaction",
"id",
"in",
"the",
"logging",
"context"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/log/ServletLogContext.java#L73-L77 |
137,084 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/log/ServletLogContext.java | ServletLogContext.putUser | public static void putUser(final String user) {
if ((user != null) && (0 < user.length())) {
MDC.put(USER, user);
}
} | java | public static void putUser(final String user) {
if ((user != null) && (0 < user.length())) {
MDC.put(USER, user);
}
} | [
"public",
"static",
"void",
"putUser",
"(",
"final",
"String",
"user",
")",
"{",
"if",
"(",
"(",
"user",
"!=",
"null",
")",
"&&",
"(",
"0",
"<",
"user",
".",
"length",
"(",
")",
")",
")",
"{",
"MDC",
".",
"put",
"(",
"USER",
",",
"user",
")",
... | Sets the user in the logging context
@param user The user | [
"Sets",
"the",
"user",
"in",
"the",
"logging",
"context"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/log/ServletLogContext.java#L97-L101 |
137,085 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/log/ServletLogContext.java | ServletLogContext.putWebRequest | public static void putWebRequest(final WebRequestDetail webRequest) {
if (webRequest != null) {
try {
String value = JSON.writeValueAsString(webRequest);
MDC.put(WEB_REQUEST, value);
} catch (Throwable t) {
// do nothing
}
}
} | java | public static void putWebRequest(final WebRequestDetail webRequest) {
if (webRequest != null) {
try {
String value = JSON.writeValueAsString(webRequest);
MDC.put(WEB_REQUEST, value);
} catch (Throwable t) {
// do nothing
}
}
} | [
"public",
"static",
"void",
"putWebRequest",
"(",
"final",
"WebRequestDetail",
"webRequest",
")",
"{",
"if",
"(",
"webRequest",
"!=",
"null",
")",
"{",
"try",
"{",
"String",
"value",
"=",
"JSON",
".",
"writeValueAsString",
"(",
"webRequest",
")",
";",
"MDC",... | Sets the web request in the logging context
@param webRequest The web request | [
"Sets",
"the",
"web",
"request",
"in",
"the",
"logging",
"context"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/log/ServletLogContext.java#L125-L134 |
137,086 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/log/LogBackgroundServiceScheduler.java | LogBackgroundServiceScheduler.update | public void update(final int numSent) {
// Reset the last HTTP error
lastHttpError = 0;
// adjust the schedule delay based on the number of messages sent in the last iteration
if (100 <= numSent) {
// messages are coming in quickly so decrease our delay
// minimum delay is 1 second
scheduleDelay = Math.max(Math.round(scheduleDelay / 2.0), ONE_SECOND);
} else if (numSent < 10) {
// messages are coming in rather slowly so increase our delay
// maximum delay is 5 seconds
scheduleDelay = Math.min(Math.round(1.25 * scheduleDelay), FIVE_SECONDS);
}
} | java | public void update(final int numSent) {
// Reset the last HTTP error
lastHttpError = 0;
// adjust the schedule delay based on the number of messages sent in the last iteration
if (100 <= numSent) {
// messages are coming in quickly so decrease our delay
// minimum delay is 1 second
scheduleDelay = Math.max(Math.round(scheduleDelay / 2.0), ONE_SECOND);
} else if (numSent < 10) {
// messages are coming in rather slowly so increase our delay
// maximum delay is 5 seconds
scheduleDelay = Math.min(Math.round(1.25 * scheduleDelay), FIVE_SECONDS);
}
} | [
"public",
"void",
"update",
"(",
"final",
"int",
"numSent",
")",
"{",
"// Reset the last HTTP error",
"lastHttpError",
"=",
"0",
";",
"// adjust the schedule delay based on the number of messages sent in the last iteration",
"if",
"(",
"100",
"<=",
"numSent",
")",
"{",
"/... | Sets the next scheduled delay based on the number of messages sent
@param numSent The number of log messages sent | [
"Sets",
"the",
"next",
"scheduled",
"delay",
"based",
"on",
"the",
"number",
"of",
"messages",
"sent"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/log/LogBackgroundServiceScheduler.java#L63-L86 |
137,087 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/lang/Throwables.java | Throwables.getCausalChain | public static List<Throwable> getCausalChain(final Throwable throwable) {
if (throwable == null) {
throw new NullPointerException("Throwable is null");
}
List<Throwable> causes = new ArrayList<Throwable>();
causes.add(throwable);
Throwable cause = throwable.getCause();
while ((cause != null) && (!causes.contains(cause))) {
causes.add(cause);
cause = cause.getCause();
}
return causes;
} | java | public static List<Throwable> getCausalChain(final Throwable throwable) {
if (throwable == null) {
throw new NullPointerException("Throwable is null");
}
List<Throwable> causes = new ArrayList<Throwable>();
causes.add(throwable);
Throwable cause = throwable.getCause();
while ((cause != null) && (!causes.contains(cause))) {
causes.add(cause);
cause = cause.getCause();
}
return causes;
} | [
"public",
"static",
"List",
"<",
"Throwable",
">",
"getCausalChain",
"(",
"final",
"Throwable",
"throwable",
")",
"{",
"if",
"(",
"throwable",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Throwable is null\"",
")",
";",
"}",
"List",
... | Returns the Throwable's cause chain as a list. The first entry is the Throwable followed by the cause chain.
@param throwable The Throwable
@return The Throwable and its cause chain | [
"Returns",
"the",
"Throwable",
"s",
"cause",
"chain",
"as",
"a",
"list",
".",
"The",
"first",
"entry",
"is",
"the",
"Throwable",
"followed",
"by",
"the",
"cause",
"chain",
"."
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/lang/Throwables.java#L36-L52 |
137,088 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/lang/Throwables.java | Throwables.toErrorItem | public static ErrorItem toErrorItem(final String logMessage, final Throwable t) {
// get a flat list of the throwable and the causal chain
List<Throwable> throwables = Throwables.getCausalChain(t);
// create and populate builders for all throwables
List<ErrorItem.Builder> builders = new ArrayList<ErrorItem.Builder>(throwables.size());
for (int i = 0; i < throwables.size(); ++i) {
if (i == 0) {
ErrorItem.Builder builder = toErrorItemBuilderWithoutCause(logMessage, throwables.get(i));
builders.add(builder);
} else {
ErrorItem.Builder builder = toErrorItemBuilderWithoutCause(null, throwables.get(i));
builders.add(builder);
}
}
// attach child errors to their parent in reverse order
for (int i = builders.size() - 1; 0 < i; --i) {
ErrorItem.Builder parent = builders.get(i - 1);
ErrorItem.Builder child = builders.get(i);
parent.innerError(child.build());
}
// return the assembled original error
return builders.get(0).build();
} | java | public static ErrorItem toErrorItem(final String logMessage, final Throwable t) {
// get a flat list of the throwable and the causal chain
List<Throwable> throwables = Throwables.getCausalChain(t);
// create and populate builders for all throwables
List<ErrorItem.Builder> builders = new ArrayList<ErrorItem.Builder>(throwables.size());
for (int i = 0; i < throwables.size(); ++i) {
if (i == 0) {
ErrorItem.Builder builder = toErrorItemBuilderWithoutCause(logMessage, throwables.get(i));
builders.add(builder);
} else {
ErrorItem.Builder builder = toErrorItemBuilderWithoutCause(null, throwables.get(i));
builders.add(builder);
}
}
// attach child errors to their parent in reverse order
for (int i = builders.size() - 1; 0 < i; --i) {
ErrorItem.Builder parent = builders.get(i - 1);
ErrorItem.Builder child = builders.get(i);
parent.innerError(child.build());
}
// return the assembled original error
return builders.get(0).build();
} | [
"public",
"static",
"ErrorItem",
"toErrorItem",
"(",
"final",
"String",
"logMessage",
",",
"final",
"Throwable",
"t",
")",
"{",
"// get a flat list of the throwable and the causal chain",
"List",
"<",
"Throwable",
">",
"throwables",
"=",
"Throwables",
".",
"getCausalCha... | Converts a Throwable to an ErrorItem
@param logMessage The log message (can be null)
@param t The Throwable to be converted
@return The ErrorItem | [
"Converts",
"a",
"Throwable",
"to",
"an",
"ErrorItem"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/lang/Throwables.java#L60-L92 |
137,089 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/lang/Throwables.java | Throwables.toErrorItemBuilderWithoutCause | private static ErrorItem.Builder toErrorItemBuilderWithoutCause(final String logMessage, final Throwable t) {
ErrorItem.Builder builder = ErrorItem.newBuilder();
builder.message(toErrorItemMessage(logMessage, t.getMessage()));
builder.errorType(t.getClass().getCanonicalName());
List<TraceFrame> stackFrames = new ArrayList<TraceFrame>();
StackTraceElement[] stackTrace = t.getStackTrace();
if ((stackTrace != null) && (0 < stackTrace.length)) {
StackTraceElement firstFrame = stackTrace[0];
builder.sourceMethod(firstFrame.getClassName() + "." + firstFrame.getMethodName());
for (int i = 0; i < stackTrace.length; ++i) {
TraceFrame stackFrame = StackTraceElements.toTraceFrame(stackTrace[i]);
stackFrames.add(stackFrame);
}
}
builder.stackTrace(stackFrames);
return builder;
} | java | private static ErrorItem.Builder toErrorItemBuilderWithoutCause(final String logMessage, final Throwable t) {
ErrorItem.Builder builder = ErrorItem.newBuilder();
builder.message(toErrorItemMessage(logMessage, t.getMessage()));
builder.errorType(t.getClass().getCanonicalName());
List<TraceFrame> stackFrames = new ArrayList<TraceFrame>();
StackTraceElement[] stackTrace = t.getStackTrace();
if ((stackTrace != null) && (0 < stackTrace.length)) {
StackTraceElement firstFrame = stackTrace[0];
builder.sourceMethod(firstFrame.getClassName() + "." + firstFrame.getMethodName());
for (int i = 0; i < stackTrace.length; ++i) {
TraceFrame stackFrame = StackTraceElements.toTraceFrame(stackTrace[i]);
stackFrames.add(stackFrame);
}
}
builder.stackTrace(stackFrames);
return builder;
} | [
"private",
"static",
"ErrorItem",
".",
"Builder",
"toErrorItemBuilderWithoutCause",
"(",
"final",
"String",
"logMessage",
",",
"final",
"Throwable",
"t",
")",
"{",
"ErrorItem",
".",
"Builder",
"builder",
"=",
"ErrorItem",
".",
"newBuilder",
"(",
")",
";",
"build... | Converts a Throwable to an ErrorItem.Builder and ignores the cause
@param logMessage The log message
@param t The Throwable to be converted
@return The ErrorItem.Builder without the innerError populated | [
"Converts",
"a",
"Throwable",
"to",
"an",
"ErrorItem",
".",
"Builder",
"and",
"ignores",
"the",
"cause"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/lang/Throwables.java#L109-L131 |
137,090 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/lang/Throwables.java | Throwables.toErrorItemMessage | private static String toErrorItemMessage(final String logMessage, final String throwableMessage) {
StringBuilder sb = new StringBuilder();
if ((throwableMessage != null) && (!throwableMessage.isEmpty())) {
sb.append(throwableMessage);
if ((logMessage != null) && (!logMessage.isEmpty())) {
sb.append(" (");
sb.append(logMessage);
sb.append(")");
}
} else {
sb.append(logMessage);
}
return sb.toString();
} | java | private static String toErrorItemMessage(final String logMessage, final String throwableMessage) {
StringBuilder sb = new StringBuilder();
if ((throwableMessage != null) && (!throwableMessage.isEmpty())) {
sb.append(throwableMessage);
if ((logMessage != null) && (!logMessage.isEmpty())) {
sb.append(" (");
sb.append(logMessage);
sb.append(")");
}
} else {
sb.append(logMessage);
}
return sb.toString();
} | [
"private",
"static",
"String",
"toErrorItemMessage",
"(",
"final",
"String",
"logMessage",
",",
"final",
"String",
"throwableMessage",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"(",
"throwableMessage",
"!=",
"null",
... | Constructs the error item message from the log message and the throwable's message
@param logMessage The log message (can be null)
@param throwableMessage The throwable's message (can be null)
@return The error item message | [
"Constructs",
"the",
"error",
"item",
"message",
"from",
"the",
"log",
"message",
"and",
"the",
"throwable",
"s",
"message"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/lang/Throwables.java#L139-L156 |
137,091 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/util/Maps.java | Maps.fromProperties | public static Map<String, String> fromProperties(final Properties props) {
Map<String, String> propMap = new HashMap<String, String>();
for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements();) {
String key = (String) e.nextElement();
propMap.put(key, props.getProperty(key));
}
return Collections.unmodifiableMap(propMap);
} | java | public static Map<String, String> fromProperties(final Properties props) {
Map<String, String> propMap = new HashMap<String, String>();
for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements();) {
String key = (String) e.nextElement();
propMap.put(key, props.getProperty(key));
}
return Collections.unmodifiableMap(propMap);
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"fromProperties",
"(",
"final",
"Properties",
"props",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"propMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",... | Converts properties to a String-String map
@param props Properties
@return String-String map of properties | [
"Converts",
"properties",
"to",
"a",
"String",
"-",
"String",
"map"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/util/Maps.java#L35-L44 |
137,092 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/log/LogSender.java | LogSender.executeMask | private void executeMask(final LogMsgGroup group) {
if (masker != null) {
if (group.getMsgs().size() > 0) {
for (LogMsg logMsg : group.getMsgs()) {
if (logMsg.getEx() != null) {
executeMask(logMsg.getEx().getError());
}
logMsg.setData(masker.mask(logMsg.getData()));
logMsg.setMsg(masker.mask(logMsg.getMsg()));
}
}
}
} | java | private void executeMask(final LogMsgGroup group) {
if (masker != null) {
if (group.getMsgs().size() > 0) {
for (LogMsg logMsg : group.getMsgs()) {
if (logMsg.getEx() != null) {
executeMask(logMsg.getEx().getError());
}
logMsg.setData(masker.mask(logMsg.getData()));
logMsg.setMsg(masker.mask(logMsg.getMsg()));
}
}
}
} | [
"private",
"void",
"executeMask",
"(",
"final",
"LogMsgGroup",
"group",
")",
"{",
"if",
"(",
"masker",
"!=",
"null",
")",
"{",
"if",
"(",
"group",
".",
"getMsgs",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"LogMsg",
"logMsg",
... | Applies masking to passed in LogMsgGroup. | [
"Applies",
"masking",
"to",
"passed",
"in",
"LogMsgGroup",
"."
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/log/LogSender.java#L134-L146 |
137,093 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/log/LogSender.java | LogSender.send | public int send(final LogMsgGroup group) throws IOException {
Preconditions.checkNotNull(group);
executeMask(group);
executeSkipJsonTag(group);
HttpClient httpClient = new HttpClient(apiConfig);
// retransmit any logs on the resend queue
resendQueue.drain(httpClient, LOG_SAVE_PATH, true);
// convert to json bytes
byte[] jsonBytes = objectMapper.writer().writeValueAsBytes(group);
// post to stackify
int statusCode = HttpURLConnection.HTTP_INTERNAL_ERROR;
try {
httpClient.post(LOG_SAVE_PATH, jsonBytes, true);
statusCode = HttpURLConnection.HTTP_OK;
} catch (IOException t) {
LOGGER.info("Queueing logs for retransmission due to IOException");
resendQueue.offer(jsonBytes, t);
throw t;
} catch (HttpException e) {
statusCode = e.getStatusCode();
LOGGER.info("Queueing logs for retransmission due to HttpException", e);
resendQueue.offer(jsonBytes, e);
}
return statusCode;
} | java | public int send(final LogMsgGroup group) throws IOException {
Preconditions.checkNotNull(group);
executeMask(group);
executeSkipJsonTag(group);
HttpClient httpClient = new HttpClient(apiConfig);
// retransmit any logs on the resend queue
resendQueue.drain(httpClient, LOG_SAVE_PATH, true);
// convert to json bytes
byte[] jsonBytes = objectMapper.writer().writeValueAsBytes(group);
// post to stackify
int statusCode = HttpURLConnection.HTTP_INTERNAL_ERROR;
try {
httpClient.post(LOG_SAVE_PATH, jsonBytes, true);
statusCode = HttpURLConnection.HTTP_OK;
} catch (IOException t) {
LOGGER.info("Queueing logs for retransmission due to IOException");
resendQueue.offer(jsonBytes, t);
throw t;
} catch (HttpException e) {
statusCode = e.getStatusCode();
LOGGER.info("Queueing logs for retransmission due to HttpException", e);
resendQueue.offer(jsonBytes, e);
}
return statusCode;
} | [
"public",
"int",
"send",
"(",
"final",
"LogMsgGroup",
"group",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"group",
")",
";",
"executeMask",
"(",
"group",
")",
";",
"executeSkipJsonTag",
"(",
"group",
")",
";",
"HttpClient",
... | Sends a group of log messages to Stackify
@param group The log message group
@return The HTTP status code returned from the HTTP POST
@throws IOException | [
"Sends",
"a",
"group",
"of",
"log",
"messages",
"to",
"Stackify"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/log/LogSender.java#L166-L200 |
137,094 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/EnvironmentDetails.java | EnvironmentDetails.getEnvironmentDetail | public static EnvironmentDetail getEnvironmentDetail(final String application, final String environment) {
// lookup the host name
String hostName = getHostName();
// lookup the current path
String currentPath = System.getProperty("user.dir");
// build the environment details
EnvironmentDetail.Builder environmentBuilder = EnvironmentDetail.newBuilder();
environmentBuilder.deviceName(hostName);
environmentBuilder.appLocation(currentPath);
environmentBuilder.configuredAppName(application);
environmentBuilder.configuredEnvironmentName(environment);
return environmentBuilder.build();
} | java | public static EnvironmentDetail getEnvironmentDetail(final String application, final String environment) {
// lookup the host name
String hostName = getHostName();
// lookup the current path
String currentPath = System.getProperty("user.dir");
// build the environment details
EnvironmentDetail.Builder environmentBuilder = EnvironmentDetail.newBuilder();
environmentBuilder.deviceName(hostName);
environmentBuilder.appLocation(currentPath);
environmentBuilder.configuredAppName(application);
environmentBuilder.configuredEnvironmentName(environment);
return environmentBuilder.build();
} | [
"public",
"static",
"EnvironmentDetail",
"getEnvironmentDetail",
"(",
"final",
"String",
"application",
",",
"final",
"String",
"environment",
")",
"{",
"// lookup the host name",
"String",
"hostName",
"=",
"getHostName",
"(",
")",
";",
"// lookup the current path",
"St... | Creates an environment details object with system information
@param application The configured application name
@param environment The configured application environment
@return The EnvironmentDetail object | [
"Creates",
"an",
"environment",
"details",
"object",
"with",
"system",
"information"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/EnvironmentDetails.java#L35-L54 |
137,095 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/log/direct/Logger.java | Logger.queueMessage | public static void queueMessage(final String level, final String message) {
try {
LogAppender<LogEvent> appender = LogManager.getAppender();
if (appender != null) {
LogEvent.Builder builder = LogEvent.newBuilder();
builder.level(level);
builder.message(message);
if ((level != null) && ("ERROR".equals(level.toUpperCase()))) {
StackTraceElement[] stackTrace = new Throwable().getStackTrace();
if ((stackTrace != null) && (1 < stackTrace.length)) {
StackTraceElement caller = stackTrace[1];
builder.className(caller.getClassName());
builder.methodName(caller.getMethodName());
builder.lineNumber(caller.getLineNumber());
}
}
appender.append(builder.build());
}
} catch (Throwable t) {
LOGGER.info("Unable to queue message to Stackify Log API service: {} {}", level, message, t);
}
} | java | public static void queueMessage(final String level, final String message) {
try {
LogAppender<LogEvent> appender = LogManager.getAppender();
if (appender != null) {
LogEvent.Builder builder = LogEvent.newBuilder();
builder.level(level);
builder.message(message);
if ((level != null) && ("ERROR".equals(level.toUpperCase()))) {
StackTraceElement[] stackTrace = new Throwable().getStackTrace();
if ((stackTrace != null) && (1 < stackTrace.length)) {
StackTraceElement caller = stackTrace[1];
builder.className(caller.getClassName());
builder.methodName(caller.getMethodName());
builder.lineNumber(caller.getLineNumber());
}
}
appender.append(builder.build());
}
} catch (Throwable t) {
LOGGER.info("Unable to queue message to Stackify Log API service: {} {}", level, message, t);
}
} | [
"public",
"static",
"void",
"queueMessage",
"(",
"final",
"String",
"level",
",",
"final",
"String",
"message",
")",
"{",
"try",
"{",
"LogAppender",
"<",
"LogEvent",
">",
"appender",
"=",
"LogManager",
".",
"getAppender",
"(",
")",
";",
"if",
"(",
"appende... | Queues a log message to be sent to Stackify
@param level The log level
@param message The log message | [
"Queues",
"a",
"log",
"message",
"to",
"be",
"sent",
"to",
"Stackify"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/log/direct/Logger.java#L38-L63 |
137,096 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/ApiClients.java | ApiClients.getApiClient | public static String getApiClient(final Class<?> apiClass, final String fileName, final String defaultClientName) {
InputStream propertiesStream = null;
try {
propertiesStream = apiClass.getResourceAsStream(fileName);
if (propertiesStream != null) {
Properties props = new Properties();
props.load(propertiesStream);
String name = (String) props.get("api-client.name");
String version = (String) props.get("api-client.version");
return name + "-" + version;
}
} catch (Throwable t) {
LOGGER.error("Exception reading {} configuration file", fileName, t);
} finally {
if (propertiesStream != null) {
try {
propertiesStream.close();
} catch (Throwable t) {
LOGGER.info("Exception closing {} configuration file", fileName, t);
}
}
}
return defaultClientName;
} | java | public static String getApiClient(final Class<?> apiClass, final String fileName, final String defaultClientName) {
InputStream propertiesStream = null;
try {
propertiesStream = apiClass.getResourceAsStream(fileName);
if (propertiesStream != null) {
Properties props = new Properties();
props.load(propertiesStream);
String name = (String) props.get("api-client.name");
String version = (String) props.get("api-client.version");
return name + "-" + version;
}
} catch (Throwable t) {
LOGGER.error("Exception reading {} configuration file", fileName, t);
} finally {
if (propertiesStream != null) {
try {
propertiesStream.close();
} catch (Throwable t) {
LOGGER.info("Exception closing {} configuration file", fileName, t);
}
}
}
return defaultClientName;
} | [
"public",
"static",
"String",
"getApiClient",
"(",
"final",
"Class",
"<",
"?",
">",
"apiClass",
",",
"final",
"String",
"fileName",
",",
"final",
"String",
"defaultClientName",
")",
"{",
"InputStream",
"propertiesStream",
"=",
"null",
";",
"try",
"{",
"propert... | Gets the client name from the properties file
@param fileName Properties file name
@param defaultClientName Default client name
@return The client name | [
"Gets",
"the",
"client",
"name",
"from",
"the",
"properties",
"file"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/ApiClients.java#L41-L70 |
137,097 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/error/ErrorCounter.java | ErrorCounter.getUniqueKey | public static String getUniqueKey(final ErrorItem errorItem) {
if (errorItem == null) {
throw new NullPointerException("ErrorItem is null");
}
String type = errorItem.getErrorType();
String typeCode = errorItem.getErrorTypeCode();
String method = errorItem.getSourceMethod();
String uniqueKey = String.format("%s-%s-%s", type, typeCode, method);
return MessageDigests.md5Hex(uniqueKey);
} | java | public static String getUniqueKey(final ErrorItem errorItem) {
if (errorItem == null) {
throw new NullPointerException("ErrorItem is null");
}
String type = errorItem.getErrorType();
String typeCode = errorItem.getErrorTypeCode();
String method = errorItem.getSourceMethod();
String uniqueKey = String.format("%s-%s-%s", type, typeCode, method);
return MessageDigests.md5Hex(uniqueKey);
} | [
"public",
"static",
"String",
"getUniqueKey",
"(",
"final",
"ErrorItem",
"errorItem",
")",
"{",
"if",
"(",
"errorItem",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"ErrorItem is null\"",
")",
";",
"}",
"String",
"type",
"=",
"errorIt... | Generates a unique key based on the error. The key will be an MD5 hash of the type, type code, and method.
@param errorItem The error item
@return The unique key for the error | [
"Generates",
"a",
"unique",
"key",
"based",
"on",
"the",
"error",
".",
"The",
"key",
"will",
"be",
"an",
"MD5",
"hash",
"of",
"the",
"type",
"type",
"code",
"and",
"method",
"."
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/error/ErrorCounter.java#L115-L127 |
137,098 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/error/ErrorCounter.java | ErrorCounter.incrementCounter | public int incrementCounter(final StackifyError error, long epochMinute) {
if (error == null) {
throw new NullPointerException("StackifyError is null");
}
ErrorItem baseError = getBaseError(error);
String uniqueKey = getUniqueKey(baseError);
// get the counter for this error
int count = 0;
if (errorCounter.containsKey(uniqueKey)) {
// counter exists
MinuteCounter counter = errorCounter.get(uniqueKey);
if (counter.getEpochMinute() == epochMinute) {
// counter exists for this current minute
// increment the counter
MinuteCounter incCounter = MinuteCounter.incrementCounter(counter);
errorCounter.put(uniqueKey, incCounter);
count = incCounter.getErrorCount();
} else {
// counter did not exist for this minute
// overwrite the entry with a new one
MinuteCounter newCounter = MinuteCounter.newMinuteCounter(epochMinute);
errorCounter.put(uniqueKey, newCounter);
count = newCounter.getErrorCount();
}
} else {
// counter did not exist so create a new one
MinuteCounter newCounter = MinuteCounter.newMinuteCounter(epochMinute);
errorCounter.put(uniqueKey, newCounter);
count = newCounter.getErrorCount();
}
return count;
} | java | public int incrementCounter(final StackifyError error, long epochMinute) {
if (error == null) {
throw new NullPointerException("StackifyError is null");
}
ErrorItem baseError = getBaseError(error);
String uniqueKey = getUniqueKey(baseError);
// get the counter for this error
int count = 0;
if (errorCounter.containsKey(uniqueKey)) {
// counter exists
MinuteCounter counter = errorCounter.get(uniqueKey);
if (counter.getEpochMinute() == epochMinute) {
// counter exists for this current minute
// increment the counter
MinuteCounter incCounter = MinuteCounter.incrementCounter(counter);
errorCounter.put(uniqueKey, incCounter);
count = incCounter.getErrorCount();
} else {
// counter did not exist for this minute
// overwrite the entry with a new one
MinuteCounter newCounter = MinuteCounter.newMinuteCounter(epochMinute);
errorCounter.put(uniqueKey, newCounter);
count = newCounter.getErrorCount();
}
} else {
// counter did not exist so create a new one
MinuteCounter newCounter = MinuteCounter.newMinuteCounter(epochMinute);
errorCounter.put(uniqueKey, newCounter);
count = newCounter.getErrorCount();
}
return count;
} | [
"public",
"int",
"incrementCounter",
"(",
"final",
"StackifyError",
"error",
",",
"long",
"epochMinute",
")",
"{",
"if",
"(",
"error",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"StackifyError is null\"",
")",
";",
"}",
"ErrorItem",
... | Increments the counter for this error in the epoch minute specified
@param error The error
@param epochMinute The epoch minute
@return The count for the error after it has been incremented | [
"Increments",
"the",
"counter",
"for",
"this",
"error",
"in",
"the",
"epoch",
"minute",
"specified"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/error/ErrorCounter.java#L135-L174 |
137,099 | stackify/stackify-api-java | src/main/java/com/stackify/api/common/error/ErrorCounter.java | ErrorCounter.purgeCounters | public void purgeCounters(final long epochMinute)
{
for (Iterator<Map.Entry<String, MinuteCounter>> it = errorCounter.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, MinuteCounter> entry = it.next();
if (entry.getValue().getEpochMinute() < epochMinute) {
it.remove();
}
}
} | java | public void purgeCounters(final long epochMinute)
{
for (Iterator<Map.Entry<String, MinuteCounter>> it = errorCounter.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, MinuteCounter> entry = it.next();
if (entry.getValue().getEpochMinute() < epochMinute) {
it.remove();
}
}
} | [
"public",
"void",
"purgeCounters",
"(",
"final",
"long",
"epochMinute",
")",
"{",
"for",
"(",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"MinuteCounter",
">",
">",
"it",
"=",
"errorCounter",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",... | Purges the errorCounter map of expired entries
@param epochMinute The current time | [
"Purges",
"the",
"errorCounter",
"map",
"of",
"expired",
"entries"
] | d3000b7c87ed53a88b302939b0c88405d63d7b67 | https://github.com/stackify/stackify-api-java/blob/d3000b7c87ed53a88b302939b0c88405d63d7b67/src/main/java/com/stackify/api/common/error/ErrorCounter.java#L180-L189 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.