repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
petergeneric/stdlib | guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/auth/oauth2/OAuth2SessionRef.java | OAuth2SessionRef.refreshToken | public synchronized void refreshToken()
{
final String refreshToken = this.response.refresh_token;
this.response = null;
this.cachedInfo = null;
final String responseStr = authService.getToken(UserManagerOAuthService.GRANT_TYPE_REFRESH_TOKEN,
null,
... | java | public synchronized void refreshToken()
{
final String refreshToken = this.response.refresh_token;
this.response = null;
this.cachedInfo = null;
final String responseStr = authService.getToken(UserManagerOAuthService.GRANT_TYPE_REFRESH_TOKEN,
null,
... | [
"public",
"synchronized",
"void",
"refreshToken",
"(",
")",
"{",
"final",
"String",
"refreshToken",
"=",
"this",
".",
"response",
".",
"refresh_token",
";",
"this",
".",
"response",
"=",
"null",
";",
"this",
".",
"cachedInfo",
"=",
"null",
";",
"final",
"S... | Use the refresh token to get a new token with a longer lifespan | [
"Use",
"the",
"refresh",
"token",
"to",
"get",
"a",
"new",
"token",
"with",
"a",
"longer",
"lifespan"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/auth/oauth2/OAuth2SessionRef.java#L242-L260 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java | PluginRepositoryUtil.loadFromXmlPluginPackageDefinitions | public static void loadFromXmlPluginPackageDefinitions(final IPluginRepository repo, final ClassLoader cl, final InputStream in)
throws PluginConfigurationException {
for (PluginDefinition pd : loadFromXmlPluginPackageDefinitions(cl, in)) {
repo.addPluginDefinition(pd);
}
} | java | public static void loadFromXmlPluginPackageDefinitions(final IPluginRepository repo, final ClassLoader cl, final InputStream in)
throws PluginConfigurationException {
for (PluginDefinition pd : loadFromXmlPluginPackageDefinitions(cl, in)) {
repo.addPluginDefinition(pd);
}
} | [
"public",
"static",
"void",
"loadFromXmlPluginPackageDefinitions",
"(",
"final",
"IPluginRepository",
"repo",
",",
"final",
"ClassLoader",
"cl",
",",
"final",
"InputStream",
"in",
")",
"throws",
"PluginConfigurationException",
"{",
"for",
"(",
"PluginDefinition",
"pd",
... | Loads a full repository definition from an XML file.
@param repo
The repository that must be loaded
@param cl
The classloader to be used to instantiate the plugin classes
@param in
The stream to the XML file
@throws PluginConfigurationException
- | [
"Loads",
"a",
"full",
"repository",
"definition",
"from",
"an",
"XML",
"file",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java#L69-L74 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java | PluginRepositoryUtil.loadFromXmlPluginPackageDefinitions | @SuppressWarnings("unchecked")
public static Collection<PluginDefinition> loadFromXmlPluginPackageDefinitions(final ClassLoader cl, final InputStream in)
throws PluginConfigurationException {
List<PluginDefinition> res = new ArrayList<PluginDefinition>();
DocumentBuilderFactory factory... | java | @SuppressWarnings("unchecked")
public static Collection<PluginDefinition> loadFromXmlPluginPackageDefinitions(final ClassLoader cl, final InputStream in)
throws PluginConfigurationException {
List<PluginDefinition> res = new ArrayList<PluginDefinition>();
DocumentBuilderFactory factory... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Collection",
"<",
"PluginDefinition",
">",
"loadFromXmlPluginPackageDefinitions",
"(",
"final",
"ClassLoader",
"cl",
",",
"final",
"InputStream",
"in",
")",
"throws",
"PluginConfigurationException",
... | Loads the plugins definitions from the jnrpe_plugins.xml file.
@param cl Classloader to be used to load classes
@param in InputStream to the jnrpe_plugins.xml file
@return a collection of all the declared plugins
@throws PluginConfigurationException on any error reading the plugin configuration | [
"Loads",
"the",
"plugins",
"definitions",
"from",
"the",
"jnrpe_plugins",
".",
"xml",
"file",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java#L84-L113 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java | PluginRepositoryUtil.parseXmlPluginDefinition | public static PluginDefinition parseXmlPluginDefinition(final ClassLoader cl, final InputStream in) throws PluginConfigurationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document document;
try {
DocumentBuilder loader = factory.newDocumentBui... | java | public static PluginDefinition parseXmlPluginDefinition(final ClassLoader cl, final InputStream in) throws PluginConfigurationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document document;
try {
DocumentBuilder loader = factory.newDocumentBui... | [
"public",
"static",
"PluginDefinition",
"parseXmlPluginDefinition",
"(",
"final",
"ClassLoader",
"cl",
",",
"final",
"InputStream",
"in",
")",
"throws",
"PluginConfigurationException",
"{",
"DocumentBuilderFactory",
"factory",
"=",
"DocumentBuilderFactory",
".",
"newInstanc... | Loads the definition of a single plugin from an XML file.
@param cl
The classloader to be used to instantiate the plugin class
@param in
The stream to the XML file
@return The plugin definition
@throws PluginConfigurationException if an error occurs parsing the plugin definition | [
"Loads",
"the",
"definition",
"of",
"a",
"single",
"plugin",
"from",
"an",
"XML",
"file",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java#L125-L145 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java | PluginRepositoryUtil.parsePluginDefinition | @SuppressWarnings("rawtypes")
private static PluginDefinition parsePluginDefinition(final ClassLoader cl, final Element plugin) throws PluginConfigurationException {
// Check if the plugin definition is inside its own file
if (getAttributeValue(plugin, "definedIn", false) != null) {
Str... | java | @SuppressWarnings("rawtypes")
private static PluginDefinition parsePluginDefinition(final ClassLoader cl, final Element plugin) throws PluginConfigurationException {
// Check if the plugin definition is inside its own file
if (getAttributeValue(plugin, "definedIn", false) != null) {
Str... | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"private",
"static",
"PluginDefinition",
"parsePluginDefinition",
"(",
"final",
"ClassLoader",
"cl",
",",
"final",
"Element",
"plugin",
")",
"throws",
"PluginConfigurationException",
"{",
"// Check if the plugin definition ... | Parse an XML plugin definition.
@param cl
The classloader to be used to load classes
@param plugin
The plugin XML element
@return the parsed plugin definition * @throws PluginConfigurationException
- | [
"Parse",
"an",
"XML",
"plugin",
"definition",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java#L187-L234 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java | PluginRepositoryUtil.parseCommandLine | @SuppressWarnings("rawtypes")
private static void parseCommandLine(final PluginDefinition pluginDef, final Element xmlPluginElement) {
Element commandLine = xmlPluginElement.element("command-line");
if (commandLine != null) {
// The plugin has a command line...
Element optio... | java | @SuppressWarnings("rawtypes")
private static void parseCommandLine(final PluginDefinition pluginDef, final Element xmlPluginElement) {
Element commandLine = xmlPluginElement.element("command-line");
if (commandLine != null) {
// The plugin has a command line...
Element optio... | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"private",
"static",
"void",
"parseCommandLine",
"(",
"final",
"PluginDefinition",
"pluginDef",
",",
"final",
"Element",
"xmlPluginElement",
")",
"{",
"Element",
"commandLine",
"=",
"xmlPluginElement",
".",
"element",... | Updates the plugin definition with the commandline read from the xml
file.
@param pluginDef
The plugin definition to be updated
@param xmlPluginElement
the xml element to be parsed | [
"Updates",
"the",
"plugin",
"definition",
"with",
"the",
"commandline",
"read",
"from",
"the",
"xml",
"file",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java#L245-L262 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java | PluginRepositoryUtil.parsePluginOption | private static PluginOption parsePluginOption(final Element option) {
PluginOption po = new PluginOption();
po.setArgName(option.attributeValue("argName"));
po.setArgsCount(Integer.valueOf(option.attributeValue("argsCount", "1")));
po.setArgsOptional(Boolean.valueOf(option.attributeValue... | java | private static PluginOption parsePluginOption(final Element option) {
PluginOption po = new PluginOption();
po.setArgName(option.attributeValue("argName"));
po.setArgsCount(Integer.valueOf(option.attributeValue("argsCount", "1")));
po.setArgsOptional(Boolean.valueOf(option.attributeValue... | [
"private",
"static",
"PluginOption",
"parsePluginOption",
"(",
"final",
"Element",
"option",
")",
"{",
"PluginOption",
"po",
"=",
"new",
"PluginOption",
"(",
")",
";",
"po",
".",
"setArgName",
"(",
"option",
".",
"attributeValue",
"(",
"\"argName\"",
")",
")",... | Parses a plugin option XML definition.
@param option
The plugin option XML definition
@return The parsed plugin option | [
"Parses",
"a",
"plugin",
"option",
"XML",
"definition",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java#L319-L333 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java | PluginRepositoryUtil.parsePluginOption | private static PluginOption parsePluginOption(final Option option) {
PluginOption po = new PluginOption();
po.setArgName(option.argName());
po.setArgsOptional(option.optionalArgs());
po.setDescription(option.description());
po.setHasArgs(option.hasArgs());
po.setLongOpt(o... | java | private static PluginOption parsePluginOption(final Option option) {
PluginOption po = new PluginOption();
po.setArgName(option.argName());
po.setArgsOptional(option.optionalArgs());
po.setDescription(option.description());
po.setHasArgs(option.hasArgs());
po.setLongOpt(o... | [
"private",
"static",
"PluginOption",
"parsePluginOption",
"(",
"final",
"Option",
"option",
")",
"{",
"PluginOption",
"po",
"=",
"new",
"PluginOption",
"(",
")",
";",
"po",
".",
"setArgName",
"(",
"option",
".",
"argName",
"(",
")",
")",
";",
"po",
".",
... | Parses a plugin option from the annotation definition.
@param option
the plugin option
@return PluginOption | [
"Parses",
"a",
"plugin",
"option",
"from",
"the",
"annotation",
"definition",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/PluginRepositoryUtil.java#L342-L353 | train |
petergeneric/stdlib | guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/jaxrs/GuiceDynamicProxyProvider.java | GuiceDynamicProxyProvider.invoke | @Override
public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
{
// Get an instance of the implementing class via Guice
final Object instance = registry.getInjector().getInstance(clazz);
return thisMethod.invoke(instance, args);
} | java | @Override
public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
{
// Get an instance of the implementing class via Guice
final Object instance = registry.getInjector().getInstance(clazz);
return thisMethod.invoke(instance, args);
} | [
"@",
"Override",
"public",
"Object",
"invoke",
"(",
"Object",
"self",
",",
"Method",
"thisMethod",
",",
"Method",
"proceed",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"Throwable",
"{",
"// Get an instance of the implementing class via Guice",
"final",
"Object"... | A MethodHandler that proxies the Method invocation through to a Guice-acquired instance | [
"A",
"MethodHandler",
"that",
"proxies",
"the",
"Method",
"invocation",
"through",
"to",
"a",
"Guice",
"-",
"acquired",
"instance"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/jaxrs/GuiceDynamicProxyProvider.java#L48-L55 | train |
petergeneric/stdlib | service-manager/host-agent/src/main/java/com/peterphi/servicemanager/hostagent/cmdline/NginxSiteGenerator.java | NginxSiteGenerator.main | public static void main(String[] args) throws Exception
{
final String name = args[0];
final File sslCert = new File(args[1]);
final File sslKey = new File(args[2]);
final Map<File, Integer> foldersAndPorts = getFoldersAndPorts(3, args);
NginxSiteGenerator generator = new NginxSiteGenerator();
final Stri... | java | public static void main(String[] args) throws Exception
{
final String name = args[0];
final File sslCert = new File(args[1]);
final File sslKey = new File(args[2]);
final Map<File, Integer> foldersAndPorts = getFoldersAndPorts(3, args);
NginxSiteGenerator generator = new NginxSiteGenerator();
final Stri... | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"final",
"String",
"name",
"=",
"args",
"[",
"0",
"]",
";",
"final",
"File",
"sslCert",
"=",
"new",
"File",
"(",
"args",
"[",
"1",
"]",
")",
";",
... | Entry point for initial generation, called from the commandline
@param args
@throws Exception | [
"Entry",
"point",
"for",
"initial",
"generation",
"called",
"from",
"the",
"commandline"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/host-agent/src/main/java/com/peterphi/servicemanager/hostagent/cmdline/NginxSiteGenerator.java#L238-L250 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/util/jaxb/MultiXSDSchemaCollector.java | MultiXSDSchemaCollector.encode | public MultiXSDSchemaFiles encode()
{
MultiXSDSchemaFiles files = new MultiXSDSchemaFiles();
for (Map.Entry<String, DOMResult> entry : schemas.entrySet())
{
MultiXSDSchemaFile file = new MultiXSDSchemaFile();
file.name = entry.getKey();
file.schema = getElement(entry.getValue().getNode());
files.f... | java | public MultiXSDSchemaFiles encode()
{
MultiXSDSchemaFiles files = new MultiXSDSchemaFiles();
for (Map.Entry<String, DOMResult> entry : schemas.entrySet())
{
MultiXSDSchemaFile file = new MultiXSDSchemaFile();
file.name = entry.getKey();
file.schema = getElement(entry.getValue().getNode());
files.f... | [
"public",
"MultiXSDSchemaFiles",
"encode",
"(",
")",
"{",
"MultiXSDSchemaFiles",
"files",
"=",
"new",
"MultiXSDSchemaFiles",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"DOMResult",
">",
"entry",
":",
"schemas",
".",
"entrySet",
"(",
... | Produces an XML Schema or a Stdlib SchemaFiles document containing the XML Schemas
@return | [
"Produces",
"an",
"XML",
"Schema",
"or",
"a",
"Stdlib",
"SchemaFiles",
"document",
"containing",
"the",
"XML",
"Schemas"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/util/jaxb/MultiXSDSchemaCollector.java#L49-L68 | train |
petergeneric/stdlib | guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/CoreRestServicesModule.java | CoreRestServicesModule.getRestServicesPrefix | @Provides
@Singleton
@Named(GuiceProperties.REST_SERVICES_PREFIX)
public String getRestServicesPrefix(ServletContext context)
{
String restPath = context.getInitParameter(RESTEASY_MAPPING_PREFIX);
if (restPath == null || restPath.isEmpty() || restPath.equals("/"))
{
return "";
}
else
{
return res... | java | @Provides
@Singleton
@Named(GuiceProperties.REST_SERVICES_PREFIX)
public String getRestServicesPrefix(ServletContext context)
{
String restPath = context.getInitParameter(RESTEASY_MAPPING_PREFIX);
if (restPath == null || restPath.isEmpty() || restPath.equals("/"))
{
return "";
}
else
{
return res... | [
"@",
"Provides",
"@",
"Singleton",
"@",
"Named",
"(",
"GuiceProperties",
".",
"REST_SERVICES_PREFIX",
")",
"public",
"String",
"getRestServicesPrefix",
"(",
"ServletContext",
"context",
")",
"{",
"String",
"restPath",
"=",
"context",
".",
"getInitParameter",
"(",
... | Retrieves the RESTeasy mapping prefix - this is the path under the webapp root where RESTeasy services are mapped.
@param context
@return | [
"Retrieves",
"the",
"RESTeasy",
"mapping",
"prefix",
"-",
"this",
"is",
"the",
"path",
"under",
"the",
"webapp",
"root",
"where",
"RESTeasy",
"services",
"are",
"mapped",
"."
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/CoreRestServicesModule.java#L59-L74 | train |
petergeneric/stdlib | guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/CoreRestServicesModule.java | CoreRestServicesModule.getRestServicesEndpoint | @Provides
@Singleton
@Named(GuiceProperties.LOCAL_REST_SERVICES_ENDPOINT)
public URI getRestServicesEndpoint(@Named(GuiceProperties.STATIC_ENDPOINT_CONFIG_NAME) URI webappUri,
@Named(GuiceProperties.REST_SERVICES_PREFIX) String restPrefix,
Servl... | java | @Provides
@Singleton
@Named(GuiceProperties.LOCAL_REST_SERVICES_ENDPOINT)
public URI getRestServicesEndpoint(@Named(GuiceProperties.STATIC_ENDPOINT_CONFIG_NAME) URI webappUri,
@Named(GuiceProperties.REST_SERVICES_PREFIX) String restPrefix,
Servl... | [
"@",
"Provides",
"@",
"Singleton",
"@",
"Named",
"(",
"GuiceProperties",
".",
"LOCAL_REST_SERVICES_ENDPOINT",
")",
"public",
"URI",
"getRestServicesEndpoint",
"(",
"@",
"Named",
"(",
"GuiceProperties",
".",
"STATIC_ENDPOINT_CONFIG_NAME",
")",
"URI",
"webappUri",
",",
... | Return the base path for all REST services in this webapp
@param webappUri
@param restPrefix
the prefix for rest services (added after the webapp endpoint to form the base path for the JAX-RS container)
@param context
@return | [
"Return",
"the",
"base",
"path",
"for",
"all",
"REST",
"services",
"in",
"this",
"webapp"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/CoreRestServicesModule.java#L87-L112 | train |
petergeneric/stdlib | guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/CoreRestServicesModule.java | CoreRestServicesModule.getRestServicesEndpoint | @Provides
@Singleton
@Named(GuiceProperties.STATIC_ENDPOINT_CONFIG_NAME)
public URI getRestServicesEndpoint(LocalEndpointDiscovery localEndpointDiscovery)
{
final URI base = localEndpointDiscovery.getLocalEndpoint();
return base;
} | java | @Provides
@Singleton
@Named(GuiceProperties.STATIC_ENDPOINT_CONFIG_NAME)
public URI getRestServicesEndpoint(LocalEndpointDiscovery localEndpointDiscovery)
{
final URI base = localEndpointDiscovery.getLocalEndpoint();
return base;
} | [
"@",
"Provides",
"@",
"Singleton",
"@",
"Named",
"(",
"GuiceProperties",
".",
"STATIC_ENDPOINT_CONFIG_NAME",
")",
"public",
"URI",
"getRestServicesEndpoint",
"(",
"LocalEndpointDiscovery",
"localEndpointDiscovery",
")",
"{",
"final",
"URI",
"base",
"=",
"localEndpointDi... | Return the base path for this webapp
@param localEndpointDiscovery
@return | [
"Return",
"the",
"base",
"path",
"for",
"this",
"webapp"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/CoreRestServicesModule.java#L122-L130 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/ClassScanner.java | ClassScanner.getSiblingClasses | public List<Class<?>> getSiblingClasses(final Class<?> clazz, boolean recursive, final Predicate<Class<?>> predicate)
{
return getClasses(getPackages(clazz)[0], recursive, predicate);
} | java | public List<Class<?>> getSiblingClasses(final Class<?> clazz, boolean recursive, final Predicate<Class<?>> predicate)
{
return getClasses(getPackages(clazz)[0], recursive, predicate);
} | [
"public",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"getSiblingClasses",
"(",
"final",
"Class",
"<",
"?",
">",
"clazz",
",",
"boolean",
"recursive",
",",
"final",
"Predicate",
"<",
"Class",
"<",
"?",
">",
">",
"predicate",
")",
"{",
"return",
"getClass... | Find all the classes that are siblings of the provided class
@param clazz
the class in whose package to search
@param recursive
if true, search all the child packages of the package containing the class
@param predicate
an optional additional predicate to filter the list against
@return | [
"Find",
"all",
"the",
"classes",
"that",
"are",
"siblings",
"of",
"the",
"provided",
"class"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/ClassScanner.java#L113-L116 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/commands/CommandDefinition.java | CommandDefinition.getCommandLine | public String[] getCommandLine() {
String[] argsAry = argsString != null ? split(argsString) : EMPTY_ARRAY;
List<String> argsList = new ArrayList<String>();
int startIndex = 0;
for (CommandOption opt : optionsList) {
String argName = opt.getName();
String argVal... | java | public String[] getCommandLine() {
String[] argsAry = argsString != null ? split(argsString) : EMPTY_ARRAY;
List<String> argsList = new ArrayList<String>();
int startIndex = 0;
for (CommandOption opt : optionsList) {
String argName = opt.getName();
String argVal... | [
"public",
"String",
"[",
"]",
"getCommandLine",
"(",
")",
"{",
"String",
"[",
"]",
"argsAry",
"=",
"argsString",
"!=",
"null",
"?",
"split",
"(",
"argsString",
")",
":",
"EMPTY_ARRAY",
";",
"List",
"<",
"String",
">",
"argsList",
"=",
"new",
"ArrayList",... | Merges the command line definition read from the server config file with.
the values received from check_nrpe and produces a clean command line.
@return a parsable command line or an empty array for empty command line. | [
"Merges",
"the",
"command",
"line",
"definition",
"read",
"from",
"the",
"server",
"config",
"file",
"with",
".",
"the",
"values",
"received",
"from",
"check_nrpe",
"and",
"produces",
"a",
"clean",
"command",
"line",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/commands/CommandDefinition.java#L124-L151 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/Threshold.java | Threshold.parse | private void parse(final String definition) throws BadThresholdException {
String[] thresholdComponentAry = definition.split(",");
for (String thresholdComponent : thresholdComponentAry) {
String[] nameValuePair = thresholdComponent.split("=");
if (nameValuePair.length != 2 || ... | java | private void parse(final String definition) throws BadThresholdException {
String[] thresholdComponentAry = definition.split(",");
for (String thresholdComponent : thresholdComponentAry) {
String[] nameValuePair = thresholdComponent.split("=");
if (nameValuePair.length != 2 || ... | [
"private",
"void",
"parse",
"(",
"final",
"String",
"definition",
")",
"throws",
"BadThresholdException",
"{",
"String",
"[",
"]",
"thresholdComponentAry",
"=",
"definition",
".",
"split",
"(",
"\",\"",
")",
";",
"for",
"(",
"String",
"thresholdComponent",
":",
... | Parses a threshold definition.
@param definition
The threshold definition
@throws BadThresholdException
- | [
"Parses",
"a",
"threshold",
"definition",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/Threshold.java#L124-L166 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/Threshold.java | Threshold.getRangesAsString | public final String getRangesAsString(final Status status) {
List<String> ranges = new ArrayList<String>();
List<Range> rangeList;
switch (status) {
case OK:
rangeList = okThresholdList;
break;
case WARNING:
rangeList = warningThresholdList;
... | java | public final String getRangesAsString(final Status status) {
List<String> ranges = new ArrayList<String>();
List<Range> rangeList;
switch (status) {
case OK:
rangeList = okThresholdList;
break;
case WARNING:
rangeList = warningThresholdList;
... | [
"public",
"final",
"String",
"getRangesAsString",
"(",
"final",
"Status",
"status",
")",
"{",
"List",
"<",
"String",
">",
"ranges",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"List",
"<",
"Range",
">",
"rangeList",
";",
"switch",
"(",
... | Returns the requested range list as comma separated string.
@param status
The status for wich we are requesting the ranges.
@return the requested range list as comma separated string.
@see it.jnrpe.utils.thresholds.IThreshold#getRangesAsString(Status) | [
"Returns",
"the",
"requested",
"range",
"list",
"as",
"comma",
"separated",
"string",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/Threshold.java#L206-L233 | train |
ops4j/org.ops4j.pax.swissbox | pax-swissbox-core/src/main/java/org/ops4j/pax/swissbox/core/BundleClassLoader.java | BundleClassLoader.newPriviledged | public static BundleClassLoader newPriviledged( final Bundle bundle, final ClassLoader parent )
{
return AccessController.doPrivileged( new PrivilegedAction<BundleClassLoader>()
{
public BundleClassLoader run()
{
return new BundleClassLoader( bundle, parent );... | java | public static BundleClassLoader newPriviledged( final Bundle bundle, final ClassLoader parent )
{
return AccessController.doPrivileged( new PrivilegedAction<BundleClassLoader>()
{
public BundleClassLoader run()
{
return new BundleClassLoader( bundle, parent );... | [
"public",
"static",
"BundleClassLoader",
"newPriviledged",
"(",
"final",
"Bundle",
"bundle",
",",
"final",
"ClassLoader",
"parent",
")",
"{",
"return",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedAction",
"<",
"BundleClassLoader",
">",
"(",
")",
... | Privileged factory method.
@param bundle bundle to be used for class loading. Cannot be null.
@param parent parent class loader
@return created bundle class loader
@see BundleClassLoader#BundleClassLoader(Bundle,ClassLoader) | [
"Privileged",
"factory",
"method",
"."
] | 00b0ee16cdbe8017984a4d7ba808b10d985c5b5c | https://github.com/ops4j/org.ops4j.pax.swissbox/blob/00b0ee16cdbe8017984a4d7ba808b10d985c5b5c/pax-swissbox-core/src/main/java/org/ops4j/pax/swissbox/core/BundleClassLoader.java#L85-L94 | train |
ops4j/org.ops4j.pax.swissbox | pax-swissbox-core/src/main/java/org/ops4j/pax/swissbox/core/BundleClassLoader.java | BundleClassLoader.findResources | @Override
@SuppressWarnings("unchecked")
protected Enumeration<URL> findResources( final String name )
throws IOException
{
Enumeration<URL> resources = m_bundle.getResources( name );
// Bundle.getResources may return null, in such case return empty enumeration
if( resources ... | java | @Override
@SuppressWarnings("unchecked")
protected Enumeration<URL> findResources( final String name )
throws IOException
{
Enumeration<URL> resources = m_bundle.getResources( name );
// Bundle.getResources may return null, in such case return empty enumeration
if( resources ... | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"Enumeration",
"<",
"URL",
">",
"findResources",
"(",
"final",
"String",
"name",
")",
"throws",
"IOException",
"{",
"Enumeration",
"<",
"URL",
">",
"resources",
"=",
"m_bundle",
... | Use bundle to find resources.
@see ClassLoader#findResources(String) | [
"Use",
"bundle",
"to",
"find",
"resources",
"."
] | 00b0ee16cdbe8017984a4d7ba808b10d985c5b5c | https://github.com/ops4j/org.ops4j.pax.swissbox/blob/00b0ee16cdbe8017984a4d7ba808b10d985c5b5c/pax-swissbox-core/src/main/java/org/ops4j/pax/swissbox/core/BundleClassLoader.java#L218-L233 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/threading/ParamInvokeable.java | ParamInvokeable.call | public final void call(T param)
{
if (!run)
{
run = true;
prepared = true;
try
{
this.run(param);
}
catch (Throwable t)
{
log.error("[ParamInvokeable] {prepare} : " + t.getMessage(), t);
}
}
} | java | public final void call(T param)
{
if (!run)
{
run = true;
prepared = true;
try
{
this.run(param);
}
catch (Throwable t)
{
log.error("[ParamInvokeable] {prepare} : " + t.getMessage(), t);
}
}
} | [
"public",
"final",
"void",
"call",
"(",
"T",
"param",
")",
"{",
"if",
"(",
"!",
"run",
")",
"{",
"run",
"=",
"true",
";",
"prepared",
"=",
"true",
";",
"try",
"{",
"this",
".",
"run",
"(",
"param",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",... | Synchronously executes this Invokeable
@param param | [
"Synchronously",
"executes",
"this",
"Invokeable"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/threading/ParamInvokeable.java#L47-L63 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/daemon/GuiceDaemonRegistry.java | GuiceDaemonRegistry.getRecurring | public synchronized List<GuiceRecurringDaemon> getRecurring()
{
return daemons.stream()
.filter(d -> d instanceof GuiceRecurringDaemon)
.map(d -> (GuiceRecurringDaemon) d)
.sorted(Comparator.comparing(GuiceDaemon::getName))
.collect(Collectors.toList())... | java | public synchronized List<GuiceRecurringDaemon> getRecurring()
{
return daemons.stream()
.filter(d -> d instanceof GuiceRecurringDaemon)
.map(d -> (GuiceRecurringDaemon) d)
.sorted(Comparator.comparing(GuiceDaemon::getName))
.collect(Collectors.toList())... | [
"public",
"synchronized",
"List",
"<",
"GuiceRecurringDaemon",
">",
"getRecurring",
"(",
")",
"{",
"return",
"daemons",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"d",
"->",
"d",
"instanceof",
"GuiceRecurringDaemon",
")",
".",
"map",
"(",
"d",
"->",
"(",... | Return a list of all
@return | [
"Return",
"a",
"list",
"of",
"all"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/daemon/GuiceDaemonRegistry.java#L48-L55 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/util/HexHelper.java | HexHelper.fromHex | public static final byte[] fromHex(final String value)
{
if (value.length() == 0)
return new byte[0];
else if (value.indexOf(':') != -1)
return fromHex(':', value);
else if (value.length() % 2 != 0)
throw new IllegalArgumentException("Invalid hex specified: uneven number of digits passed for byte[] conv... | java | public static final byte[] fromHex(final String value)
{
if (value.length() == 0)
return new byte[0];
else if (value.indexOf(':') != -1)
return fromHex(':', value);
else if (value.length() % 2 != 0)
throw new IllegalArgumentException("Invalid hex specified: uneven number of digits passed for byte[] conv... | [
"public",
"static",
"final",
"byte",
"[",
"]",
"fromHex",
"(",
"final",
"String",
"value",
")",
"{",
"if",
"(",
"value",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"new",
"byte",
"[",
"0",
"]",
";",
"else",
"if",
"(",
"value",
".",
"index... | Decodes a hexidecimal string into a series of bytes
@param value
@return | [
"Decodes",
"a",
"hexidecimal",
"string",
"into",
"a",
"series",
"of",
"bytes"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/util/HexHelper.java#L24-L44 | train |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckHttp.java | CheckHttp.getHttpResponse | private String getHttpResponse(final ICommandLine cl, final String hostname, final String port, final String method, final String path,
final int timeout, final boolean ssl, final List<Metric> metrics) throws MetricGatheringException {
Properties props = null;
try {
props = getRe... | java | private String getHttpResponse(final ICommandLine cl, final String hostname, final String port, final String method, final String path,
final int timeout, final boolean ssl, final List<Metric> metrics) throws MetricGatheringException {
Properties props = null;
try {
props = getRe... | [
"private",
"String",
"getHttpResponse",
"(",
"final",
"ICommandLine",
"cl",
",",
"final",
"String",
"hostname",
",",
"final",
"String",
"port",
",",
"final",
"String",
"method",
",",
"final",
"String",
"path",
",",
"final",
"int",
"timeout",
",",
"final",
"b... | Do the actual http request and return the response string.
@param cl
- The received command line
@param hostname
- The server hostname
@param port
- The server port
@param method
- The HTTP method
@param path
- The connection path
@param timeout
- The timeout
@param ssl
- if SSL must be used
@param metrics
- This list... | [
"Do",
"the",
"actual",
"http",
"request",
"and",
"return",
"the",
"response",
"string",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckHttp.java#L224-L282 | train |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckHttp.java | CheckHttp.checkRedirectResponse | private String checkRedirectResponse(final URL url, final String method, final Integer timeout, final Properties props, final String postData,
final String redirect, final boolean ignoreBody, final List<Metric> metrics) throws Exception {
// @todo handle sticky/port and follow param options
... | java | private String checkRedirectResponse(final URL url, final String method, final Integer timeout, final Properties props, final String postData,
final String redirect, final boolean ignoreBody, final List<Metric> metrics) throws Exception {
// @todo handle sticky/port and follow param options
... | [
"private",
"String",
"checkRedirectResponse",
"(",
"final",
"URL",
"url",
",",
"final",
"String",
"method",
",",
"final",
"Integer",
"timeout",
",",
"final",
"Properties",
"props",
",",
"final",
"String",
"postData",
",",
"final",
"String",
"redirect",
",",
"f... | Apply the logic to check for url redirects.
@param url
- The server URL
@param method
- The HTTP method
@param timeout
- The timeout
@param props
-
@param postData
-
@param redirect
-
@param ignoreBody
-
@param metrics
- This list will be filled with the gathered metrics
@return String
@throws Exception
- | [
"Apply",
"the",
"logic",
"to",
"check",
"for",
"url",
"redirects",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckHttp.java#L307-L328 | train |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckHttp.java | CheckHttp.analyzeResponse | private List<Metric> analyzeResponse(final ICommandLine opt, final String response, final int elapsed) throws MetricGatheringException {
List<Metric> metrics = new ArrayList<Metric>();
metrics.add(new Metric("time", "", new BigDecimal(elapsed), null, null));
if (!opt.hasOption("certificate")) {... | java | private List<Metric> analyzeResponse(final ICommandLine opt, final String response, final int elapsed) throws MetricGatheringException {
List<Metric> metrics = new ArrayList<Metric>();
metrics.add(new Metric("time", "", new BigDecimal(elapsed), null, null));
if (!opt.hasOption("certificate")) {... | [
"private",
"List",
"<",
"Metric",
">",
"analyzeResponse",
"(",
"final",
"ICommandLine",
"opt",
",",
"final",
"String",
"response",
",",
"final",
"int",
"elapsed",
")",
"throws",
"MetricGatheringException",
"{",
"List",
"<",
"Metric",
">",
"metrics",
"=",
"new"... | Apply logic to the http response and build metrics.
@param opt
-
@param response
-
@param elapsed
-
@return - The metrics
@throws MetricGatheringException
List<Metric> | [
"Apply",
"logic",
"to",
"the",
"http",
"response",
"and",
"build",
"metrics",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckHttp.java#L343-L384 | train |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckHttp.java | CheckHttp.getRequestProperties | private Properties getRequestProperties(final ICommandLine cl, final String method) throws UnsupportedEncodingException {
Properties props = new Properties();
if (cl.hasOption("useragent")) {
props.setProperty("User-Agent", cl.getOptionValue("useragent"));
} else {
props.... | java | private Properties getRequestProperties(final ICommandLine cl, final String method) throws UnsupportedEncodingException {
Properties props = new Properties();
if (cl.hasOption("useragent")) {
props.setProperty("User-Agent", cl.getOptionValue("useragent"));
} else {
props.... | [
"private",
"Properties",
"getRequestProperties",
"(",
"final",
"ICommandLine",
"cl",
",",
"final",
"String",
"method",
")",
"throws",
"UnsupportedEncodingException",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"if",
"(",
"cl",
".",
"hasO... | Set the http request properties and headers.
@param cl
The received command line
@param method
The HTTP method
@return Properties
@throws UnsupportedEncodingException | [
"Set",
"the",
"http",
"request",
"properties",
"and",
"headers",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckHttp.java#L396-L428 | train |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckHttp.java | CheckHttp.getPostData | private String getPostData(final ICommandLine cl) throws Exception {
// String encoded = "";
StringBuilder encoded = new StringBuilder();
String data = cl.getOptionValue("post");
if (data == null) {
return null;
}
String[] values = data.split("&");
for... | java | private String getPostData(final ICommandLine cl) throws Exception {
// String encoded = "";
StringBuilder encoded = new StringBuilder();
String data = cl.getOptionValue("post");
if (data == null) {
return null;
}
String[] values = data.split("&");
for... | [
"private",
"String",
"getPostData",
"(",
"final",
"ICommandLine",
"cl",
")",
"throws",
"Exception",
"{",
"// String encoded = \"\";",
"StringBuilder",
"encoded",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"data",
"=",
"cl",
".",
"getOptionValue",
"(",
... | Returns encoded post data.
@param cl
- The received command line
@return - The encoded post data
@throws Exception
- | [
"Returns",
"encoded",
"post",
"data",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckHttp.java#L439-L464 | train |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckHttp.java | CheckHttp.checkCertificateExpiryDate | private void checkCertificateExpiryDate(URL url, List<Metric> metrics) throws Exception {
SSLContext ctx = SSLContext.getInstance("TLS");
ctx.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, new SecureRandom());
SSLContext.setDefault(ctx);
HttpsURLConnection conn... | java | private void checkCertificateExpiryDate(URL url, List<Metric> metrics) throws Exception {
SSLContext ctx = SSLContext.getInstance("TLS");
ctx.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, new SecureRandom());
SSLContext.setDefault(ctx);
HttpsURLConnection conn... | [
"private",
"void",
"checkCertificateExpiryDate",
"(",
"URL",
"url",
",",
"List",
"<",
"Metric",
">",
"metrics",
")",
"throws",
"Exception",
"{",
"SSLContext",
"ctx",
"=",
"SSLContext",
".",
"getInstance",
"(",
"\"TLS\"",
")",
";",
"ctx",
".",
"init",
"(",
... | stuff for checking certificate | [
"stuff",
"for",
"checking",
"certificate"
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckHttp.java#L477-L502 | train |
ziccardi/jnrpe | jnrpe-server/src/main/java/it/jnrpe/server/JNRPEConfigurationFactory.java | JNRPEConfigurationFactory.createConfiguration | public static JNRPEConfiguration createConfiguration(final String configurationFilePath) throws ConfigurationException {
JNRPEConfiguration conf = null;
if (configurationFilePath.toLowerCase().endsWith(".conf") || configurationFilePath.toLowerCase().endsWith(".ini")) {
conf = new IniJNRPECo... | java | public static JNRPEConfiguration createConfiguration(final String configurationFilePath) throws ConfigurationException {
JNRPEConfiguration conf = null;
if (configurationFilePath.toLowerCase().endsWith(".conf") || configurationFilePath.toLowerCase().endsWith(".ini")) {
conf = new IniJNRPECo... | [
"public",
"static",
"JNRPEConfiguration",
"createConfiguration",
"(",
"final",
"String",
"configurationFilePath",
")",
"throws",
"ConfigurationException",
"{",
"JNRPEConfiguration",
"conf",
"=",
"null",
";",
"if",
"(",
"configurationFilePath",
".",
"toLowerCase",
"(",
"... | Creates a configuration object from the passed in configuration file.
@param configurationFilePath
Path to the configuration file
@return The configuration object
@throws ConfigurationException
- | [
"Creates",
"a",
"configuration",
"object",
"from",
"the",
"passed",
"in",
"configuration",
"file",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-server/src/main/java/it/jnrpe/server/JNRPEConfigurationFactory.java#L43-L60 | train |
ops4j/org.ops4j.pax.swissbox | pax-swissbox-core/src/main/java/org/ops4j/pax/swissbox/core/BundleUtils.java | BundleUtils.getBundleContext | public static BundleContext getBundleContext( final Bundle bundle )
{
try
{
// first try to find the getBundleContext method (OSGi spec >= 4.10)
final Method method = Bundle.class.getDeclaredMethod( "getBundleContext" );
if( !method.isAccessible() )
{
... | java | public static BundleContext getBundleContext( final Bundle bundle )
{
try
{
// first try to find the getBundleContext method (OSGi spec >= 4.10)
final Method method = Bundle.class.getDeclaredMethod( "getBundleContext" );
if( !method.isAccessible() )
{
... | [
"public",
"static",
"BundleContext",
"getBundleContext",
"(",
"final",
"Bundle",
"bundle",
")",
"{",
"try",
"{",
"// first try to find the getBundleContext method (OSGi spec >= 4.10)",
"final",
"Method",
"method",
"=",
"Bundle",
".",
"class",
".",
"getDeclaredMethod",
"("... | Discovers the bundle context for a bundle. If the bundle is an 4.1.0 or greater bundle it should have a method
that just returns the bundle context. Otherwise uses reflection to look for an internal bundle context.
@param bundle the bundle from which the bundle context is needed
@return corresponding bundle context o... | [
"Discovers",
"the",
"bundle",
"context",
"for",
"a",
"bundle",
".",
"If",
"the",
"bundle",
"is",
"an",
"4",
".",
"1",
".",
"0",
"or",
"greater",
"bundle",
"it",
"should",
"have",
"a",
"method",
"that",
"just",
"returns",
"the",
"bundle",
"context",
"."... | 00b0ee16cdbe8017984a4d7ba808b10d985c5b5c | https://github.com/ops4j/org.ops4j.pax.swissbox/blob/00b0ee16cdbe8017984a4d7ba808b10d985c5b5c/pax-swissbox-core/src/main/java/org/ops4j/pax/swissbox/core/BundleUtils.java#L46-L83 | train |
ops4j/org.ops4j.pax.swissbox | pax-swissbox-core/src/main/java/org/ops4j/pax/swissbox/core/BundleUtils.java | BundleUtils.getBundle | public static Bundle getBundle( BundleContext bc, String symbolicName )
{
return getBundle( bc, symbolicName, null );
} | java | public static Bundle getBundle( BundleContext bc, String symbolicName )
{
return getBundle( bc, symbolicName, null );
} | [
"public",
"static",
"Bundle",
"getBundle",
"(",
"BundleContext",
"bc",
",",
"String",
"symbolicName",
")",
"{",
"return",
"getBundle",
"(",
"bc",
",",
"symbolicName",
",",
"null",
")",
";",
"}"
] | Returns any bundle with the given symbolic name, or null if no such bundle exists. If there
are multiple bundles with the same symbolic name and different version, this method returns
the first bundle found.
@param bc bundle context
@param symbolicName bundle symbolic name
@return matching bundle, or null | [
"Returns",
"any",
"bundle",
"with",
"the",
"given",
"symbolic",
"name",
"or",
"null",
"if",
"no",
"such",
"bundle",
"exists",
".",
"If",
"there",
"are",
"multiple",
"bundles",
"with",
"the",
"same",
"symbolic",
"name",
"and",
"different",
"version",
"this",
... | 00b0ee16cdbe8017984a4d7ba808b10d985c5b5c | https://github.com/ops4j/org.ops4j.pax.swissbox/blob/00b0ee16cdbe8017984a4d7ba808b10d985c5b5c/pax-swissbox-core/src/main/java/org/ops4j/pax/swissbox/core/BundleUtils.java#L94-L97 | train |
ops4j/org.ops4j.pax.swissbox | pax-swissbox-core/src/main/java/org/ops4j/pax/swissbox/core/BundleUtils.java | BundleUtils.getBundles | public static List<Bundle> getBundles( BundleContext bc, String symbolicName )
{
List<Bundle> bundles = new ArrayList<Bundle>();
for( Bundle bundle : bc.getBundles() )
{
if( bundle.getSymbolicName().equals( symbolicName ) )
{
bundles.add( bundle );
... | java | public static List<Bundle> getBundles( BundleContext bc, String symbolicName )
{
List<Bundle> bundles = new ArrayList<Bundle>();
for( Bundle bundle : bc.getBundles() )
{
if( bundle.getSymbolicName().equals( symbolicName ) )
{
bundles.add( bundle );
... | [
"public",
"static",
"List",
"<",
"Bundle",
">",
"getBundles",
"(",
"BundleContext",
"bc",
",",
"String",
"symbolicName",
")",
"{",
"List",
"<",
"Bundle",
">",
"bundles",
"=",
"new",
"ArrayList",
"<",
"Bundle",
">",
"(",
")",
";",
"for",
"(",
"Bundle",
... | Returns a list of all bundles with the given symbolic name.
@param bc bundle context
@param symbolicName bundle symbolic name
@return matching bundles. The list may be empty, but never null. | [
"Returns",
"a",
"list",
"of",
"all",
"bundles",
"with",
"the",
"given",
"symbolic",
"name",
"."
] | 00b0ee16cdbe8017984a4d7ba808b10d985c5b5c | https://github.com/ops4j/org.ops4j.pax.swissbox/blob/00b0ee16cdbe8017984a4d7ba808b10d985c5b5c/pax-swissbox-core/src/main/java/org/ops4j/pax/swissbox/core/BundleUtils.java#L106-L117 | train |
ops4j/org.ops4j.pax.swissbox | pax-swissbox-core/src/main/java/org/ops4j/pax/swissbox/core/BundleUtils.java | BundleUtils.getBundle | public static Bundle getBundle( BundleContext bc, String symbolicName, String version )
{
for( Bundle bundle : bc.getBundles() )
{
if( bundle.getSymbolicName().equals( symbolicName ) )
{
if( version == null || version.equals( bundle.getVersion() ) )
... | java | public static Bundle getBundle( BundleContext bc, String symbolicName, String version )
{
for( Bundle bundle : bc.getBundles() )
{
if( bundle.getSymbolicName().equals( symbolicName ) )
{
if( version == null || version.equals( bundle.getVersion() ) )
... | [
"public",
"static",
"Bundle",
"getBundle",
"(",
"BundleContext",
"bc",
",",
"String",
"symbolicName",
",",
"String",
"version",
")",
"{",
"for",
"(",
"Bundle",
"bundle",
":",
"bc",
".",
"getBundles",
"(",
")",
")",
"{",
"if",
"(",
"bundle",
".",
"getSymb... | Returns the bundle with the given symbolic name and the given version, or null if no such
bundle exists
@param bc bundle context
@param symbolicName bundle symbolic name
@param version bundle version
@return matching bundle, or null | [
"Returns",
"the",
"bundle",
"with",
"the",
"given",
"symbolic",
"name",
"and",
"the",
"given",
"version",
"or",
"null",
"if",
"no",
"such",
"bundle",
"exists"
] | 00b0ee16cdbe8017984a4d7ba808b10d985c5b5c | https://github.com/ops4j/org.ops4j.pax.swissbox/blob/00b0ee16cdbe8017984a4d7ba808b10d985c5b5c/pax-swissbox-core/src/main/java/org/ops4j/pax/swissbox/core/BundleUtils.java#L128-L141 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/restclient/jaxb/webquery/WQConstraint.java | WQConstraint.encodeValue | public String encodeValue()
{
switch (function)
{
case EQ:
if (value != null && value.startsWith("_"))
return function.getPrefix() + value;
else
return value;
default:
if (function.hasBinaryParam())
return function.getPrefix() + value + ".." + value2;
else if (function.hasParam... | java | public String encodeValue()
{
switch (function)
{
case EQ:
if (value != null && value.startsWith("_"))
return function.getPrefix() + value;
else
return value;
default:
if (function.hasBinaryParam())
return function.getPrefix() + value + ".." + value2;
else if (function.hasParam... | [
"public",
"String",
"encodeValue",
"(",
")",
"{",
"switch",
"(",
"function",
")",
"{",
"case",
"EQ",
":",
"if",
"(",
"value",
"!=",
"null",
"&&",
"value",
".",
"startsWith",
"(",
"\"_\"",
")",
")",
"return",
"function",
".",
"getPrefix",
"(",
")",
"+... | Encode this constraint in the query string value format
@return | [
"Encode",
"this",
"constraint",
"in",
"the",
"query",
"string",
"value",
"format"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/restclient/jaxb/webquery/WQConstraint.java#L92-L109 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/restclient/jaxb/webquery/WQConstraint.java | WQConstraint.decode | public static WQConstraint decode(final String field, final String rawValue)
{
final WQFunctionType function;
final String value;
if (StringUtils.equalsIgnoreCase(rawValue, WQFunctionType.IS_NULL.getPrefix()))
return new WQConstraint(field, WQFunctionType.IS_NULL, null);
else if (StringUtils.equalsIgnoreCa... | java | public static WQConstraint decode(final String field, final String rawValue)
{
final WQFunctionType function;
final String value;
if (StringUtils.equalsIgnoreCase(rawValue, WQFunctionType.IS_NULL.getPrefix()))
return new WQConstraint(field, WQFunctionType.IS_NULL, null);
else if (StringUtils.equalsIgnoreCa... | [
"public",
"static",
"WQConstraint",
"decode",
"(",
"final",
"String",
"field",
",",
"final",
"String",
"rawValue",
")",
"{",
"final",
"WQFunctionType",
"function",
";",
"final",
"String",
"value",
";",
"if",
"(",
"StringUtils",
".",
"equalsIgnoreCase",
"(",
"r... | Produce a WebQueryConstraint from a Query String format parameter
@param field
@param rawValue
@return | [
"Produce",
"a",
"WebQueryConstraint",
"from",
"a",
"Query",
"String",
"format",
"parameter"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/restclient/jaxb/webquery/WQConstraint.java#L238-L278 | train |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/mysql/CheckMysql.java | CheckMysql.checkSlave | private Metric checkSlave(final ICommandLine cl, final Mysql mysql, final Connection conn) throws MetricGatheringException {
Metric metric = null;
try {
Map<String, Integer> status = getSlaveStatus(conn);
if (status.isEmpty()) {
mysql.closeConnection(conn);
... | java | private Metric checkSlave(final ICommandLine cl, final Mysql mysql, final Connection conn) throws MetricGatheringException {
Metric metric = null;
try {
Map<String, Integer> status = getSlaveStatus(conn);
if (status.isEmpty()) {
mysql.closeConnection(conn);
... | [
"private",
"Metric",
"checkSlave",
"(",
"final",
"ICommandLine",
"cl",
",",
"final",
"Mysql",
"mysql",
",",
"final",
"Connection",
"conn",
")",
"throws",
"MetricGatheringException",
"{",
"Metric",
"metric",
"=",
"null",
";",
"try",
"{",
"Map",
"<",
"String",
... | Check the status of mysql slave thread.
@param cl
The command line
@param mysql
MySQL connection mgr object
@param conn
The SQL connection
@return ReturnValue -
@throws MetricGatheringException
- | [
"Check",
"the",
"status",
"of",
"mysql",
"slave",
"thread",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/mysql/CheckMysql.java#L117-L146 | train |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/mysql/CheckMysql.java | CheckMysql.getSlaveStatus | private Map<String, Integer> getSlaveStatus(final Connection conn) throws SQLException {
Map<String, Integer> map = new HashMap<String, Integer>();
String query = SLAVE_STATUS_QRY;
Statement statement = null;
ResultSet rs = null;
try {
if (conn != null) {
... | java | private Map<String, Integer> getSlaveStatus(final Connection conn) throws SQLException {
Map<String, Integer> map = new HashMap<String, Integer>();
String query = SLAVE_STATUS_QRY;
Statement statement = null;
ResultSet rs = null;
try {
if (conn != null) {
... | [
"private",
"Map",
"<",
"String",
",",
"Integer",
">",
"getSlaveStatus",
"(",
"final",
"Connection",
"conn",
")",
"throws",
"SQLException",
"{",
"Map",
"<",
"String",
",",
"Integer",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Integer",
">",
"... | Get slave statuses.
@param conn
The database connection
@return The slave status info
@throws SQLException
- | [
"Get",
"slave",
"statuses",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/mysql/CheckMysql.java#L157-L177 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/net/packet/AbstractJNRPEProtocolPacket.java | AbstractJNRPEProtocolPacket.updateCRC | public void updateCRC() {
this.crc32 = 0;
CRC32 crcAlg = new CRC32();
crcAlg.update(this.toByteArray());
this.crc32 = (int) crcAlg.getValue();
} | java | public void updateCRC() {
this.crc32 = 0;
CRC32 crcAlg = new CRC32();
crcAlg.update(this.toByteArray());
this.crc32 = (int) crcAlg.getValue();
} | [
"public",
"void",
"updateCRC",
"(",
")",
"{",
"this",
".",
"crc32",
"=",
"0",
";",
"CRC32",
"crcAlg",
"=",
"new",
"CRC32",
"(",
")",
";",
"crcAlg",
".",
"update",
"(",
"this",
".",
"toByteArray",
"(",
")",
")",
";",
"this",
".",
"crc32",
"=",
"("... | Updates the CRC value. | [
"Updates",
"the",
"CRC",
"value",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/net/packet/AbstractJNRPEProtocolPacket.java#L91-L97 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/RangeStringParser.java | RangeStringParser.configureParser | private static Stage configureParser() {
Stage startStage = new StartStage();
Stage negativeInfinityStage = new NegativeInfinityStage();
Stage positiveInfinityStage = new PositiveInfinityStage();
NegateStage negateStage = new NegateStage();
BracketStage.OpenBracketStage openBrace... | java | private static Stage configureParser() {
Stage startStage = new StartStage();
Stage negativeInfinityStage = new NegativeInfinityStage();
Stage positiveInfinityStage = new PositiveInfinityStage();
NegateStage negateStage = new NegateStage();
BracketStage.OpenBracketStage openBrace... | [
"private",
"static",
"Stage",
"configureParser",
"(",
")",
"{",
"Stage",
"startStage",
"=",
"new",
"StartStage",
"(",
")",
";",
"Stage",
"negativeInfinityStage",
"=",
"new",
"NegativeInfinityStage",
"(",
")",
";",
"Stage",
"positiveInfinityStage",
"=",
"new",
"P... | Configures the state machine.
@return The configured state machine. | [
"Configures",
"the",
"state",
"machine",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/RangeStringParser.java#L43-L73 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/RangeStringParser.java | RangeStringParser.parse | public static void parse(final String range, final RangeConfig tc) throws RangeException {
if (range == null) {
throw new RangeException("Range can't be null");
}
ROOT_STAGE.parse(range, tc);
checkBoundaries(tc);
} | java | public static void parse(final String range, final RangeConfig tc) throws RangeException {
if (range == null) {
throw new RangeException("Range can't be null");
}
ROOT_STAGE.parse(range, tc);
checkBoundaries(tc);
} | [
"public",
"static",
"void",
"parse",
"(",
"final",
"String",
"range",
",",
"final",
"RangeConfig",
"tc",
")",
"throws",
"RangeException",
"{",
"if",
"(",
"range",
"==",
"null",
")",
"{",
"throw",
"new",
"RangeException",
"(",
"\"Range can't be null\"",
")",
... | Parses the threshold.
@param range
The threshold to be parsed
@param tc
The configuration
@throws RangeException
- | [
"Parses",
"the",
"threshold",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/RangeStringParser.java#L85-L91 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/RangeStringParser.java | RangeStringParser.checkBoundaries | private static void checkBoundaries(final RangeConfig rc) throws RangeException {
if (rc.isNegativeInfinity()) {
// No other checks necessary. Negative infinity is less than any
// number
return;
}
if (rc.isPositiveInfinity()) {
// No other checks... | java | private static void checkBoundaries(final RangeConfig rc) throws RangeException {
if (rc.isNegativeInfinity()) {
// No other checks necessary. Negative infinity is less than any
// number
return;
}
if (rc.isPositiveInfinity()) {
// No other checks... | [
"private",
"static",
"void",
"checkBoundaries",
"(",
"final",
"RangeConfig",
"rc",
")",
"throws",
"RangeException",
"{",
"if",
"(",
"rc",
".",
"isNegativeInfinity",
"(",
")",
")",
"{",
"// No other checks necessary. Negative infinity is less than any",
"// number",
"ret... | Checks that right boundary is greater than left boundary.
@param rc
The range configuration
@throws RangeException
If right < left | [
"Checks",
"that",
"right",
"boundary",
"is",
"greater",
"than",
"left",
"boundary",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/RangeStringParser.java#L101-L118 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/TimecodeBuilder.java | TimecodeBuilder.withTimecode | public TimecodeBuilder withTimecode(Timecode timecode)
{
return this
.withNegative(timecode.isNegative())
.withDays(timecode.getDaysPart())
.withHours(timecode.getHoursPart())
.withMinutes(timecode.getMinutesPart())
.withSeconds(timecode.getSecondsPart())
... | java | public TimecodeBuilder withTimecode(Timecode timecode)
{
return this
.withNegative(timecode.isNegative())
.withDays(timecode.getDaysPart())
.withHours(timecode.getHoursPart())
.withMinutes(timecode.getMinutesPart())
.withSeconds(timecode.getSecondsPart())
... | [
"public",
"TimecodeBuilder",
"withTimecode",
"(",
"Timecode",
"timecode",
")",
"{",
"return",
"this",
".",
"withNegative",
"(",
"timecode",
".",
"isNegative",
"(",
")",
")",
".",
"withDays",
"(",
"timecode",
".",
"getDaysPart",
"(",
")",
")",
".",
"withHours... | Reset this builder to the values in the provided Timecode
@param timecode
@return | [
"Reset",
"this",
"builder",
"to",
"the",
"values",
"in",
"the",
"provided",
"Timecode"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/TimecodeBuilder.java#L30-L41 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/TimecodeBuilder.java | TimecodeBuilder.build | public Timecode build()
{
// If drop-frame is not specified (and timebase is drop frame capable) default to true
final boolean dropFrame = (this.dropFrame != null) ? this.dropFrame.booleanValue() : getRate().canBeDropFrame();
return new Timecode(negative, days, hours, minutes, seconds, frames, rate, dropFrame);... | java | public Timecode build()
{
// If drop-frame is not specified (and timebase is drop frame capable) default to true
final boolean dropFrame = (this.dropFrame != null) ? this.dropFrame.booleanValue() : getRate().canBeDropFrame();
return new Timecode(negative, days, hours, minutes, seconds, frames, rate, dropFrame);... | [
"public",
"Timecode",
"build",
"(",
")",
"{",
"// If drop-frame is not specified (and timebase is drop frame capable) default to true",
"final",
"boolean",
"dropFrame",
"=",
"(",
"this",
".",
"dropFrame",
"!=",
"null",
")",
"?",
"this",
".",
"dropFrame",
".",
"booleanVa... | Constructs a Timecode instance with the fields defined in this builder
@return
@throws IllegalArgumentException
if any of the fields are invalid/incompatible | [
"Constructs",
"a",
"Timecode",
"instance",
"with",
"the",
"fields",
"defined",
"in",
"this",
"builder"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/TimecodeBuilder.java#L142-L148 | train |
petergeneric/stdlib | service-manager/configuration/src/main/java/com/peterphi/configuration/service/git/ConfigRepository.java | ConfigRepository.setAll | public void setAll(final String name,
final String email,
final Map<String, Map<String, ConfigPropertyValue>> data,
final String message)
{
set(name, email, data, ConfigChangeMode.WIPE_ALL, message);
} | java | public void setAll(final String name,
final String email,
final Map<String, Map<String, ConfigPropertyValue>> data,
final String message)
{
set(name, email, data, ConfigChangeMode.WIPE_ALL, message);
} | [
"public",
"void",
"setAll",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"email",
",",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"ConfigPropertyValue",
">",
">",
"data",
",",
"final",
"String",
"message",
")",
"{",
"set",
... | Create a new commit reflecting the provided properties, removing any property not mentioned here
@param name
@param email
@param data
@param message | [
"Create",
"a",
"new",
"commit",
"reflecting",
"the",
"provided",
"properties",
"removing",
"any",
"property",
"not",
"mentioned",
"here"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/configuration/src/main/java/com/peterphi/configuration/service/git/ConfigRepository.java#L82-L88 | train |
petergeneric/stdlib | service-manager/configuration/src/main/java/com/peterphi/configuration/service/git/ConfigRepository.java | ConfigRepository.set | public void set(final String name,
final String email,
final Map<String, Map<String, ConfigPropertyValue>> data,
final ConfigChangeMode changeMode,
final String message)
{
try
{
RepoHelper.write(repo, name, email, data, changeMode, message);
... | java | public void set(final String name,
final String email,
final Map<String, Map<String, ConfigPropertyValue>> data,
final ConfigChangeMode changeMode,
final String message)
{
try
{
RepoHelper.write(repo, name, email, data, changeMode, message);
... | [
"public",
"void",
"set",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"email",
",",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"ConfigPropertyValue",
">",
">",
"data",
",",
"final",
"ConfigChangeMode",
"changeMode",
",",
"fin... | Create a new commit reflecting the provided properties
@param name
@param email
@param data
@param erase
if true all existing properties will be erased
@param message | [
"Create",
"a",
"new",
"commit",
"reflecting",
"the",
"provided",
"properties"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/configuration/src/main/java/com/peterphi/configuration/service/git/ConfigRepository.java#L101-L137 | train |
petergeneric/stdlib | guice/webapp/src/main/java/com/peterphi/std/guice/web/HttpCallContext.java | HttpCallContext.get | public static HttpCallContext get() throws IllegalStateException
{
final HttpCallContext ctx = peek();
if (ctx != null)
return ctx;
else
throw new IllegalStateException("Not in an HttpCallContext!");
} | java | public static HttpCallContext get() throws IllegalStateException
{
final HttpCallContext ctx = peek();
if (ctx != null)
return ctx;
else
throw new IllegalStateException("Not in an HttpCallContext!");
} | [
"public",
"static",
"HttpCallContext",
"get",
"(",
")",
"throws",
"IllegalStateException",
"{",
"final",
"HttpCallContext",
"ctx",
"=",
"peek",
"(",
")",
";",
"if",
"(",
"ctx",
"!=",
"null",
")",
"return",
"ctx",
";",
"else",
"throw",
"new",
"IllegalStateExc... | Retrieve the HttpCallContext associated with this Thread
@return
@throws IllegalStateException
if not inside an http call | [
"Retrieve",
"the",
"HttpCallContext",
"associated",
"with",
"this",
"Thread"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/webapp/src/main/java/com/peterphi/std/guice/web/HttpCallContext.java#L31-L39 | train |
petergeneric/stdlib | guice/webapp/src/main/java/com/peterphi/std/guice/web/HttpCallContext.java | HttpCallContext.set | public static HttpCallContext set(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
{
final HttpCallContext ctx = new HttpCallContext(generateTraceId(request), request, response, servletContext);
contexts.set(ctx);
return ctx;
} | java | public static HttpCallContext set(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
{
final HttpCallContext ctx = new HttpCallContext(generateTraceId(request), request, response, servletContext);
contexts.set(ctx);
return ctx;
} | [
"public",
"static",
"HttpCallContext",
"set",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"ServletContext",
"servletContext",
")",
"{",
"final",
"HttpCallContext",
"ctx",
"=",
"new",
"HttpCallContext",
"(",
"generateTraceId",
"(",
... | Creates and associates an HttpCallContext with the current Thread
@param request
@param response
@return | [
"Creates",
"and",
"associates",
"an",
"HttpCallContext",
"with",
"the",
"current",
"Thread"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/webapp/src/main/java/com/peterphi/std/guice/web/HttpCallContext.java#L70-L77 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/crypto/openssl/OpenSSLPKCS12.java | OpenSSLPKCS12.filterP12 | public static void filterP12(File p12, String p12Password) throws IOException
{
if (!p12.exists())
throw new IllegalArgumentException("p12 file does not exist: " + p12.getPath());
final File pem;
if (USE_GENERIC_TEMP_DIRECTORY)
pem = File.createTempFile(UUID.randomUUID().toString(), "");
else
pem = n... | java | public static void filterP12(File p12, String p12Password) throws IOException
{
if (!p12.exists())
throw new IllegalArgumentException("p12 file does not exist: " + p12.getPath());
final File pem;
if (USE_GENERIC_TEMP_DIRECTORY)
pem = File.createTempFile(UUID.randomUUID().toString(), "");
else
pem = n... | [
"public",
"static",
"void",
"filterP12",
"(",
"File",
"p12",
",",
"String",
"p12Password",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"p12",
".",
"exists",
"(",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"p12 file does not exist: \"",
... | Recreates a PKCS12 KeyStore using OpenSSL; this is a workaround a BouncyCastle-Firefox compatibility bug
@param p12
The PKCS12 Keystore to filter
@param p12Password
The password for the keystore
@throws IOException
if a catastrophic unexpected failure occurs during execution
@throws IllegalArgumentException
if the PK... | [
"Recreates",
"a",
"PKCS12",
"KeyStore",
"using",
"OpenSSL",
";",
"this",
"is",
"a",
"workaround",
"a",
"BouncyCastle",
"-",
"Firefox",
"compatibility",
"bug"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/crypto/openssl/OpenSSLPKCS12.java#L34-L59 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/retry/retry/RetryManager.java | RetryManager.runUnchecked | public <T> T runUnchecked(Retryable<T> operation) throws RuntimeException
{
try
{
return run(operation);
}
catch (RuntimeException e)
{
throw e;
}
catch (Exception e)
{
throw new RuntimeException("Retryable " + operation + " failed: " + e.getMessage(), e);
}
} | java | public <T> T runUnchecked(Retryable<T> operation) throws RuntimeException
{
try
{
return run(operation);
}
catch (RuntimeException e)
{
throw e;
}
catch (Exception e)
{
throw new RuntimeException("Retryable " + operation + " failed: " + e.getMessage(), e);
}
} | [
"public",
"<",
"T",
">",
"T",
"runUnchecked",
"(",
"Retryable",
"<",
"T",
">",
"operation",
")",
"throws",
"RuntimeException",
"{",
"try",
"{",
"return",
"run",
"(",
"operation",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"throw",
... | Run the operation, only throwing an unchecked exception on failure
@param operation
@param <T>
@return
@throws RuntimeException | [
"Run",
"the",
"operation",
"only",
"throwing",
"an",
"unchecked",
"exception",
"on",
"failure"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/retry/retry/RetryManager.java#L131-L145 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/JNRPELogger.java | JNRPELogger.trace | public void trace(final IJNRPEExecutionContext ctx, final String message) {
postEvent(ctx, new LogEvent(source, LogEventType.TRACE, message));
} | java | public void trace(final IJNRPEExecutionContext ctx, final String message) {
postEvent(ctx, new LogEvent(source, LogEventType.TRACE, message));
} | [
"public",
"void",
"trace",
"(",
"final",
"IJNRPEExecutionContext",
"ctx",
",",
"final",
"String",
"message",
")",
"{",
"postEvent",
"(",
"ctx",
",",
"new",
"LogEvent",
"(",
"source",
",",
"LogEventType",
".",
"TRACE",
",",
"message",
")",
")",
";",
"}"
] | Sends trace level messages.
@param ctx the JNRPE context
@param message the message | [
"Sends",
"trace",
"level",
"messages",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/JNRPELogger.java#L49-L51 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/JNRPELogger.java | JNRPELogger.debug | public void debug(final IJNRPEExecutionContext ctx, final String message) {
postEvent(ctx, new LogEvent(source, LogEventType.DEBUG, message));
} | java | public void debug(final IJNRPEExecutionContext ctx, final String message) {
postEvent(ctx, new LogEvent(source, LogEventType.DEBUG, message));
} | [
"public",
"void",
"debug",
"(",
"final",
"IJNRPEExecutionContext",
"ctx",
",",
"final",
"String",
"message",
")",
"{",
"postEvent",
"(",
"ctx",
",",
"new",
"LogEvent",
"(",
"source",
",",
"LogEventType",
".",
"DEBUG",
",",
"message",
")",
")",
";",
"}"
] | Sends debug level messages.
@param ctx the JNRPE context
@param message the message | [
"Sends",
"debug",
"level",
"messages",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/JNRPELogger.java#L70-L72 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/JNRPELogger.java | JNRPELogger.info | public void info(final IJNRPEExecutionContext ctx, final String message) {
postEvent(ctx, new LogEvent(source, LogEventType.INFO, message));
} | java | public void info(final IJNRPEExecutionContext ctx, final String message) {
postEvent(ctx, new LogEvent(source, LogEventType.INFO, message));
} | [
"public",
"void",
"info",
"(",
"final",
"IJNRPEExecutionContext",
"ctx",
",",
"final",
"String",
"message",
")",
"{",
"postEvent",
"(",
"ctx",
",",
"new",
"LogEvent",
"(",
"source",
",",
"LogEventType",
".",
"INFO",
",",
"message",
")",
")",
";",
"}"
] | Sends info level messages.
@param ctx the JNRPE context
@param message the message | [
"Sends",
"info",
"level",
"messages",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/JNRPELogger.java#L91-L93 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/JNRPELogger.java | JNRPELogger.warn | public void warn(final IJNRPEExecutionContext ctx, final String message) {
postEvent(ctx, new LogEvent(source, LogEventType.WARNING, message));
} | java | public void warn(final IJNRPEExecutionContext ctx, final String message) {
postEvent(ctx, new LogEvent(source, LogEventType.WARNING, message));
} | [
"public",
"void",
"warn",
"(",
"final",
"IJNRPEExecutionContext",
"ctx",
",",
"final",
"String",
"message",
")",
"{",
"postEvent",
"(",
"ctx",
",",
"new",
"LogEvent",
"(",
"source",
",",
"LogEventType",
".",
"WARNING",
",",
"message",
")",
")",
";",
"}"
] | Sends warn level messages.
@param ctx the JNRPE context
@param message the message | [
"Sends",
"warn",
"level",
"messages",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/JNRPELogger.java#L112-L114 | train |
petergeneric/stdlib | rules/src/main/java/com/peterphi/rules/RulesEngineImpl.java | RulesEngineImpl.matching | @Override
public Map<RuleSet, List<Rule>> matching(Rules rules,
Map<String, Object> vars,
boolean ignoreMethodErrors) throws OgnlException
{
Map<RuleSet, List<Rule>> ret = new HashMap<>();
for (RuleSet ruleSet : rules.ruleSets)
... | java | @Override
public Map<RuleSet, List<Rule>> matching(Rules rules,
Map<String, Object> vars,
boolean ignoreMethodErrors) throws OgnlException
{
Map<RuleSet, List<Rule>> ret = new HashMap<>();
for (RuleSet ruleSet : rules.ruleSets)
... | [
"@",
"Override",
"public",
"Map",
"<",
"RuleSet",
",",
"List",
"<",
"Rule",
">",
">",
"matching",
"(",
"Rules",
"rules",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"vars",
",",
"boolean",
"ignoreMethodErrors",
")",
"throws",
"OgnlException",
"{",
"Ma... | returns a list of the rules that match from the supplied Rules document
@param rules
@return | [
"returns",
"a",
"list",
"of",
"the",
"rules",
"that",
"match",
"from",
"the",
"supplied",
"Rules",
"document"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/rules/src/main/java/com/peterphi/rules/RulesEngineImpl.java#L140-L173 | train |
petergeneric/stdlib | rules/src/main/java/com/peterphi/rules/RulesEngineImpl.java | RulesEngineImpl.match | private List<Rule> match(final RuleSet ruleSet, final OgnlContext ognlContext) throws OgnlException
{
log.debug("Assessing input for ruleset : " + ruleSet.id);
//run the input commands
ruleSet.runInput(ognlContext);
final List<Rule> ret = new ArrayList<>();
//assess each rule against the input, return any... | java | private List<Rule> match(final RuleSet ruleSet, final OgnlContext ognlContext) throws OgnlException
{
log.debug("Assessing input for ruleset : " + ruleSet.id);
//run the input commands
ruleSet.runInput(ognlContext);
final List<Rule> ret = new ArrayList<>();
//assess each rule against the input, return any... | [
"private",
"List",
"<",
"Rule",
">",
"match",
"(",
"final",
"RuleSet",
"ruleSet",
",",
"final",
"OgnlContext",
"ognlContext",
")",
"throws",
"OgnlException",
"{",
"log",
".",
"debug",
"(",
"\"Assessing input for ruleset : \"",
"+",
"ruleSet",
".",
"id",
")",
"... | returns a list of rules that match in the given rule set
@param ruleSet
@param ognlContext
@return | [
"returns",
"a",
"list",
"of",
"rules",
"that",
"match",
"in",
"the",
"given",
"rule",
"set"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/rules/src/main/java/com/peterphi/rules/RulesEngineImpl.java#L273-L295 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/JNRPEBuilder.java | JNRPEBuilder.build | public JNRPE build() {
JNRPE jnrpe = new JNRPE(pluginRepository, commandRepository, charset, acceptParams, acceptedHosts, maxAcceptedConnections, readTimeout,
writeTimeout);
IJNRPEEventBus eventBus = jnrpe.getExecutionContext().getEventBus();
for (Object obj : eventList... | java | public JNRPE build() {
JNRPE jnrpe = new JNRPE(pluginRepository, commandRepository, charset, acceptParams, acceptedHosts, maxAcceptedConnections, readTimeout,
writeTimeout);
IJNRPEEventBus eventBus = jnrpe.getExecutionContext().getEventBus();
for (Object obj : eventList... | [
"public",
"JNRPE",
"build",
"(",
")",
"{",
"JNRPE",
"jnrpe",
"=",
"new",
"JNRPE",
"(",
"pluginRepository",
",",
"commandRepository",
",",
"charset",
",",
"acceptParams",
",",
"acceptedHosts",
",",
"maxAcceptedConnections",
",",
"readTimeout",
",",
"writeTimeout",
... | Builds the configured JNRPE instance.
@return the configured JNRPE instance | [
"Builds",
"the",
"configured",
"JNRPE",
"instance",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/JNRPEBuilder.java#L210-L221 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/restclient/resteasy/impl/ResteasyClientFactoryImpl.java | ResteasyClientFactoryImpl.getOrCreateClient | public ResteasyClient getOrCreateClient(final boolean fastFail,
final AuthScope authScope,
final Credentials credentials,
final boolean preemptiveAuth,
fina... | java | public ResteasyClient getOrCreateClient(final boolean fastFail,
final AuthScope authScope,
final Credentials credentials,
final boolean preemptiveAuth,
fina... | [
"public",
"ResteasyClient",
"getOrCreateClient",
"(",
"final",
"boolean",
"fastFail",
",",
"final",
"AuthScope",
"authScope",
",",
"final",
"Credentials",
"credentials",
",",
"final",
"boolean",
"preemptiveAuth",
",",
"final",
"boolean",
"storeCookies",
",",
"Consumer... | Build a new Resteasy Client, optionally with authentication credentials
@param fastFail
if true, use fast fail timeouts, otherwise false to use default timeouts
@param authScope
the auth scope to use - if null then defaults to <code>AuthScope.ANY</code>
@param credentials
the credentials to use (optional, e.g. {@link ... | [
"Build",
"a",
"new",
"Resteasy",
"Client",
"optionally",
"with",
"authentication",
"credentials"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/restclient/resteasy/impl/ResteasyClientFactoryImpl.java#L140-L151 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/restclient/resteasy/impl/ResteasyClientFactoryImpl.java | ResteasyClientFactoryImpl.createHttpClientCustomiser | public Consumer<HttpClientBuilder> createHttpClientCustomiser(final boolean fastFail,
final AuthScope authScope,
final Credentials credentials,
... | java | public Consumer<HttpClientBuilder> createHttpClientCustomiser(final boolean fastFail,
final AuthScope authScope,
final Credentials credentials,
... | [
"public",
"Consumer",
"<",
"HttpClientBuilder",
">",
"createHttpClientCustomiser",
"(",
"final",
"boolean",
"fastFail",
",",
"final",
"AuthScope",
"authScope",
",",
"final",
"Credentials",
"credentials",
",",
"final",
"boolean",
"preemptiveAuth",
",",
"final",
"boolea... | N.B. This method signature may change in the future to add new parameters
@param fastFail
@param authScope
@param credentials
@param preemptiveAuth
@param storeCookies
@param customiser
@return | [
"N",
".",
"B",
".",
"This",
"method",
"signature",
"may",
"change",
"in",
"the",
"future",
"to",
"add",
"new",
"parameters"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/restclient/resteasy/impl/ResteasyClientFactoryImpl.java#L166-L223 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/restclient/resteasy/impl/ResteasyClientFactoryImpl.java | ResteasyClientFactoryImpl.createHttpClient | public CloseableHttpClient createHttpClient(final Consumer<HttpClientBuilder> customiser)
{
final HttpClientBuilder builder = HttpClientBuilder.create();
// By default set long call timeouts
{
RequestConfig.Builder requestBuilder = RequestConfig.custom();
requestBuilder.setConnectTimeout((int) connection... | java | public CloseableHttpClient createHttpClient(final Consumer<HttpClientBuilder> customiser)
{
final HttpClientBuilder builder = HttpClientBuilder.create();
// By default set long call timeouts
{
RequestConfig.Builder requestBuilder = RequestConfig.custom();
requestBuilder.setConnectTimeout((int) connection... | [
"public",
"CloseableHttpClient",
"createHttpClient",
"(",
"final",
"Consumer",
"<",
"HttpClientBuilder",
">",
"customiser",
")",
"{",
"final",
"HttpClientBuilder",
"builder",
"=",
"HttpClientBuilder",
".",
"create",
"(",
")",
";",
"// By default set long call timeouts",
... | Build an HttpClient
@param customiser
@return | [
"Build",
"an",
"HttpClient"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/restclient/resteasy/impl/ResteasyClientFactoryImpl.java#L264-L293 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/StorageSize.java | StorageSize.multiply | public StorageSize multiply(BigInteger by)
{
final BigInteger result = getBits().multiply(by);
return new StorageSize(getUnit(), result);
} | java | public StorageSize multiply(BigInteger by)
{
final BigInteger result = getBits().multiply(by);
return new StorageSize(getUnit(), result);
} | [
"public",
"StorageSize",
"multiply",
"(",
"BigInteger",
"by",
")",
"{",
"final",
"BigInteger",
"result",
"=",
"getBits",
"(",
")",
".",
"multiply",
"(",
"by",
")",
";",
"return",
"new",
"StorageSize",
"(",
"getUnit",
"(",
")",
",",
"result",
")",
";",
... | Multiplies the storage size by a certain amount
@param that
@return | [
"Multiplies",
"the",
"storage",
"size",
"by",
"a",
"certain",
"amount"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/StorageSize.java#L378-L383 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/StorageSize.java | StorageSize.subtract | public StorageSize subtract(StorageSize that)
{
StorageUnit smallestUnit = StorageUnit.smallest(this.getUnit(), that.getUnit());
final BigInteger a = this.getBits();
final BigInteger b = that.getBits();
final BigInteger result = a.subtract(b);
return new StorageSize(smallestUnit, result);
} | java | public StorageSize subtract(StorageSize that)
{
StorageUnit smallestUnit = StorageUnit.smallest(this.getUnit(), that.getUnit());
final BigInteger a = this.getBits();
final BigInteger b = that.getBits();
final BigInteger result = a.subtract(b);
return new StorageSize(smallestUnit, result);
} | [
"public",
"StorageSize",
"subtract",
"(",
"StorageSize",
"that",
")",
"{",
"StorageUnit",
"smallestUnit",
"=",
"StorageUnit",
".",
"smallest",
"(",
"this",
".",
"getUnit",
"(",
")",
",",
"that",
".",
"getUnit",
"(",
")",
")",
";",
"final",
"BigInteger",
"a... | Subtracts a storage size from the current object, using the smallest unit as the resulting StorageSize's unit
@param storage
@return | [
"Subtracts",
"a",
"storage",
"size",
"from",
"the",
"current",
"object",
"using",
"the",
"smallest",
"unit",
"as",
"the",
"resulting",
"StorageSize",
"s",
"unit"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/StorageSize.java#L393-L402 | train |
petergeneric/stdlib | guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/auth/oauth2/RedirectToOAuthAccessRefuser.java | RedirectToOAuthAccessRefuser.isHtmlAcceptable | private boolean isHtmlAcceptable(HttpServletRequest request)
{
@SuppressWarnings("unchecked") final List<String> accepts = ListUtility.list(ListUtility.iterate(request.getHeaders(
HttpHeaderNames.ACCEPT)));
for (String accept : accepts)
{
if (StringUtils.startsWithIgnoreCase(accept, "text/html"))
ret... | java | private boolean isHtmlAcceptable(HttpServletRequest request)
{
@SuppressWarnings("unchecked") final List<String> accepts = ListUtility.list(ListUtility.iterate(request.getHeaders(
HttpHeaderNames.ACCEPT)));
for (String accept : accepts)
{
if (StringUtils.startsWithIgnoreCase(accept, "text/html"))
ret... | [
"private",
"boolean",
"isHtmlAcceptable",
"(",
"HttpServletRequest",
"request",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"final",
"List",
"<",
"String",
">",
"accepts",
"=",
"ListUtility",
".",
"list",
"(",
"ListUtility",
".",
"iterate",
"("... | Decides if an HTML response is acceptable to the client
@param request
@return | [
"Decides",
"if",
"an",
"HTML",
"response",
"is",
"acceptable",
"to",
"the",
"client"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/auth/oauth2/RedirectToOAuthAccessRefuser.java#L118-L130 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/apploader/impl/GuiceInjectorBootstrap.java | GuiceInjectorBootstrap.createInjector | public static Injector createInjector(final PropertyFile configuration, final GuiceSetup setup)
{
return new GuiceBuilder().withConfig(configuration).withSetup(setup).build();
} | java | public static Injector createInjector(final PropertyFile configuration, final GuiceSetup setup)
{
return new GuiceBuilder().withConfig(configuration).withSetup(setup).build();
} | [
"public",
"static",
"Injector",
"createInjector",
"(",
"final",
"PropertyFile",
"configuration",
",",
"final",
"GuiceSetup",
"setup",
")",
"{",
"return",
"new",
"GuiceBuilder",
"(",
")",
".",
"withConfig",
"(",
"configuration",
")",
".",
"withSetup",
"(",
"setup... | Creates an Injector by taking a preloaded service.properties and a pre-constructed GuiceSetup
@param properties
@param setup
@return | [
"Creates",
"an",
"Injector",
"by",
"taking",
"a",
"preloaded",
"service",
".",
"properties",
"and",
"a",
"pre",
"-",
"constructed",
"GuiceSetup"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/apploader/impl/GuiceInjectorBootstrap.java#L57-L60 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/ReturnValue.java | ReturnValue.getMessage | public String getMessage() {
if (performanceDataList.isEmpty()) {
return messageString;
}
StringBuilder res = new StringBuilder(messageString).append('|');
for (PerformanceData pd : performanceDataList) {
res.append(pd.toPerformanceString()).append(' ');
}... | java | public String getMessage() {
if (performanceDataList.isEmpty()) {
return messageString;
}
StringBuilder res = new StringBuilder(messageString).append('|');
for (PerformanceData pd : performanceDataList) {
res.append(pd.toPerformanceString()).append(' ');
}... | [
"public",
"String",
"getMessage",
"(",
")",
"{",
"if",
"(",
"performanceDataList",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"messageString",
";",
"}",
"StringBuilder",
"res",
"=",
"new",
"StringBuilder",
"(",
"messageString",
")",
".",
"append",
"(",
... | Returns the message. If the performance data has been passed in, they are
attached at the end of the message accordingly to the Nagios
specifications
@return The message and optionally the performance data | [
"Returns",
"the",
"message",
".",
"If",
"the",
"performance",
"data",
"has",
"been",
"passed",
"in",
"they",
"are",
"attached",
"at",
"the",
"end",
"of",
"the",
"message",
"accordingly",
"to",
"the",
"Nagios",
"specifications"
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/ReturnValue.java#L211-L220 | train |
petergeneric/stdlib | service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/rest/resource/daemon/AzureInstanceActionDaemon.java | AzureInstanceActionDaemon.start | private void start(final ResourceInstanceEntity instance)
{
azure.start(instance.getProviderInstanceId());
instance.setState(ResourceInstanceState.PROVISIONING);
} | java | private void start(final ResourceInstanceEntity instance)
{
azure.start(instance.getProviderInstanceId());
instance.setState(ResourceInstanceState.PROVISIONING);
} | [
"private",
"void",
"start",
"(",
"final",
"ResourceInstanceEntity",
"instance",
")",
"{",
"azure",
".",
"start",
"(",
"instance",
".",
"getProviderInstanceId",
"(",
")",
")",
";",
"instance",
".",
"setState",
"(",
"ResourceInstanceState",
".",
"PROVISIONING",
")... | Start the instance | [
"Start",
"the",
"instance"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/rest/resource/daemon/AzureInstanceActionDaemon.java#L87-L92 | train |
petergeneric/stdlib | service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/rest/resource/daemon/AzureInstanceActionDaemon.java | AzureInstanceActionDaemon.stop | private void stop(final ResourceInstanceEntity instance)
{
azure.stop(instance);
instance.setState(ResourceInstanceState.DISCARDING);
} | java | private void stop(final ResourceInstanceEntity instance)
{
azure.stop(instance);
instance.setState(ResourceInstanceState.DISCARDING);
} | [
"private",
"void",
"stop",
"(",
"final",
"ResourceInstanceEntity",
"instance",
")",
"{",
"azure",
".",
"stop",
"(",
"instance",
")",
";",
"instance",
".",
"setState",
"(",
"ResourceInstanceState",
".",
"DISCARDING",
")",
";",
"}"
] | Stop the instance | [
"Stop",
"the",
"instance"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/rest/resource/daemon/AzureInstanceActionDaemon.java#L96-L101 | train |
petergeneric/stdlib | service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/rest/resource/daemon/AzureInstanceActionDaemon.java | AzureInstanceActionDaemon.updateState | private void updateState(final ResourceInstanceEntity instance)
{
ResourceInstanceState actual = azure.determineState(instance);
instance.setState(actual);
} | java | private void updateState(final ResourceInstanceEntity instance)
{
ResourceInstanceState actual = azure.determineState(instance);
instance.setState(actual);
} | [
"private",
"void",
"updateState",
"(",
"final",
"ResourceInstanceEntity",
"instance",
")",
"{",
"ResourceInstanceState",
"actual",
"=",
"azure",
".",
"determineState",
"(",
"instance",
")",
";",
"instance",
".",
"setState",
"(",
"actual",
")",
";",
"}"
] | Check in with Azure on the instance state | [
"Check",
"in",
"with",
"Azure",
"on",
"the",
"instance",
"state"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/service-manager/src/main/java/com/peterphi/servicemanager/service/rest/resource/daemon/AzureInstanceActionDaemon.java#L105-L110 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/net/JNRPEIdleStateHandler.java | JNRPEIdleStateHandler.userEventTriggered | @Override
public void userEventTriggered(final ChannelHandlerContext ctx, final Object evt) {
if (evt instanceof IdleStateEvent) {
IdleStateEvent e = (IdleStateEvent) evt;
if (e.state() == IdleState.READER_IDLE) {
ctx.close();
LOG.warn(jnrpeContext, "R... | java | @Override
public void userEventTriggered(final ChannelHandlerContext ctx, final Object evt) {
if (evt instanceof IdleStateEvent) {
IdleStateEvent e = (IdleStateEvent) evt;
if (e.state() == IdleState.READER_IDLE) {
ctx.close();
LOG.warn(jnrpeContext, "R... | [
"@",
"Override",
"public",
"void",
"userEventTriggered",
"(",
"final",
"ChannelHandlerContext",
"ctx",
",",
"final",
"Object",
"evt",
")",
"{",
"if",
"(",
"evt",
"instanceof",
"IdleStateEvent",
")",
"{",
"IdleStateEvent",
"e",
"=",
"(",
"IdleStateEvent",
")",
... | Method userEventTriggered.
@param ctx ChannelHandlerContext
@param evt Object
@see io.netty.channel.ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object) | [
"Method",
"userEventTriggered",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/net/JNRPEIdleStateHandler.java#L59-L75 | train |
petergeneric/stdlib | guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/service/servicedescription/freemarker/RestServiceInfo.java | RestServiceInfo.truncatePath | static String truncatePath(String path, String commonPrefix)
{
final int nextSlash = path.indexOf('/', commonPrefix.length());
final int nextOpenCurly = path.indexOf('{', commonPrefix.length());
if (nextSlash > 0)
return path.substring(0, nextSlash);
else if (nextOpenCurly > 0)
return path.substring(0, ... | java | static String truncatePath(String path, String commonPrefix)
{
final int nextSlash = path.indexOf('/', commonPrefix.length());
final int nextOpenCurly = path.indexOf('{', commonPrefix.length());
if (nextSlash > 0)
return path.substring(0, nextSlash);
else if (nextOpenCurly > 0)
return path.substring(0, ... | [
"static",
"String",
"truncatePath",
"(",
"String",
"path",
",",
"String",
"commonPrefix",
")",
"{",
"final",
"int",
"nextSlash",
"=",
"path",
".",
"indexOf",
"(",
"'",
"'",
",",
"commonPrefix",
".",
"length",
"(",
")",
")",
";",
"final",
"int",
"nextOpen... | Truncate path to the completion of the segment ending with the common prefix
@param path
@param commonPrefix
@return | [
"Truncate",
"path",
"to",
"the",
"completion",
"of",
"the",
"segment",
"ending",
"with",
"the",
"common",
"prefix"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/service/servicedescription/freemarker/RestServiceInfo.java#L93-L104 | train |
petergeneric/stdlib | util/carbon-client/src/main/java/com/peterphi/carbon/type/mutable/CarbonSource.java | CarbonSource.setFilterGUIDs | public void setFilterGUIDs(List<String> filterGUIDs)
{
int i = 0;
for (String filterGUID : filterGUIDs)
{
// Remove filters (we're replacing them)
removeFilter("Filter_" + i);
// Build a new Filter_0 element
Element filter = buildFilterElement("Filter_" + i, filterGUID);
element.addContent(filt... | java | public void setFilterGUIDs(List<String> filterGUIDs)
{
int i = 0;
for (String filterGUID : filterGUIDs)
{
// Remove filters (we're replacing them)
removeFilter("Filter_" + i);
// Build a new Filter_0 element
Element filter = buildFilterElement("Filter_" + i, filterGUID);
element.addContent(filt... | [
"public",
"void",
"setFilterGUIDs",
"(",
"List",
"<",
"String",
">",
"filterGUIDs",
")",
"{",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"String",
"filterGUID",
":",
"filterGUIDs",
")",
"{",
"// Remove filters (we're replacing them)",
"removeFilter",
"(",
"\"Filter_... | Set the filter GUID, replacing any filter that is currently defined
@param filterGUIDs | [
"Set",
"the",
"filter",
"GUID",
"replacing",
"any",
"filter",
"that",
"is",
"currently",
"defined"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/util/carbon-client/src/main/java/com/peterphi/carbon/type/mutable/CarbonSource.java#L126-L142 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/ognl/OgnlFactory.java | OgnlFactory.getInstance | public static OgnlEvaluator getInstance(final Object root, final String expression)
{
final OgnlEvaluatorCollection collection = INSTANCE.getEvaluators(getRootClass(root));
return collection.get(expression);
} | java | public static OgnlEvaluator getInstance(final Object root, final String expression)
{
final OgnlEvaluatorCollection collection = INSTANCE.getEvaluators(getRootClass(root));
return collection.get(expression);
} | [
"public",
"static",
"OgnlEvaluator",
"getInstance",
"(",
"final",
"Object",
"root",
",",
"final",
"String",
"expression",
")",
"{",
"final",
"OgnlEvaluatorCollection",
"collection",
"=",
"INSTANCE",
".",
"getEvaluators",
"(",
"getRootClass",
"(",
"root",
")",
")",... | Get an OGNL Evaluator for a particular expression with a given input
@param root
an example instance of the root object that will be passed to this OGNL evaluator
@param expression
the OGNL expression
@return
@see <a href="https://commons.apache.org/proper/commons-ognl/language-guide.html">OGNL Language Guide</a> | [
"Get",
"an",
"OGNL",
"Evaluator",
"for",
"a",
"particular",
"expression",
"with",
"a",
"given",
"input"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/ognl/OgnlFactory.java#L61-L66 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/io/PropertyFile.java | PropertyFile.find | public static PropertyFile find(final ClassLoader classloader, final String... fileNames)
{
URL resolvedResource = null;
String resolvedFile = null;
for (String fileName : fileNames)
{
if (fileName.charAt(0) == '/')
{
File file = new File(fileName);
if (file.exists())
{
try
{
... | java | public static PropertyFile find(final ClassLoader classloader, final String... fileNames)
{
URL resolvedResource = null;
String resolvedFile = null;
for (String fileName : fileNames)
{
if (fileName.charAt(0) == '/')
{
File file = new File(fileName);
if (file.exists())
{
try
{
... | [
"public",
"static",
"PropertyFile",
"find",
"(",
"final",
"ClassLoader",
"classloader",
",",
"final",
"String",
"...",
"fileNames",
")",
"{",
"URL",
"resolvedResource",
"=",
"null",
";",
"String",
"resolvedFile",
"=",
"null",
";",
"for",
"(",
"String",
"fileNa... | Find a property file
@param classloader
@param fileName
@return | [
"Find",
"a",
"property",
"file"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/io/PropertyFile.java#L92-L143 | train |
petergeneric/stdlib | guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/webquery/impl/jpa/JPAQueryBuilder.java | JPAQueryBuilder.getClassesByDiscriminators | private List<Class<?>> getClassesByDiscriminators(Collection<String> discriminators)
{
Map<String, Class<?>> entitiesByName = new HashMap<>();
// Prepare a Map of discriminator name -> entity class
for (QEntity child : entity.getSubEntities())
{
entitiesByName.put(child.getDiscriminatorValue(), child.getEn... | java | private List<Class<?>> getClassesByDiscriminators(Collection<String> discriminators)
{
Map<String, Class<?>> entitiesByName = new HashMap<>();
// Prepare a Map of discriminator name -> entity class
for (QEntity child : entity.getSubEntities())
{
entitiesByName.put(child.getDiscriminatorValue(), child.getEn... | [
"private",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"getClassesByDiscriminators",
"(",
"Collection",
"<",
"String",
">",
"discriminators",
")",
"{",
"Map",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"entitiesByName",
"=",
"new",
"HashMap",
"<>",
"... | Translates the set of string discriminators into entity classes
@return | [
"Translates",
"the",
"set",
"of",
"string",
"discriminators",
"into",
"entity",
"classes"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/webquery/impl/jpa/JPAQueryBuilder.java#L110-L140 | train |
petergeneric/stdlib | guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/webquery/impl/jpa/JPAQueryBuilder.java | JPAQueryBuilder.getProperty | @Override
public Expression<?> getProperty(final WQPath path)
{
final JPAJoin join = getOrCreateJoin(path.getTail());
return join.property(path.getHead().getPath());
} | java | @Override
public Expression<?> getProperty(final WQPath path)
{
final JPAJoin join = getOrCreateJoin(path.getTail());
return join.property(path.getHead().getPath());
} | [
"@",
"Override",
"public",
"Expression",
"<",
"?",
">",
"getProperty",
"(",
"final",
"WQPath",
"path",
")",
"{",
"final",
"JPAJoin",
"join",
"=",
"getOrCreateJoin",
"(",
"path",
".",
"getTail",
"(",
")",
")",
";",
"return",
"join",
".",
"property",
"(",
... | Get a property, automatically creating any joins along the way as needed
@param path
@return | [
"Get",
"a",
"property",
"automatically",
"creating",
"any",
"joins",
"along",
"the",
"way",
"as",
"needed"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/webquery/impl/jpa/JPAQueryBuilder.java#L180-L186 | train |
petergeneric/stdlib | guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/webquery/impl/jpa/JPAQueryBuilder.java | JPAQueryBuilder.getOrCreateJoin | @Override
public JPAJoin getOrCreateJoin(final WQPath path)
{
if (path == null)
return new JPAJoin(criteriaBuilder, entity, root, false);
if (!joins.containsKey(path.getPath()))
{
final JPAJoin parent = getOrCreateJoin(path.getTail());
final JPAJoin join = parent.join(path.getHead().getPath());
j... | java | @Override
public JPAJoin getOrCreateJoin(final WQPath path)
{
if (path == null)
return new JPAJoin(criteriaBuilder, entity, root, false);
if (!joins.containsKey(path.getPath()))
{
final JPAJoin parent = getOrCreateJoin(path.getTail());
final JPAJoin join = parent.join(path.getHead().getPath());
j... | [
"@",
"Override",
"public",
"JPAJoin",
"getOrCreateJoin",
"(",
"final",
"WQPath",
"path",
")",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"return",
"new",
"JPAJoin",
"(",
"criteriaBuilder",
",",
"entity",
",",
"root",
",",
"false",
")",
";",
"if",
"(",
... | Ensure a join has been set up for a path
@param path
@return | [
"Ensure",
"a",
"join",
"has",
"been",
"set",
"up",
"for",
"a",
"path"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/webquery/impl/jpa/JPAQueryBuilder.java#L196-L216 | train |
petergeneric/stdlib | guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/webquery/impl/jpa/JPAQueryBuilder.java | JPAQueryBuilder.hasCollectionFetch | public boolean hasCollectionFetch()
{
if (fetches != null)
for (String fetch : fetches)
{
QEntity parent = entity;
final String[] parts = StringUtils.split(fetch, '.');
for (int i = 0; i < parts.length; i++)
{
// If this is a fully supported relation then continue checking
if (paren... | java | public boolean hasCollectionFetch()
{
if (fetches != null)
for (String fetch : fetches)
{
QEntity parent = entity;
final String[] parts = StringUtils.split(fetch, '.');
for (int i = 0; i < parts.length; i++)
{
// If this is a fully supported relation then continue checking
if (paren... | [
"public",
"boolean",
"hasCollectionFetch",
"(",
")",
"{",
"if",
"(",
"fetches",
"!=",
"null",
")",
"for",
"(",
"String",
"fetch",
":",
"fetches",
")",
"{",
"QEntity",
"parent",
"=",
"entity",
";",
"final",
"String",
"[",
"]",
"parts",
"=",
"StringUtils",... | Returns true if one of the fetches specified will result in a collection being pulled back | [
"Returns",
"true",
"if",
"one",
"of",
"the",
"fetches",
"specified",
"will",
"result",
"in",
"a",
"collection",
"being",
"pulled",
"back"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/webquery/impl/jpa/JPAQueryBuilder.java#L719-L770 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/Timecode.java | Timecode.subtract | public Timecode subtract(SampleCount samples)
{
final SampleCount mySamples = getSampleCount();
final SampleCount result = mySamples.subtract(samples);
return Timecode.getInstance(result, dropFrame);
} | java | public Timecode subtract(SampleCount samples)
{
final SampleCount mySamples = getSampleCount();
final SampleCount result = mySamples.subtract(samples);
return Timecode.getInstance(result, dropFrame);
} | [
"public",
"Timecode",
"subtract",
"(",
"SampleCount",
"samples",
")",
"{",
"final",
"SampleCount",
"mySamples",
"=",
"getSampleCount",
"(",
")",
";",
"final",
"SampleCount",
"result",
"=",
"mySamples",
".",
"subtract",
"(",
"samples",
")",
";",
"return",
"Time... | Subtract some samples from this timecode
@param samples
@return | [
"Subtract",
"some",
"samples",
"from",
"this",
"timecode"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/Timecode.java#L428-L434 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/Timecode.java | Timecode.add | public Timecode add(SampleCount samples)
{
final SampleCount mySamples = getSampleCount();
final SampleCount totalSamples = mySamples.add(samples);
return TimecodeBuilder.fromSamples(totalSamples, dropFrame).build();
} | java | public Timecode add(SampleCount samples)
{
final SampleCount mySamples = getSampleCount();
final SampleCount totalSamples = mySamples.add(samples);
return TimecodeBuilder.fromSamples(totalSamples, dropFrame).build();
} | [
"public",
"Timecode",
"add",
"(",
"SampleCount",
"samples",
")",
"{",
"final",
"SampleCount",
"mySamples",
"=",
"getSampleCount",
"(",
")",
";",
"final",
"SampleCount",
"totalSamples",
"=",
"mySamples",
".",
"add",
"(",
"samples",
")",
";",
"return",
"Timecode... | Add some samples to this timecode
@param samples
@return | [
"Add",
"some",
"samples",
"to",
"this",
"timecode"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/Timecode.java#L444-L450 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/Timecode.java | Timecode.addPrecise | public Timecode addPrecise(SampleCount samples) throws ResamplingException
{
final SampleCount mySamples = getSampleCount();
final SampleCount totalSamples = mySamples.addPrecise(samples);
return TimecodeBuilder.fromSamples(totalSamples, dropFrame).build();
} | java | public Timecode addPrecise(SampleCount samples) throws ResamplingException
{
final SampleCount mySamples = getSampleCount();
final SampleCount totalSamples = mySamples.addPrecise(samples);
return TimecodeBuilder.fromSamples(totalSamples, dropFrame).build();
} | [
"public",
"Timecode",
"addPrecise",
"(",
"SampleCount",
"samples",
")",
"throws",
"ResamplingException",
"{",
"final",
"SampleCount",
"mySamples",
"=",
"getSampleCount",
"(",
")",
";",
"final",
"SampleCount",
"totalSamples",
"=",
"mySamples",
".",
"addPrecise",
"(",... | Add some samples to this timecode, throwing an exception if precision would be lost
@param samples
@return
@throws ResamplingException
if the requested addition would result in a loss of accuracy due to resampling | [
"Add",
"some",
"samples",
"to",
"this",
"timecode",
"throwing",
"an",
"exception",
"if",
"precision",
"would",
"be",
"lost"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/Timecode.java#L463-L469 | train |
ziccardi/jnrpe | jnrpe-server/src/main/java/it/jnrpe/server/CommandsSection.java | CommandsSection.addCommand | public void addCommand(final String commandName, final String pluginName, final String commandLine) {
commandsList.add(new Command(commandName, pluginName, commandLine));
} | java | public void addCommand(final String commandName, final String pluginName, final String commandLine) {
commandsList.add(new Command(commandName, pluginName, commandLine));
} | [
"public",
"void",
"addCommand",
"(",
"final",
"String",
"commandName",
",",
"final",
"String",
"pluginName",
",",
"final",
"String",
"commandLine",
")",
"{",
"commandsList",
".",
"add",
"(",
"new",
"Command",
"(",
"commandName",
",",
"pluginName",
",",
"comman... | Adds a command to the section.
@param commandName
The command name
@param pluginName
The plugin name
@param commandLine
The command line | [
"Adds",
"a",
"command",
"to",
"the",
"section",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-server/src/main/java/it/jnrpe/server/CommandsSection.java#L102-L104 | train |
ops4j/org.ops4j.pax.swissbox | pax-swissbox-extender/src/main/java/org/ops4j/pax/swissbox/extender/BundleManifestScanner.java | BundleManifestScanner.scan | public List<ManifestEntry> scan( final Bundle bundle )
{
NullArgumentException.validateNotNull( bundle, "Bundle" );
final Dictionary bundleHeaders = bundle.getHeaders();
if( bundleHeaders != null && !bundleHeaders.isEmpty() )
{
return asManifestEntryList( m_manifestFilte... | java | public List<ManifestEntry> scan( final Bundle bundle )
{
NullArgumentException.validateNotNull( bundle, "Bundle" );
final Dictionary bundleHeaders = bundle.getHeaders();
if( bundleHeaders != null && !bundleHeaders.isEmpty() )
{
return asManifestEntryList( m_manifestFilte... | [
"public",
"List",
"<",
"ManifestEntry",
">",
"scan",
"(",
"final",
"Bundle",
"bundle",
")",
"{",
"NullArgumentException",
".",
"validateNotNull",
"(",
"bundle",
",",
"\"Bundle\"",
")",
";",
"final",
"Dictionary",
"bundleHeaders",
"=",
"bundle",
".",
"getHeaders"... | Scans bundle manifest for matches against configured manifest headers.
@param bundle bundle to be scanned
@return list of matching manifest entries
@see BundleScanner#scan(Bundle) | [
"Scans",
"bundle",
"manifest",
"for",
"matches",
"against",
"configured",
"manifest",
"headers",
"."
] | 00b0ee16cdbe8017984a4d7ba808b10d985c5b5c | https://github.com/ops4j/org.ops4j.pax.swissbox/blob/00b0ee16cdbe8017984a4d7ba808b10d985c5b5c/pax-swissbox-extender/src/main/java/org/ops4j/pax/swissbox/extender/BundleManifestScanner.java#L69-L82 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/Timebase.java | Timebase.resample | public double resample(final double samples, final Timebase oldRate)
{
if (samples == 0)
{
return 0;
}
else if (!this.equals(oldRate))
{
final double resampled = resample(samples, oldRate, this);
return resampled;
}
else
{
return samples;
}
} | java | public double resample(final double samples, final Timebase oldRate)
{
if (samples == 0)
{
return 0;
}
else if (!this.equals(oldRate))
{
final double resampled = resample(samples, oldRate, this);
return resampled;
}
else
{
return samples;
}
} | [
"public",
"double",
"resample",
"(",
"final",
"double",
"samples",
",",
"final",
"Timebase",
"oldRate",
")",
"{",
"if",
"(",
"samples",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"!",
"this",
".",
"equals",
"(",
"oldRate",
")",
... | Convert a sample count from one timebase to another
@param samples
@param oldRate
@return | [
"Convert",
"a",
"sample",
"count",
"from",
"one",
"timebase",
"to",
"another"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/Timebase.java#L247-L263 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/restclient/exception/RestExceptionFactory.java | RestExceptionFactory.buildKnown | private RestException buildKnown(Constructor<RestException> constructor, RestFailure failure)
{
try
{
return constructor.newInstance(failure.exception.detail, null);
}
catch (Exception e)
{
return buildUnknown(failure);
}
} | java | private RestException buildKnown(Constructor<RestException> constructor, RestFailure failure)
{
try
{
return constructor.newInstance(failure.exception.detail, null);
}
catch (Exception e)
{
return buildUnknown(failure);
}
} | [
"private",
"RestException",
"buildKnown",
"(",
"Constructor",
"<",
"RestException",
">",
"constructor",
",",
"RestFailure",
"failure",
")",
"{",
"try",
"{",
"return",
"constructor",
".",
"newInstance",
"(",
"failure",
".",
"exception",
".",
"detail",
",",
"null"... | Build an exception for a known exception type
@param constructor
@param failure
@return | [
"Build",
"an",
"exception",
"for",
"a",
"known",
"exception",
"type"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/restclient/exception/RestExceptionFactory.java#L70-L80 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/restclient/exception/RestExceptionFactory.java | RestExceptionFactory.buildUnknown | private UnboundRestException buildUnknown(RestFailure failure)
{
// We need to build up exception detail that reasonably accurately describes the source exception
final String msg = failure.exception.shortName + ": " + failure.exception.detail + " (" + failure.id + ")";
return new UnboundRestException(msg);
} | java | private UnboundRestException buildUnknown(RestFailure failure)
{
// We need to build up exception detail that reasonably accurately describes the source exception
final String msg = failure.exception.shortName + ": " + failure.exception.detail + " (" + failure.id + ")";
return new UnboundRestException(msg);
} | [
"private",
"UnboundRestException",
"buildUnknown",
"(",
"RestFailure",
"failure",
")",
"{",
"// We need to build up exception detail that reasonably accurately describes the source exception",
"final",
"String",
"msg",
"=",
"failure",
".",
"exception",
".",
"shortName",
"+",
"\... | Build an exception to represent an unknown or problematic exception type
@param failure
@return | [
"Build",
"an",
"exception",
"to",
"represent",
"an",
"unknown",
"or",
"problematic",
"exception",
"type"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/restclient/exception/RestExceptionFactory.java#L89-L95 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/io/nio/NIOHelper.java | NIOHelper.blockingRead | public static ByteBuffer blockingRead(SocketChannel so, long timeout, byte[] bytes) throws IOException
{
ByteBuffer b = ByteBuffer.wrap(bytes);
if (bytes.length == 0)
return b;
final long timeoutTime = (timeout > 0) ? (System.currentTimeMillis() + timeout) : (Long.MAX_VALUE);
while (b.remaining() != 0 &&... | java | public static ByteBuffer blockingRead(SocketChannel so, long timeout, byte[] bytes) throws IOException
{
ByteBuffer b = ByteBuffer.wrap(bytes);
if (bytes.length == 0)
return b;
final long timeoutTime = (timeout > 0) ? (System.currentTimeMillis() + timeout) : (Long.MAX_VALUE);
while (b.remaining() != 0 &&... | [
"public",
"static",
"ByteBuffer",
"blockingRead",
"(",
"SocketChannel",
"so",
",",
"long",
"timeout",
",",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"ByteBuffer",
"b",
"=",
"ByteBuffer",
".",
"wrap",
"(",
"bytes",
")",
";",
"if",
"(",
... | Read a number of bytes from a socket, terminating when complete, after timeout milliseconds or if an error occurs | [
"Read",
"a",
"number",
"of",
"bytes",
"from",
"a",
"socket",
"terminating",
"when",
"complete",
"after",
"timeout",
"milliseconds",
"or",
"if",
"an",
"error",
"occurs"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/io/nio/NIOHelper.java#L103-L140 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/util/jaxb/JAXBSerialiser.java | JAXBSerialiser.deserialise | public <T> T deserialise(final Class<T> clazz, final InputSource source)
{
final Object obj = deserialise(source);
if (clazz.isInstance(obj))
return clazz.cast(obj);
else
throw new JAXBRuntimeException("XML deserialised to " + obj.getClass() + ", could not cast to the expected " + clazz);
} | java | public <T> T deserialise(final Class<T> clazz, final InputSource source)
{
final Object obj = deserialise(source);
if (clazz.isInstance(obj))
return clazz.cast(obj);
else
throw new JAXBRuntimeException("XML deserialised to " + obj.getClass() + ", could not cast to the expected " + clazz);
} | [
"public",
"<",
"T",
">",
"T",
"deserialise",
"(",
"final",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"InputSource",
"source",
")",
"{",
"final",
"Object",
"obj",
"=",
"deserialise",
"(",
"source",
")",
";",
"if",
"(",
"clazz",
".",
"isInstance",
... | Deserialise an input and cast to a particular type
@param clazz
@param source
@return | [
"Deserialise",
"an",
"input",
"and",
"cast",
"to",
"a",
"particular",
"type"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/util/jaxb/JAXBSerialiser.java#L322-L330 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/util/jaxb/JAXBSerialiser.java | JAXBSerialiser.deserialise | public <T> T deserialise(final Class<T> clazz, final String xml)
{
final Object obj = deserialise(new InputSource(new StringReader(xml)));
if (clazz.isInstance(obj))
return clazz.cast(obj);
else
throw new JAXBRuntimeException("XML deserialised to " + obj.getClass() + ", could not cast to the expected " + ... | java | public <T> T deserialise(final Class<T> clazz, final String xml)
{
final Object obj = deserialise(new InputSource(new StringReader(xml)));
if (clazz.isInstance(obj))
return clazz.cast(obj);
else
throw new JAXBRuntimeException("XML deserialised to " + obj.getClass() + ", could not cast to the expected " + ... | [
"public",
"<",
"T",
">",
"T",
"deserialise",
"(",
"final",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"String",
"xml",
")",
"{",
"final",
"Object",
"obj",
"=",
"deserialise",
"(",
"new",
"InputSource",
"(",
"new",
"StringReader",
"(",
"xml",
")",
... | Deserialise and cast to a particular type
@param clazz
@param xml
a String of XML
@return | [
"Deserialise",
"and",
"cast",
"to",
"a",
"particular",
"type"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/util/jaxb/JAXBSerialiser.java#L342-L350 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/util/jaxb/JAXBSerialiser.java | JAXBSerialiser.serialiseToDocument | public Document serialiseToDocument(final Object obj)
{
final Document document = DOMUtils.createDocumentBuilder().newDocument();
serialise(obj, document);
return document;
} | java | public Document serialiseToDocument(final Object obj)
{
final Document document = DOMUtils.createDocumentBuilder().newDocument();
serialise(obj, document);
return document;
} | [
"public",
"Document",
"serialiseToDocument",
"(",
"final",
"Object",
"obj",
")",
"{",
"final",
"Document",
"document",
"=",
"DOMUtils",
".",
"createDocumentBuilder",
"(",
")",
".",
"newDocument",
"(",
")",
";",
"serialise",
"(",
"obj",
",",
"document",
")",
... | Helper method to serialise an Object to an org.w3c.dom.Document
@param obj
the object to serialise
@return a new Document containing the serialised form of the provided Object | [
"Helper",
"method",
"to",
"serialise",
"an",
"Object",
"to",
"an",
"org",
".",
"w3c",
".",
"dom",
".",
"Document"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/util/jaxb/JAXBSerialiser.java#L486-L493 | train |
petergeneric/stdlib | service-manager/host-agent/src/main/java/com/peterphi/servicemanager/hostagent/webapp/service/NginxService.java | NginxService.reload | public void reload()
{
try
{
final Execed process = Exec.rootUtility(new File(binPath, "nginx-reload").getAbsolutePath());
process.waitForExit(new Timeout(30, TimeUnit.SECONDS).start(), 0);
}
catch (IOException e)
{
throw new RuntimeException("Error executing nginx-reload command", e);
}
} | java | public void reload()
{
try
{
final Execed process = Exec.rootUtility(new File(binPath, "nginx-reload").getAbsolutePath());
process.waitForExit(new Timeout(30, TimeUnit.SECONDS).start(), 0);
}
catch (IOException e)
{
throw new RuntimeException("Error executing nginx-reload command", e);
}
} | [
"public",
"void",
"reload",
"(",
")",
"{",
"try",
"{",
"final",
"Execed",
"process",
"=",
"Exec",
".",
"rootUtility",
"(",
"new",
"File",
"(",
"binPath",
",",
"\"nginx-reload\"",
")",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"process",
".",
"waitForEx... | Reload the nginx configuration | [
"Reload",
"the",
"nginx",
"configuration"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/host-agent/src/main/java/com/peterphi/servicemanager/hostagent/webapp/service/NginxService.java#L25-L36 | train |
petergeneric/stdlib | service-manager/host-agent/src/main/java/com/peterphi/servicemanager/hostagent/webapp/service/NginxService.java | NginxService.reconfigure | public void reconfigure(final String config)
{
try
{
final File tempFile = File.createTempFile("nginx", ".conf");
try
{
FileHelper.write(tempFile, config);
final Execed process = Exec.rootUtility(new File(binPath, "nginx-reconfigure").getAbsolutePath(),
... | java | public void reconfigure(final String config)
{
try
{
final File tempFile = File.createTempFile("nginx", ".conf");
try
{
FileHelper.write(tempFile, config);
final Execed process = Exec.rootUtility(new File(binPath, "nginx-reconfigure").getAbsolutePath(),
... | [
"public",
"void",
"reconfigure",
"(",
"final",
"String",
"config",
")",
"{",
"try",
"{",
"final",
"File",
"tempFile",
"=",
"File",
".",
"createTempFile",
"(",
"\"nginx\"",
",",
"\".conf\"",
")",
";",
"try",
"{",
"FileHelper",
".",
"write",
"(",
"tempFile",... | Rewrite the nginx site configuration and reload
@param config
the nginx site configuration | [
"Rewrite",
"the",
"nginx",
"site",
"configuration",
"and",
"reload"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/host-agent/src/main/java/com/peterphi/servicemanager/hostagent/webapp/service/NginxService.java#L45-L70 | train |
petergeneric/stdlib | service-manager/host-agent/src/main/java/com/peterphi/servicemanager/hostagent/webapp/service/NginxService.java | NginxService.installCertificates | public void installCertificates(final String key, final String cert, final String chain)
{
try
{
final File keyFile = File.createTempFile("key", ".pem");
final File certFile = File.createTempFile("cert", ".pem");
final File chainFile = File.createTempFile("chain", ".pem");
try
{
FileHelper.writ... | java | public void installCertificates(final String key, final String cert, final String chain)
{
try
{
final File keyFile = File.createTempFile("key", ".pem");
final File certFile = File.createTempFile("cert", ".pem");
final File chainFile = File.createTempFile("chain", ".pem");
try
{
FileHelper.writ... | [
"public",
"void",
"installCertificates",
"(",
"final",
"String",
"key",
",",
"final",
"String",
"cert",
",",
"final",
"String",
"chain",
")",
"{",
"try",
"{",
"final",
"File",
"keyFile",
"=",
"File",
".",
"createTempFile",
"(",
"\"key\"",
",",
"\".pem\"",
... | Install new SSL Certificates for the host
@param key
@param cert
@param chain | [
"Install",
"new",
"SSL",
"Certificates",
"for",
"the",
"host"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/service-manager/host-agent/src/main/java/com/peterphi/servicemanager/hostagent/webapp/service/NginxService.java#L80-L112 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/util/ClassManifestLocator.java | ClassManifestLocator.get | public static PropertyFile get(Class<?> clazz)
{
try
{
// If we get a guice-enhanced class then we should go up one level to get the class name from the user's code
if (clazz.getName().contains("$$EnhancerByGuice$$"))
clazz = clazz.getSuperclass();
final String classFileName = clazz.getSimpleName() +... | java | public static PropertyFile get(Class<?> clazz)
{
try
{
// If we get a guice-enhanced class then we should go up one level to get the class name from the user's code
if (clazz.getName().contains("$$EnhancerByGuice$$"))
clazz = clazz.getSuperclass();
final String classFileName = clazz.getSimpleName() +... | [
"public",
"static",
"PropertyFile",
"get",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"try",
"{",
"// If we get a guice-enhanced class then we should go up one level to get the class name from the user's code",
"if",
"(",
"clazz",
".",
"getName",
"(",
")",
".",
"co... | Attempt to find the MANIFEST.MF associated with a particular class
@param clazz
The class whose jar/war should be searched for a MANIFEST.MF
@return a PropertyFile version of the main manifest attributes if found, otherwise null | [
"Attempt",
"to",
"find",
"the",
"MANIFEST",
".",
"MF",
"associated",
"with",
"a",
"particular",
"class"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/util/ClassManifestLocator.java#L28-L100 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/LoadedClassCache.java | LoadedClassCache.saveClass | private static void saveClass(final ClassLoader cl, final Class c) {
if (LOADED_PLUGINS.get(cl) == null) {
LOADED_PLUGINS.put(cl, new ClassesData());
}
ClassesData cd = LOADED_PLUGINS.get(cl);
cd.addClass(c);
} | java | private static void saveClass(final ClassLoader cl, final Class c) {
if (LOADED_PLUGINS.get(cl) == null) {
LOADED_PLUGINS.put(cl, new ClassesData());
}
ClassesData cd = LOADED_PLUGINS.get(cl);
cd.addClass(c);
} | [
"private",
"static",
"void",
"saveClass",
"(",
"final",
"ClassLoader",
"cl",
",",
"final",
"Class",
"c",
")",
"{",
"if",
"(",
"LOADED_PLUGINS",
".",
"get",
"(",
"cl",
")",
"==",
"null",
")",
"{",
"LOADED_PLUGINS",
".",
"put",
"(",
"cl",
",",
"new",
"... | Stores a class in the cache.
@param cl
The classloader
@param c
the class to be stored | [
"Stores",
"a",
"class",
"in",
"the",
"cache",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/LoadedClassCache.java#L118-L125 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/LoadedClassCache.java | LoadedClassCache.getClass | public static Class getClass(final ClassLoader cl, final String className) throws ClassNotFoundException {
if (LOADED_PLUGINS.get(cl) == null) {
LOADED_PLUGINS.put(cl, new ClassesData());
}
ClassesData cd = LOADED_PLUGINS.get(cl);
Class clazz = cd.getClass(className);
... | java | public static Class getClass(final ClassLoader cl, final String className) throws ClassNotFoundException {
if (LOADED_PLUGINS.get(cl) == null) {
LOADED_PLUGINS.put(cl, new ClassesData());
}
ClassesData cd = LOADED_PLUGINS.get(cl);
Class clazz = cd.getClass(className);
... | [
"public",
"static",
"Class",
"getClass",
"(",
"final",
"ClassLoader",
"cl",
",",
"final",
"String",
"className",
")",
"throws",
"ClassNotFoundException",
"{",
"if",
"(",
"LOADED_PLUGINS",
".",
"get",
"(",
"cl",
")",
"==",
"null",
")",
"{",
"LOADED_PLUGINS",
... | Returns a class object. If the class is new, a new Class object is
created, otherwise the cached object is returned.
@param cl
the classloader
@param className
the class name
@return the class object associated to the given class name * @throws ClassNotFoundException
if the class can't be loaded | [
"Returns",
"a",
"class",
"object",
".",
"If",
"the",
"class",
"is",
"new",
"a",
"new",
"Class",
"object",
"is",
"created",
"otherwise",
"the",
"cached",
"object",
"is",
"returned",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/LoadedClassCache.java#L139-L152 | train |
ziccardi/jnrpe | jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/ThresholdsEvaluator.java | ThresholdsEvaluator.evaluate | final Status evaluate(final Metric metric) {
if (metric == null || metric.getMetricValue() == null) {
throw new NullPointerException("Metric value can't be null");
}
IThreshold thr = thresholdsMap.get(metric.getMetricName());
if (thr == null) {
return Status.OK;... | java | final Status evaluate(final Metric metric) {
if (metric == null || metric.getMetricValue() == null) {
throw new NullPointerException("Metric value can't be null");
}
IThreshold thr = thresholdsMap.get(metric.getMetricName());
if (thr == null) {
return Status.OK;... | [
"final",
"Status",
"evaluate",
"(",
"final",
"Metric",
"metric",
")",
"{",
"if",
"(",
"metric",
"==",
"null",
"||",
"metric",
".",
"getMetricValue",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Metric value can't be null\""... | Evaluates the passed in metric against the threshold configured inside
this evaluator. If the threshold do not refer the passed in metric, then
it is ignored and the next threshold is checked.
@param metric
The metric to be checked
@return The status computed according to the rules specified for
{@link IThreshold#eva... | [
"Evaluates",
"the",
"passed",
"in",
"metric",
"against",
"the",
"threshold",
"configured",
"inside",
"this",
"evaluator",
".",
"If",
"the",
"threshold",
"do",
"not",
"refer",
"the",
"passed",
"in",
"metric",
"then",
"it",
"is",
"ignored",
"and",
"the",
"next... | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/ThresholdsEvaluator.java#L90-L102 | train |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/utils/Shell.java | Shell.executeSystemCommandAndGetOutput | public final String executeSystemCommandAndGetOutput(final String[] command, final String encoding) throws IOException {
Process p = Runtime.getRuntime().exec(command);
StreamManager sm = new StreamManager();
try {
InputStream input = sm.handle(p.getInputStream());
StringBuffer lines = new Stri... | java | public final String executeSystemCommandAndGetOutput(final String[] command, final String encoding) throws IOException {
Process p = Runtime.getRuntime().exec(command);
StreamManager sm = new StreamManager();
try {
InputStream input = sm.handle(p.getInputStream());
StringBuffer lines = new Stri... | [
"public",
"final",
"String",
"executeSystemCommandAndGetOutput",
"(",
"final",
"String",
"[",
"]",
"command",
",",
"final",
"String",
"encoding",
")",
"throws",
"IOException",
"{",
"Process",
"p",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"exec",
"(",
... | Executes a system command with arguments and returns the output.
@param command command to be executed
@param encoding encoding to be used
@return command output
@throws IOException on any error | [
"Executes",
"a",
"system",
"command",
"with",
"arguments",
"and",
"returns",
"the",
"output",
"."
] | ac9046355851136994388442b01ba4063305f9c4 | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/utils/Shell.java#L55-L72 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/threading/Daemon.java | Daemon.startThread | public synchronized Thread startThread(String name) throws IllegalThreadStateException
{
if (!running)
{
log.info("[Daemon] {startThread} Starting thread " + name);
this.running = true;
thisThread = new Thread(this, name);
thisThread.setDaemon(shouldStartAsDaemon()); // Set whether we're a daemon threa... | java | public synchronized Thread startThread(String name) throws IllegalThreadStateException
{
if (!running)
{
log.info("[Daemon] {startThread} Starting thread " + name);
this.running = true;
thisThread = new Thread(this, name);
thisThread.setDaemon(shouldStartAsDaemon()); // Set whether we're a daemon threa... | [
"public",
"synchronized",
"Thread",
"startThread",
"(",
"String",
"name",
")",
"throws",
"IllegalThreadStateException",
"{",
"if",
"(",
"!",
"running",
")",
"{",
"log",
".",
"info",
"(",
"\"[Daemon] {startThread} Starting thread \"",
"+",
"name",
")",
";",
"this",... | Starts this daemon, creating a new thread for it
@param name
String The name for the thread
@return Thread The daemon's thread
@throws IllegalThreadStateException
If the daemon is still running | [
"Starts",
"this",
"daemon",
"creating",
"a",
"new",
"thread",
"for",
"it"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/threading/Daemon.java#L75-L90 | train |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/threading/Daemon.java | Daemon.stopThread | public synchronized void stopThread()
{
if (isRunning())
{
if (log.isInfoEnabled())
log.info("[Daemon] {stopThread} Requesting termination of thread " + thisThread.getName());
this.running = false;
synchronized (this)
{
this.notifyAll();
}
}
else
{
throw new IllegalThreadStateExce... | java | public synchronized void stopThread()
{
if (isRunning())
{
if (log.isInfoEnabled())
log.info("[Daemon] {stopThread} Requesting termination of thread " + thisThread.getName());
this.running = false;
synchronized (this)
{
this.notifyAll();
}
}
else
{
throw new IllegalThreadStateExce... | [
"public",
"synchronized",
"void",
"stopThread",
"(",
")",
"{",
"if",
"(",
"isRunning",
"(",
")",
")",
"{",
"if",
"(",
"log",
".",
"isInfoEnabled",
"(",
")",
")",
"log",
".",
"info",
"(",
"\"[Daemon] {stopThread} Requesting termination of thread \"",
"+",
"this... | Requests the daemon terminate by setting a flag and sending an interrupt to the thread | [
"Requests",
"the",
"daemon",
"terminate",
"by",
"setting",
"a",
"flag",
"and",
"sending",
"an",
"interrupt",
"to",
"the",
"thread"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/threading/Daemon.java#L126-L144 | train |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/logging/appender/ServiceManagerLogForwardDaemon.java | ServiceManagerLogForwardDaemon.guiceSetupComplete | @Inject
public void guiceSetupComplete()
{
// Force us to re-register with guice-supplied values
this.registered = false;
// Normally guice would call this but we must call it manually because the object was created manually
postConstruct();
if (onGuiceTakeover != null)
{
onGuiceTakeover.run();
o... | java | @Inject
public void guiceSetupComplete()
{
// Force us to re-register with guice-supplied values
this.registered = false;
// Normally guice would call this but we must call it manually because the object was created manually
postConstruct();
if (onGuiceTakeover != null)
{
onGuiceTakeover.run();
o... | [
"@",
"Inject",
"public",
"void",
"guiceSetupComplete",
"(",
")",
"{",
"// Force us to re-register with guice-supplied values",
"this",
".",
"registered",
"=",
"false",
";",
"// Normally guice would call this but we must call it manually because the object was created manually",
"post... | Called when Guice takes over this Daemon, notifies the original constructor that the temporary services are no longer
required | [
"Called",
"when",
"Guice",
"takes",
"over",
"this",
"Daemon",
"notifies",
"the",
"original",
"constructor",
"that",
"the",
"temporary",
"services",
"are",
"no",
"longer",
"required"
] | d4025d2f881bc0542b1e004c5f65a1ccaf895836 | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/logging/appender/ServiceManagerLogForwardDaemon.java#L107-L122 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.