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
brianwhu/xillium
gear/src/main/java/org/xillium/gear/auth/DatabaseBackedAuthority.java
DatabaseBackedAuthority.loadRolesAndPermissions
@Transactional(readOnly=true) public List<Permission> loadRolesAndPermissions() throws Exception { return _persistence.getResults(_qRoleAuthorizations, null); }
java
@Transactional(readOnly=true) public List<Permission> loadRolesAndPermissions() throws Exception { return _persistence.getResults(_qRoleAuthorizations, null); }
[ "@", "Transactional", "(", "readOnly", "=", "true", ")", "public", "List", "<", "Permission", ">", "loadRolesAndPermissions", "(", ")", "throws", "Exception", "{", "return", "_persistence", ".", "getResults", "(", "_qRoleAuthorizations", ",", "null", ")", ";", ...
Loads all role permissions into memory.
[ "Loads", "all", "role", "permissions", "into", "memory", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/gear/src/main/java/org/xillium/gear/auth/DatabaseBackedAuthority.java#L36-L39
train
mcpat/microjiac-public
tools/microjiac-config/src/main/java/de/jiac/micro/config/generator/ConfigurationGenerator.java
ConfigurationGenerator.execute
public static AbstractConfiguration[] execute(String applicationNamespace, ClassLoader loader, Logger log) throws Exception { String packageName= "de.jiac.micro.internal.latebind"; MicroJIACToolContext context= new MicroJIACToolContext(loader); ConfigurationGenerator generator= new ConfigurationGenerator(context.getLoader(), log); MergedConfiguration conf= context.createResolver().resolveAndMerge(applicationNamespace); CheckerResult checkerResult= context.createChecker().flattenAndCheck(conf); // first print the warnings for(String warning : checkerResult.warnings) { log.warn(warning); } // print errors for(String error : checkerResult.errors) { log.error(error); } if(checkerResult.hasErrors()) { throw new GeneratorException("checker has found errors"); } return generator.generate(packageName, conf); }
java
public static AbstractConfiguration[] execute(String applicationNamespace, ClassLoader loader, Logger log) throws Exception { String packageName= "de.jiac.micro.internal.latebind"; MicroJIACToolContext context= new MicroJIACToolContext(loader); ConfigurationGenerator generator= new ConfigurationGenerator(context.getLoader(), log); MergedConfiguration conf= context.createResolver().resolveAndMerge(applicationNamespace); CheckerResult checkerResult= context.createChecker().flattenAndCheck(conf); // first print the warnings for(String warning : checkerResult.warnings) { log.warn(warning); } // print errors for(String error : checkerResult.errors) { log.error(error); } if(checkerResult.hasErrors()) { throw new GeneratorException("checker has found errors"); } return generator.generate(packageName, conf); }
[ "public", "static", "AbstractConfiguration", "[", "]", "execute", "(", "String", "applicationNamespace", ",", "ClassLoader", "loader", ",", "Logger", "log", ")", "throws", "Exception", "{", "String", "packageName", "=", "\"de.jiac.micro.internal.latebind\"", ";", "Mic...
Return the array of generated node configurations. @param applicationNamespace the namespace where the application definition is located @param loader the classloader which has access to all required resources and classes @param log the log that outputs the plugin informations @return full-qualified class names of all generated node configurations @throws Exception if an error occures during execution
[ "Return", "the", "array", "of", "generated", "node", "configurations", "." ]
3c649e44846981a68e84cc4578719532414d8d35
https://github.com/mcpat/microjiac-public/blob/3c649e44846981a68e84cc4578719532414d8d35/tools/microjiac-config/src/main/java/de/jiac/micro/config/generator/ConfigurationGenerator.java#L517-L540
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java
ProfilePackageIndexFrameWriter.generate
public static void generate(ConfigurationImpl configuration, String profileName) { ProfilePackageIndexFrameWriter profpackgen; DocPath filename = DocPaths.profileFrame(profileName); try { profpackgen = new ProfilePackageIndexFrameWriter(configuration, filename); profpackgen.buildProfilePackagesIndexFile("doclet.Window_Overview", false, profileName); profpackgen.close(); } catch (IOException exc) { configuration.standardmessage.error( "doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } }
java
public static void generate(ConfigurationImpl configuration, String profileName) { ProfilePackageIndexFrameWriter profpackgen; DocPath filename = DocPaths.profileFrame(profileName); try { profpackgen = new ProfilePackageIndexFrameWriter(configuration, filename); profpackgen.buildProfilePackagesIndexFile("doclet.Window_Overview", false, profileName); profpackgen.close(); } catch (IOException exc) { configuration.standardmessage.error( "doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } }
[ "public", "static", "void", "generate", "(", "ConfigurationImpl", "configuration", ",", "String", "profileName", ")", "{", "ProfilePackageIndexFrameWriter", "profpackgen", ";", "DocPath", "filename", "=", "DocPaths", ".", "profileFrame", "(", "profileName", ")", ";", ...
Generate the profile package index file. @throws DocletAbortException @param configuration the configuration object @param profileName the name of the profile being documented
[ "Generate", "the", "profile", "package", "index", "file", "." ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java#L67-L80
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/javadoc/TypeMaker.java
TypeMaker.getTypeString
static String getTypeString(DocEnv env, Type t, boolean full) { // TODO: should annotations be included here? if (t.isAnnotated()) { t = t.unannotatedType(); } switch (t.getTag()) { case ARRAY: StringBuilder s = new StringBuilder(); while (t.hasTag(ARRAY)) { s.append("[]"); t = env.types.elemtype(t); } s.insert(0, getTypeString(env, t, full)); return s.toString(); case CLASS: return ParameterizedTypeImpl. parameterizedTypeToString(env, (ClassType)t, full); case WILDCARD: Type.WildcardType a = (Type.WildcardType)t; return WildcardTypeImpl.wildcardTypeToString(env, a, full); default: return t.tsym.getQualifiedName().toString(); } }
java
static String getTypeString(DocEnv env, Type t, boolean full) { // TODO: should annotations be included here? if (t.isAnnotated()) { t = t.unannotatedType(); } switch (t.getTag()) { case ARRAY: StringBuilder s = new StringBuilder(); while (t.hasTag(ARRAY)) { s.append("[]"); t = env.types.elemtype(t); } s.insert(0, getTypeString(env, t, full)); return s.toString(); case CLASS: return ParameterizedTypeImpl. parameterizedTypeToString(env, (ClassType)t, full); case WILDCARD: Type.WildcardType a = (Type.WildcardType)t; return WildcardTypeImpl.wildcardTypeToString(env, a, full); default: return t.tsym.getQualifiedName().toString(); } }
[ "static", "String", "getTypeString", "(", "DocEnv", "env", ",", "Type", "t", ",", "boolean", "full", ")", "{", "// TODO: should annotations be included here?", "if", "(", "t", ".", "isAnnotated", "(", ")", ")", "{", "t", "=", "t", ".", "unannotatedType", "("...
Return the string representation of a type use. Bounds of type variables are not included; bounds of wildcard types are. Class names are qualified if "full" is true.
[ "Return", "the", "string", "representation", "of", "a", "type", "use", ".", "Bounds", "of", "type", "variables", "are", "not", "included", ";", "bounds", "of", "wildcard", "types", "are", ".", "Class", "names", "are", "qualified", "if", "full", "is", "true...
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javadoc/TypeMaker.java#L155-L178
train
defei/codelogger-utils
src/main/java/org/codelogger/utils/PathUtils.java
PathUtils.getWebProjectPath
public static String getWebProjectPath(Object currentObject) { Class<? extends Object> class1 = currentObject.getClass(); ClassLoader classLoader = class1.getClassLoader(); URL resource = classLoader.getResource("/"); String path = resource.getPath(); int webRootIndex = StringUtils.indexOfIgnoreCase(path, "WEB-INF"); if (path.indexOf(":/") > 0) { return path.substring(1, webRootIndex); } else { return path.substring(0, webRootIndex); } }
java
public static String getWebProjectPath(Object currentObject) { Class<? extends Object> class1 = currentObject.getClass(); ClassLoader classLoader = class1.getClassLoader(); URL resource = classLoader.getResource("/"); String path = resource.getPath(); int webRootIndex = StringUtils.indexOfIgnoreCase(path, "WEB-INF"); if (path.indexOf(":/") > 0) { return path.substring(1, webRootIndex); } else { return path.substring(0, webRootIndex); } }
[ "public", "static", "String", "getWebProjectPath", "(", "Object", "currentObject", ")", "{", "Class", "<", "?", "extends", "Object", ">", "class1", "=", "currentObject", ".", "getClass", "(", ")", ";", "ClassLoader", "classLoader", "=", "class1", ".", "getClas...
The parameter currentObject recommend to user 'this', because of can not be a object which build by manually with 'new'; @param currentObject @return web project physical path.
[ "The", "parameter", "currentObject", "recommend", "to", "user", "this", "because", "of", "can", "not", "be", "a", "object", "which", "build", "by", "manually", "with", "new", ";" ]
d906f5d217b783c7ae3e53442cd6fb87b20ecc0a
https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/PathUtils.java#L14-L26
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/sjavac/BuildState.java
BuildState.flattenPackagesSourcesAndArtifacts
public void flattenPackagesSourcesAndArtifacts(Map<String,Module> m) { modules = m; // Extract all the found packages. for (Module i : modules.values()) { for (Map.Entry<String,Package> j : i.packages().entrySet()) { Package p = packages.get(j.getKey()); // Check that no two different packages are stored under same name. assert(p == null || p == j.getValue()); if (p == null) { p = j.getValue(); packages.put(j.getKey(),j.getValue()); } for (Map.Entry<String,Source> k : p.sources().entrySet()) { Source s = sources.get(k.getKey()); // Check that no two different sources are stored under same name. assert(s == null || s == k.getValue()); if (s == null) { s = k.getValue(); sources.put(k.getKey(), k.getValue()); } } for (Map.Entry<String,File> g : p.artifacts().entrySet()) { File f = artifacts.get(g.getKey()); // Check that no two artifacts are stored under the same file. assert(f == null || f == g.getValue()); if (f == null) { f = g.getValue(); artifacts.put(g.getKey(), g.getValue()); } } } } }
java
public void flattenPackagesSourcesAndArtifacts(Map<String,Module> m) { modules = m; // Extract all the found packages. for (Module i : modules.values()) { for (Map.Entry<String,Package> j : i.packages().entrySet()) { Package p = packages.get(j.getKey()); // Check that no two different packages are stored under same name. assert(p == null || p == j.getValue()); if (p == null) { p = j.getValue(); packages.put(j.getKey(),j.getValue()); } for (Map.Entry<String,Source> k : p.sources().entrySet()) { Source s = sources.get(k.getKey()); // Check that no two different sources are stored under same name. assert(s == null || s == k.getValue()); if (s == null) { s = k.getValue(); sources.put(k.getKey(), k.getValue()); } } for (Map.Entry<String,File> g : p.artifacts().entrySet()) { File f = artifacts.get(g.getKey()); // Check that no two artifacts are stored under the same file. assert(f == null || f == g.getValue()); if (f == null) { f = g.getValue(); artifacts.put(g.getKey(), g.getValue()); } } } } }
[ "public", "void", "flattenPackagesSourcesAndArtifacts", "(", "Map", "<", "String", ",", "Module", ">", "m", ")", "{", "modules", "=", "m", ";", "// Extract all the found packages.", "for", "(", "Module", "i", ":", "modules", ".", "values", "(", ")", ")", "{"...
Store references to all packages, sources and artifacts for all modules into the build state. I.e. flatten the module tree structure into global maps stored in the BuildState for easy access. @param m The set of modules.
[ "Store", "references", "to", "all", "packages", "sources", "and", "artifacts", "for", "all", "modules", "into", "the", "build", "state", ".", "I", ".", "e", ".", "flatten", "the", "module", "tree", "structure", "into", "global", "maps", "stored", "in", "th...
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/BuildState.java#L90-L122
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/sjavac/BuildState.java
BuildState.checkInternalState
public void checkInternalState(String msg, boolean linkedOnly, Map<String,Source> srcs) { boolean baad = false; Map<String,Source> original = new HashMap<String,Source>(); Map<String,Source> calculated = new HashMap<String,Source>(); for (String s : sources.keySet()) { Source ss = sources.get(s); if (ss.isLinkedOnly() == linkedOnly) { calculated.put(s,ss); } } for (String s : srcs.keySet()) { Source ss = srcs.get(s); if (ss.isLinkedOnly() == linkedOnly) { original.put(s,ss); } } if (original.size() != calculated.size()) { Log.error("INTERNAL ERROR "+msg+" original and calculated are not the same size!"); baad = true; } if (!original.keySet().equals(calculated.keySet())) { Log.error("INTERNAL ERROR "+msg+" original and calculated do not have the same domain!"); baad = true; } if (!baad) { for (String s : original.keySet()) { Source s1 = original.get(s); Source s2 = calculated.get(s); if (s1 == null || s2 == null || !s1.equals(s2)) { Log.error("INTERNAL ERROR "+msg+" original and calculated have differing elements for "+s); } baad = true; } } if (baad) { for (String s : original.keySet()) { Source ss = original.get(s); Source sss = calculated.get(s); if (sss == null) { Log.error("The file "+s+" does not exist in calculated tree of sources."); } } for (String s : calculated.keySet()) { Source ss = calculated.get(s); Source sss = original.get(s); if (sss == null) { Log.error("The file "+s+" does not exist in original set of found sources."); } } } }
java
public void checkInternalState(String msg, boolean linkedOnly, Map<String,Source> srcs) { boolean baad = false; Map<String,Source> original = new HashMap<String,Source>(); Map<String,Source> calculated = new HashMap<String,Source>(); for (String s : sources.keySet()) { Source ss = sources.get(s); if (ss.isLinkedOnly() == linkedOnly) { calculated.put(s,ss); } } for (String s : srcs.keySet()) { Source ss = srcs.get(s); if (ss.isLinkedOnly() == linkedOnly) { original.put(s,ss); } } if (original.size() != calculated.size()) { Log.error("INTERNAL ERROR "+msg+" original and calculated are not the same size!"); baad = true; } if (!original.keySet().equals(calculated.keySet())) { Log.error("INTERNAL ERROR "+msg+" original and calculated do not have the same domain!"); baad = true; } if (!baad) { for (String s : original.keySet()) { Source s1 = original.get(s); Source s2 = calculated.get(s); if (s1 == null || s2 == null || !s1.equals(s2)) { Log.error("INTERNAL ERROR "+msg+" original and calculated have differing elements for "+s); } baad = true; } } if (baad) { for (String s : original.keySet()) { Source ss = original.get(s); Source sss = calculated.get(s); if (sss == null) { Log.error("The file "+s+" does not exist in calculated tree of sources."); } } for (String s : calculated.keySet()) { Source ss = calculated.get(s); Source sss = original.get(s); if (sss == null) { Log.error("The file "+s+" does not exist in original set of found sources."); } } } }
[ "public", "void", "checkInternalState", "(", "String", "msg", ",", "boolean", "linkedOnly", ",", "Map", "<", "String", ",", "Source", ">", "srcs", ")", "{", "boolean", "baad", "=", "false", ";", "Map", "<", "String", ",", "Source", ">", "original", "=", ...
Verify that the setModules method above did the right thing when running through the module->package->source structure.
[ "Verify", "that", "the", "setModules", "method", "above", "did", "the", "right", "thing", "when", "running", "through", "the", "module", "-", ">", "package", "-", ">", "source", "structure", "." ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/BuildState.java#L182-L233
train
jbundle/osgi
obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java
ObrClassFinderService.getRepositoryAdmin
public RepositoryAdmin getRepositoryAdmin(BundleContext context, ObrClassFinderService autoStartNotify) throws InvalidSyntaxException { RepositoryAdmin admin = null; ServiceReference[] ref = context.getServiceReferences(RepositoryAdmin.class.getName(), null); if ((ref != null) && (ref.length > 0)) admin = (RepositoryAdmin) context.getService(ref[0]); if (admin == null) if (autoStartNotify != null) if (waitingForRepositoryAdmin == false) { // Wait until the repository service is up until I start servicing clients context.addServiceListener(new RepositoryAdminServiceListener(autoStartNotify, context), "(" + Constants.OBJECTCLASS + "=" + RepositoryAdmin.class.getName() + ")"); waitingForRepositoryAdmin = true; } return admin; }
java
public RepositoryAdmin getRepositoryAdmin(BundleContext context, ObrClassFinderService autoStartNotify) throws InvalidSyntaxException { RepositoryAdmin admin = null; ServiceReference[] ref = context.getServiceReferences(RepositoryAdmin.class.getName(), null); if ((ref != null) && (ref.length > 0)) admin = (RepositoryAdmin) context.getService(ref[0]); if (admin == null) if (autoStartNotify != null) if (waitingForRepositoryAdmin == false) { // Wait until the repository service is up until I start servicing clients context.addServiceListener(new RepositoryAdminServiceListener(autoStartNotify, context), "(" + Constants.OBJECTCLASS + "=" + RepositoryAdmin.class.getName() + ")"); waitingForRepositoryAdmin = true; } return admin; }
[ "public", "RepositoryAdmin", "getRepositoryAdmin", "(", "BundleContext", "context", ",", "ObrClassFinderService", "autoStartNotify", ")", "throws", "InvalidSyntaxException", "{", "RepositoryAdmin", "admin", "=", "null", ";", "ServiceReference", "[", "]", "ref", "=", "co...
Get the repository admin service. @param context @return @throws InvalidSyntaxException
[ "Get", "the", "repository", "admin", "service", "." ]
beb02aef78736a4f799aaac001c8f0327bf0536c
https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java#L70-L88
train
jbundle/osgi
obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java
ObrClassFinderService.addBootstrapRepository
public void addBootstrapRepository(RepositoryAdmin repositoryAdmin, BundleContext context) { if (repositoryAdmin == null) return; String repository = context.getProperty("jbundle.repository.url"); if (repository != null) if (repository.length() > 0) this.addRepository(repositoryAdmin, repository); //repository = "file:" + System.getProperty("user.home") + File.separator + ".m2" + File.separator + "full-repository.xml"; //this.addRepository(repositoryAdmin, repository); }
java
public void addBootstrapRepository(RepositoryAdmin repositoryAdmin, BundleContext context) { if (repositoryAdmin == null) return; String repository = context.getProperty("jbundle.repository.url"); if (repository != null) if (repository.length() > 0) this.addRepository(repositoryAdmin, repository); //repository = "file:" + System.getProperty("user.home") + File.separator + ".m2" + File.separator + "full-repository.xml"; //this.addRepository(repositoryAdmin, repository); }
[ "public", "void", "addBootstrapRepository", "(", "RepositoryAdmin", "repositoryAdmin", ",", "BundleContext", "context", ")", "{", "if", "(", "repositoryAdmin", "==", "null", ")", "return", ";", "String", "repository", "=", "context", ".", "getProperty", "(", "\"jb...
Add the standard obr repository, so I can get the bundles that I need. @param repositoryAdmin @param context
[ "Add", "the", "standard", "obr", "repository", "so", "I", "can", "get", "the", "bundles", "that", "I", "need", "." ]
beb02aef78736a4f799aaac001c8f0327bf0536c
https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java#L94-L105
train
jbundle/osgi
obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java
ObrClassFinderService.addRepository
public void addRepository(RepositoryAdmin repositoryAdmin, String repository) { try { if (repository != null) { boolean duplicate = false; for (Repository repo : repositoryAdmin.listRepositories()) { if (repository.equalsIgnoreCase(repo.getURI())) duplicate = true; } if (!duplicate) { Repository repo = repositoryAdmin.addRepository(repository); if (repo == null) repositoryAdmin.removeRepository(repository); // Ignore repos not found } } } catch (Exception e) { // Ignore exception e.printStackTrace(); } }
java
public void addRepository(RepositoryAdmin repositoryAdmin, String repository) { try { if (repository != null) { boolean duplicate = false; for (Repository repo : repositoryAdmin.listRepositories()) { if (repository.equalsIgnoreCase(repo.getURI())) duplicate = true; } if (!duplicate) { Repository repo = repositoryAdmin.addRepository(repository); if (repo == null) repositoryAdmin.removeRepository(repository); // Ignore repos not found } } } catch (Exception e) { // Ignore exception e.printStackTrace(); } }
[ "public", "void", "addRepository", "(", "RepositoryAdmin", "repositoryAdmin", ",", "String", "repository", ")", "{", "try", "{", "if", "(", "repository", "!=", "null", ")", "{", "boolean", "duplicate", "=", "false", ";", "for", "(", "Repository", "repo", ":"...
Add this repository to my available repositories. @param repositoryAdmin @param repository
[ "Add", "this", "repository", "to", "my", "available", "repositories", "." ]
beb02aef78736a4f799aaac001c8f0327bf0536c
https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java#L111-L132
train
jbundle/osgi
obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java
ObrClassFinderService.startClassFinderActivator
public boolean startClassFinderActivator(BundleContext context) { if (ClassFinderActivator.getClassFinder(context, 0) == this) return true; // Already up! // If the repository is not up, but the bundle is deployed, this will find it String packageName = ClassFinderActivator.getPackageName(ClassFinderActivator.class.getName(), false); Bundle bundle = this.findBundle(null, context, packageName, null); if (bundle == null) { Resource resource = (Resource)this.deployThisResource(packageName, null, false); // Get the bundle info from the repos bundle = this.findBundle(resource, context, packageName, null); } if (bundle != null) { if (((bundle.getState() & Bundle.ACTIVE) == 0) && ((bundle.getState() & Bundle.STARTING) == 0)) { try { bundle.start(); } catch (BundleException e) { e.printStackTrace(); } } ClassFinderActivator.setClassFinder(this); return true; // Success } return false; // Error! Where is my bundle? }
java
public boolean startClassFinderActivator(BundleContext context) { if (ClassFinderActivator.getClassFinder(context, 0) == this) return true; // Already up! // If the repository is not up, but the bundle is deployed, this will find it String packageName = ClassFinderActivator.getPackageName(ClassFinderActivator.class.getName(), false); Bundle bundle = this.findBundle(null, context, packageName, null); if (bundle == null) { Resource resource = (Resource)this.deployThisResource(packageName, null, false); // Get the bundle info from the repos bundle = this.findBundle(resource, context, packageName, null); } if (bundle != null) { if (((bundle.getState() & Bundle.ACTIVE) == 0) && ((bundle.getState() & Bundle.STARTING) == 0)) { try { bundle.start(); } catch (BundleException e) { e.printStackTrace(); } } ClassFinderActivator.setClassFinder(this); return true; // Success } return false; // Error! Where is my bundle? }
[ "public", "boolean", "startClassFinderActivator", "(", "BundleContext", "context", ")", "{", "if", "(", "ClassFinderActivator", ".", "getClassFinder", "(", "context", ",", "0", ")", "==", "this", ")", "return", "true", ";", "// Already up!", "// If the repository is...
Convenience method to start the class finder utility service. If admin service is not up yet, this starts it. @param className @return true If I'm up already @return false If I had a problem.
[ "Convenience", "method", "to", "start", "the", "class", "finder", "utility", "service", ".", "If", "admin", "service", "is", "not", "up", "yet", "this", "starts", "it", "." ]
beb02aef78736a4f799aaac001c8f0327bf0536c
https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java#L167-L195
train
jbundle/osgi
obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java
ObrClassFinderService.deployThisResource
public Object deployThisResource(String packageName, String versionRange, boolean start) { int options = 0; //?if (start) //? options = Resolver.START; if (repositoryAdmin == null) return null; DataModelHelper helper = repositoryAdmin.getHelper(); if (this.getResourceFromCache(packageName) != null) return this.getResourceFromCache(packageName); String filter = "(package=" + packageName + ")"; filter = ClassFinderActivator.addVersionFilter(filter, versionRange); Requirement requirement = helper.requirement("package", filter); Requirement[] requirements = { requirement };// repositoryAdmin Resource[] resources = repositoryAdmin.discoverResources(requirements); Resource bestResource = null; if (resources != null) { Version bestVersion = null; for (Resource resource : resources) { Version resourceVersion = resource.getVersion(); if (!isValidVersion(resourceVersion, versionRange)) continue; if ((bestVersion == null) || (resourceVersion.compareTo(bestVersion) >= 0)) { bestVersion = resourceVersion; // Use the highest version number bestResource = resource; } } } if (bestResource != null) { this.deployResource(bestResource, options); Bundle bundle = this.findBundle(bestResource, bundleContext, packageName, versionRange); if (start) this.startBundle(bundle); this.addResourceToCache(packageName, bestResource); } return bestResource; }
java
public Object deployThisResource(String packageName, String versionRange, boolean start) { int options = 0; //?if (start) //? options = Resolver.START; if (repositoryAdmin == null) return null; DataModelHelper helper = repositoryAdmin.getHelper(); if (this.getResourceFromCache(packageName) != null) return this.getResourceFromCache(packageName); String filter = "(package=" + packageName + ")"; filter = ClassFinderActivator.addVersionFilter(filter, versionRange); Requirement requirement = helper.requirement("package", filter); Requirement[] requirements = { requirement };// repositoryAdmin Resource[] resources = repositoryAdmin.discoverResources(requirements); Resource bestResource = null; if (resources != null) { Version bestVersion = null; for (Resource resource : resources) { Version resourceVersion = resource.getVersion(); if (!isValidVersion(resourceVersion, versionRange)) continue; if ((bestVersion == null) || (resourceVersion.compareTo(bestVersion) >= 0)) { bestVersion = resourceVersion; // Use the highest version number bestResource = resource; } } } if (bestResource != null) { this.deployResource(bestResource, options); Bundle bundle = this.findBundle(bestResource, bundleContext, packageName, versionRange); if (start) this.startBundle(bundle); this.addResourceToCache(packageName, bestResource); } return bestResource; }
[ "public", "Object", "deployThisResource", "(", "String", "packageName", ",", "String", "versionRange", ",", "boolean", "start", ")", "{", "int", "options", "=", "0", ";", "//?if (start)", "//?\toptions = Resolver.START;", "if", "(", "repositoryAdmin", "==", "null", ...
Find this resource in the repository, then deploy and optionally start it. @param className @param options @return
[ "Find", "this", "resource", "in", "the", "repository", "then", "deploy", "and", "optionally", "start", "it", "." ]
beb02aef78736a4f799aaac001c8f0327bf0536c
https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java#L202-L242
train
jbundle/osgi
obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java
ObrClassFinderService.deployResources
public void deployResources(Resource[] resources, int options) { if (resources != null) { for (Resource resource : resources) { this.deployResource(resource, options); } } }
java
public void deployResources(Resource[] resources, int options) { if (resources != null) { for (Resource resource : resources) { this.deployResource(resource, options); } } }
[ "public", "void", "deployResources", "(", "Resource", "[", "]", "resources", ",", "int", "options", ")", "{", "if", "(", "resources", "!=", "null", ")", "{", "for", "(", "Resource", "resource", ":", "resources", ")", "{", "this", ".", "deployResource", "...
Deploy this list of resources. @param resources @param options
[ "Deploy", "this", "list", "of", "resources", "." ]
beb02aef78736a4f799aaac001c8f0327bf0536c
https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java#L248-L257
train
jbundle/osgi
obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java
ObrClassFinderService.deployResource
public void deployResource(Resource resource, int options) { String name = resource.getSymbolicName() + "/" + resource.getVersion(); Lock lock = this.getLock(name); try { boolean acquired = lock.tryLock(); if (acquired) { // Good, deploy this resource try { Resolver resolver = repositoryAdmin.resolver(); resolver.add(resource); int resolveAttempt = 5; while (resolveAttempt-- > 0) { try { if (resolver.resolve(options)) { resolver.deploy(options); break; // Resolve successful, exception thrown on previous instruction if not } else { Reason[] reqs = resolver.getUnsatisfiedRequirements(); for (int i = 0; i < reqs.length; i++) { ClassServiceUtility.log(bundleContext, LogService.LOG_ERROR, "Unable to resolve: " + reqs[i]); } break; // Resolve unsuccessful, but it did finish } } catch (IllegalStateException e) { // If resolve unsuccessful, try again if (resolveAttempt == 0) e.printStackTrace(); } } } finally { lock.unlock(); } } else { // Lock was not acquired, wait until it is unlocked and return (resource should be deployed by then) acquired = lock.tryLock(secondsToWait, TimeUnit.SECONDS); if (acquired) { try { // Success } finally { lock.unlock(); } } else { // failure code here } } } catch (InterruptedException e) { e.printStackTrace(); } finally { this.removeLock(name); } }
java
public void deployResource(Resource resource, int options) { String name = resource.getSymbolicName() + "/" + resource.getVersion(); Lock lock = this.getLock(name); try { boolean acquired = lock.tryLock(); if (acquired) { // Good, deploy this resource try { Resolver resolver = repositoryAdmin.resolver(); resolver.add(resource); int resolveAttempt = 5; while (resolveAttempt-- > 0) { try { if (resolver.resolve(options)) { resolver.deploy(options); break; // Resolve successful, exception thrown on previous instruction if not } else { Reason[] reqs = resolver.getUnsatisfiedRequirements(); for (int i = 0; i < reqs.length; i++) { ClassServiceUtility.log(bundleContext, LogService.LOG_ERROR, "Unable to resolve: " + reqs[i]); } break; // Resolve unsuccessful, but it did finish } } catch (IllegalStateException e) { // If resolve unsuccessful, try again if (resolveAttempt == 0) e.printStackTrace(); } } } finally { lock.unlock(); } } else { // Lock was not acquired, wait until it is unlocked and return (resource should be deployed by then) acquired = lock.tryLock(secondsToWait, TimeUnit.SECONDS); if (acquired) { try { // Success } finally { lock.unlock(); } } else { // failure code here } } } catch (InterruptedException e) { e.printStackTrace(); } finally { this.removeLock(name); } }
[ "public", "void", "deployResource", "(", "Resource", "resource", ",", "int", "options", ")", "{", "String", "name", "=", "resource", ".", "getSymbolicName", "(", ")", "+", "\"/\"", "+", "resource", ".", "getVersion", "(", ")", ";", "Lock", "lock", "=", "...
Deploy this resource. @param resource @param options
[ "Deploy", "this", "resource", "." ]
beb02aef78736a4f799aaac001c8f0327bf0536c
https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java#L264-L316
train
jbundle/osgi
obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java
ObrClassFinderService.isResourceBundleMatch
public boolean isResourceBundleMatch(Object objResource, Bundle bundle) { Resource resource = (Resource)objResource; return ((bundle.getSymbolicName().equals(resource.getSymbolicName())) && (isValidVersion(bundle.getVersion(), resource.getVersion().toString()))); }
java
public boolean isResourceBundleMatch(Object objResource, Bundle bundle) { Resource resource = (Resource)objResource; return ((bundle.getSymbolicName().equals(resource.getSymbolicName())) && (isValidVersion(bundle.getVersion(), resource.getVersion().toString()))); }
[ "public", "boolean", "isResourceBundleMatch", "(", "Object", "objResource", ",", "Bundle", "bundle", ")", "{", "Resource", "resource", "=", "(", "Resource", ")", "objResource", ";", "return", "(", "(", "bundle", ".", "getSymbolicName", "(", ")", ".", "equals",...
Does this resource match this bundle? @param resource @param context @return
[ "Does", "this", "resource", "match", "this", "bundle?" ]
beb02aef78736a4f799aaac001c8f0327bf0536c
https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/obr/src/main/java/org/jbundle/util/osgi/obr/ObrClassFinderService.java#L336-L340
train
coopernurse/barrister-java
src/main/java/com/bitmechanic/barrister/HttpTransport.java
HttpTransport.request
@SuppressWarnings("unchecked") public List<RpcResponse> request(List<RpcRequest> reqList) { List<RpcResponse> respList = new ArrayList<RpcResponse>(); List<Map> marshaledReqs = new ArrayList<Map>(); Map<String,RpcRequest> byReqId = new HashMap<String,RpcRequest>(); for (RpcRequest req : reqList) { try { marshaledReqs.add(req.marshal(contract)); byReqId.put(req.getId(), req); } catch (RpcException e) { respList.add(new RpcResponse(req, e)); } } InputStream is = null; try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); serializer.write(marshaledReqs, bos); bos.close(); byte[] data = bos.toByteArray(); is = requestRaw(data); List<Map> responses = serializer.readList(is); for (Map map : responses) { String id = (String)map.get("id"); if (id != null) { RpcRequest req = byReqId.get(id); if (req == null) { // TODO: ?? log error? } else { byReqId.remove(id); respList.add(unmarshal(req, map)); } } else { // TODO: ?? log error? } } if (byReqId.size() > 0) { for (RpcRequest req : byReqId.values()) { String msg = "No response in batch for request " + req.getId(); RpcException exc = RpcException.Error.INVALID_RESP.exc(msg); RpcResponse resp = new RpcResponse(req, exc); respList.add(resp); } } } catch (IOException e) { String msg = "IOException requesting batch " + " from: " + endpoint + " - " + e.getMessage(); RpcException exc = RpcException.Error.INTERNAL.exc(msg); respList.add(new RpcResponse(null, exc)); } finally { closeQuietly(is); } return respList; }
java
@SuppressWarnings("unchecked") public List<RpcResponse> request(List<RpcRequest> reqList) { List<RpcResponse> respList = new ArrayList<RpcResponse>(); List<Map> marshaledReqs = new ArrayList<Map>(); Map<String,RpcRequest> byReqId = new HashMap<String,RpcRequest>(); for (RpcRequest req : reqList) { try { marshaledReqs.add(req.marshal(contract)); byReqId.put(req.getId(), req); } catch (RpcException e) { respList.add(new RpcResponse(req, e)); } } InputStream is = null; try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); serializer.write(marshaledReqs, bos); bos.close(); byte[] data = bos.toByteArray(); is = requestRaw(data); List<Map> responses = serializer.readList(is); for (Map map : responses) { String id = (String)map.get("id"); if (id != null) { RpcRequest req = byReqId.get(id); if (req == null) { // TODO: ?? log error? } else { byReqId.remove(id); respList.add(unmarshal(req, map)); } } else { // TODO: ?? log error? } } if (byReqId.size() > 0) { for (RpcRequest req : byReqId.values()) { String msg = "No response in batch for request " + req.getId(); RpcException exc = RpcException.Error.INVALID_RESP.exc(msg); RpcResponse resp = new RpcResponse(req, exc); respList.add(resp); } } } catch (IOException e) { String msg = "IOException requesting batch " + " from: " + endpoint + " - " + e.getMessage(); RpcException exc = RpcException.Error.INTERNAL.exc(msg); respList.add(new RpcResponse(null, exc)); } finally { closeQuietly(is); } return respList; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "List", "<", "RpcResponse", ">", "request", "(", "List", "<", "RpcRequest", ">", "reqList", ")", "{", "List", "<", "RpcResponse", ">", "respList", "=", "new", "ArrayList", "<", "RpcResponse", ">",...
Makes JSON-RPC batch request against the remote server as a single HTTP request.
[ "Makes", "JSON", "-", "RPC", "batch", "request", "against", "the", "remote", "server", "as", "a", "single", "HTTP", "request", "." ]
c2b639634c88a25002b66d1fb4a8f5fb51ade6a2
https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/HttpTransport.java#L175-L237
train
coopernurse/barrister-java
src/main/java/com/bitmechanic/barrister/HttpTransport.java
HttpTransport.createURLConnection
public URLConnection createURLConnection(URL url) throws IOException { URLConnection conn = url.openConnection(); return conn; }
java
public URLConnection createURLConnection(URL url) throws IOException { URLConnection conn = url.openConnection(); return conn; }
[ "public", "URLConnection", "createURLConnection", "(", "URL", "url", ")", "throws", "IOException", "{", "URLConnection", "conn", "=", "url", ".", "openConnection", "(", ")", ";", "return", "conn", ";", "}" ]
Returns an URLConnection for the given URL. Subclasses may override this and customize the connection with custom timeouts, headers, etc. Headers passed into the constructor, and the Content-Length header, will be added after this method is called.
[ "Returns", "an", "URLConnection", "for", "the", "given", "URL", ".", "Subclasses", "may", "override", "this", "and", "customize", "the", "connection", "with", "custom", "timeouts", "headers", "etc", "." ]
c2b639634c88a25002b66d1fb4a8f5fb51ade6a2
https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/HttpTransport.java#L247-L250
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
MethodWriterImpl.getSignature
public Content getSignature(MethodDoc method) { Content pre = new HtmlTree(HtmlTag.PRE); writer.addAnnotationInfo(method, pre); addModifiers(method, pre); addTypeParameters(method, pre); addReturnType(method, pre); if (configuration.linksource) { Content methodName = new StringContent(method.name()); writer.addSrcLink(method, methodName, pre); } else { addName(method.name(), pre); } int indent = pre.charCount(); addParameters(method, pre, indent); addExceptions(method, pre, indent); return pre; }
java
public Content getSignature(MethodDoc method) { Content pre = new HtmlTree(HtmlTag.PRE); writer.addAnnotationInfo(method, pre); addModifiers(method, pre); addTypeParameters(method, pre); addReturnType(method, pre); if (configuration.linksource) { Content methodName = new StringContent(method.name()); writer.addSrcLink(method, methodName, pre); } else { addName(method.name(), pre); } int indent = pre.charCount(); addParameters(method, pre, indent); addExceptions(method, pre, indent); return pre; }
[ "public", "Content", "getSignature", "(", "MethodDoc", "method", ")", "{", "Content", "pre", "=", "new", "HtmlTree", "(", "HtmlTag", ".", "PRE", ")", ";", "writer", ".", "addAnnotationInfo", "(", "method", ",", "pre", ")", ";", "addModifiers", "(", "method...
Get the signature for the given method. @param method the method being documented. @return a content object for the signature
[ "Get", "the", "signature", "for", "the", "given", "method", "." ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java#L121-L137
train
Wadpam/guja
guja-core/src/main/java/com/wadpam/guja/oauth2/provider/TemporaryTokenCache.java
TemporaryTokenCache.generateTemporaryToken
public String generateTemporaryToken(String key, int secondsToLive, Object context) { checkNotNull(key); String token = tokenGenerator.generate(); tokenCache.put(key, Triplet.of(token, DateTime.now().plusSeconds(secondsToLive).getMillis(), context)); return token; }
java
public String generateTemporaryToken(String key, int secondsToLive, Object context) { checkNotNull(key); String token = tokenGenerator.generate(); tokenCache.put(key, Triplet.of(token, DateTime.now().plusSeconds(secondsToLive).getMillis(), context)); return token; }
[ "public", "String", "generateTemporaryToken", "(", "String", "key", ",", "int", "secondsToLive", ",", "Object", "context", ")", "{", "checkNotNull", "(", "key", ")", ";", "String", "token", "=", "tokenGenerator", ".", "generate", "(", ")", ";", "tokenCache", ...
Same as above but will also store a context that can be retried later.
[ "Same", "as", "above", "but", "will", "also", "store", "a", "context", "that", "can", "be", "retried", "later", "." ]
eb8ba8e6794a96ea0dd9744cada4f9ad9618f114
https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/provider/TemporaryTokenCache.java#L54-L59
train
Wadpam/guja
guja-core/src/main/java/com/wadpam/guja/oauth2/provider/TemporaryTokenCache.java
TemporaryTokenCache.getContextForToken
public Optional<Object> getContextForToken(String key, String token) { Object context = validateTokenAndGetContext(key, token).second(); return null != context ? Optional.of(context) : Optional.absent(); }
java
public Optional<Object> getContextForToken(String key, String token) { Object context = validateTokenAndGetContext(key, token).second(); return null != context ? Optional.of(context) : Optional.absent(); }
[ "public", "Optional", "<", "Object", ">", "getContextForToken", "(", "String", "key", ",", "String", "token", ")", "{", "Object", "context", "=", "validateTokenAndGetContext", "(", "key", ",", "token", ")", ".", "second", "(", ")", ";", "return", "null", "...
Validate a short lived token and returning the associated context The token is removed if found and valid. @param key cacheKey @param token temporary token to validate @return an optional. The context will be absent if either the token is invalid of the context is null.
[ "Validate", "a", "short", "lived", "token", "and", "returning", "the", "associated", "context", "The", "token", "is", "removed", "if", "found", "and", "valid", "." ]
eb8ba8e6794a96ea0dd9744cada4f9ad9618f114
https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/provider/TemporaryTokenCache.java#L96-L99
train
yerenkow/javaz
cache/src/main/java/org/javaz/cache/CacheImpl.java
CacheImpl.put
public Object put(Object key, Object value) { long objectStamp = System.currentTimeMillis(); synchronized (objects) { objectTimeStamps.put(key, objectStamp); if (nextTimeSomeExpired == NO_OBJECTS) { nextTimeSomeExpired = objectStamp; } return objects.put(key, value); } }
java
public Object put(Object key, Object value) { long objectStamp = System.currentTimeMillis(); synchronized (objects) { objectTimeStamps.put(key, objectStamp); if (nextTimeSomeExpired == NO_OBJECTS) { nextTimeSomeExpired = objectStamp; } return objects.put(key, value); } }
[ "public", "Object", "put", "(", "Object", "key", ",", "Object", "value", ")", "{", "long", "objectStamp", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "synchronized", "(", "objects", ")", "{", "objectTimeStamps", ".", "put", "(", "key", ",", "...
Method to store value in cache, if this value first in cache - also mark nextTimeSomeExpired as its creating time; @param key, may not be null @param value - any value object @return old value or null
[ "Method", "to", "store", "value", "in", "cache", "if", "this", "value", "first", "in", "cache", "-", "also", "mark", "nextTimeSomeExpired", "as", "its", "creating", "time", ";" ]
1902ec50b5d6a531d9c5faf99760eacf3d0cbb21
https://github.com/yerenkow/javaz/blob/1902ec50b5d6a531d9c5faf99760eacf3d0cbb21/cache/src/main/java/org/javaz/cache/CacheImpl.java#L81-L93
train
yerenkow/javaz
cache/src/main/java/org/javaz/cache/CacheImpl.java
CacheImpl.remove
public Object remove(Object key) { synchronized (objects) { Object remove = objects.remove(key); objectTimeStamps.remove(key); if (remove != null) { findNextExpireTime(); } return remove; } }
java
public Object remove(Object key) { synchronized (objects) { Object remove = objects.remove(key); objectTimeStamps.remove(key); if (remove != null) { findNextExpireTime(); } return remove; } }
[ "public", "Object", "remove", "(", "Object", "key", ")", "{", "synchronized", "(", "objects", ")", "{", "Object", "remove", "=", "objects", ".", "remove", "(", "key", ")", ";", "objectTimeStamps", ".", "remove", "(", "key", ")", ";", "if", "(", "remove...
When we remove any object, we must found again nextTimeSomeExpired. @param key - key to remove @return - object, if any
[ "When", "we", "remove", "any", "object", "we", "must", "found", "again", "nextTimeSomeExpired", "." ]
1902ec50b5d6a531d9c5faf99760eacf3d0cbb21
https://github.com/yerenkow/javaz/blob/1902ec50b5d6a531d9c5faf99760eacf3d0cbb21/cache/src/main/java/org/javaz/cache/CacheImpl.java#L196-L208
train
yerenkow/javaz
cache/src/main/java/org/javaz/cache/CacheImpl.java
CacheImpl.findNextExpireTime
private void findNextExpireTime() { if (objects.size() == 0) { nextTimeSomeExpired = NO_OBJECTS; } else { nextTimeSomeExpired = NO_OBJECTS; Collection<Long> longs = null; synchronized (objects) { longs = new ArrayList(objectTimeStamps.values()); } for (Iterator<Long> iterator = longs.iterator(); iterator.hasNext(); ) { Long next = iterator.next() + timeToLive; if (nextTimeSomeExpired == NO_OBJECTS || next < nextTimeSomeExpired) { nextTimeSomeExpired = next; } } } }
java
private void findNextExpireTime() { if (objects.size() == 0) { nextTimeSomeExpired = NO_OBJECTS; } else { nextTimeSomeExpired = NO_OBJECTS; Collection<Long> longs = null; synchronized (objects) { longs = new ArrayList(objectTimeStamps.values()); } for (Iterator<Long> iterator = longs.iterator(); iterator.hasNext(); ) { Long next = iterator.next() + timeToLive; if (nextTimeSomeExpired == NO_OBJECTS || next < nextTimeSomeExpired) { nextTimeSomeExpired = next; } } } }
[ "private", "void", "findNextExpireTime", "(", ")", "{", "if", "(", "objects", ".", "size", "(", ")", "==", "0", ")", "{", "nextTimeSomeExpired", "=", "NO_OBJECTS", ";", "}", "else", "{", "nextTimeSomeExpired", "=", "NO_OBJECTS", ";", "Collection", "<", "Lo...
Internal-use method, finds out when next object will expire and store this as nextTimeSomeExpired. If there's no items in cache - let's store NO_OBJECTS
[ "Internal", "-", "use", "method", "finds", "out", "when", "next", "object", "will", "expire", "and", "store", "this", "as", "nextTimeSomeExpired", ".", "If", "there", "s", "no", "items", "in", "cache", "-", "let", "s", "store", "NO_OBJECTS" ]
1902ec50b5d6a531d9c5faf99760eacf3d0cbb21
https://github.com/yerenkow/javaz/blob/1902ec50b5d6a531d9c5faf99760eacf3d0cbb21/cache/src/main/java/org/javaz/cache/CacheImpl.java#L223-L246
train
brianwhu/xillium
core/src/main/java/org/xillium/core/util/ServiceMilestone.java
ServiceMilestone.attach
@SuppressWarnings("unchecked") public static <M extends Enum<M>> void attach(Service service, String milestore, ServiceMilestone.Evaluation evaluation) throws Exception { for (Field field: Beans.getKnownInstanceFields(service.getClass())) { if (ServiceMilestone.class.isAssignableFrom(field.getType())) { try { ((ServiceMilestone<M>)field.get(service)).attach(Enum.valueOf((Class<M>)getMilestoneEnum(field.getDeclaringClass()), milestore), evaluation); return; } catch (ClassNotFoundException x) { // No Milestone enum class found // keep looking } catch (IllegalArgumentException x) { // No enum constant as named // keep looking } } } throw new IllegalArgumentException("NoSuchMilestone"); }
java
@SuppressWarnings("unchecked") public static <M extends Enum<M>> void attach(Service service, String milestore, ServiceMilestone.Evaluation evaluation) throws Exception { for (Field field: Beans.getKnownInstanceFields(service.getClass())) { if (ServiceMilestone.class.isAssignableFrom(field.getType())) { try { ((ServiceMilestone<M>)field.get(service)).attach(Enum.valueOf((Class<M>)getMilestoneEnum(field.getDeclaringClass()), milestore), evaluation); return; } catch (ClassNotFoundException x) { // No Milestone enum class found // keep looking } catch (IllegalArgumentException x) { // No enum constant as named // keep looking } } } throw new IllegalArgumentException("NoSuchMilestone"); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "M", "extends", "Enum", "<", "M", ">", ">", "void", "attach", "(", "Service", "service", ",", "String", "milestore", ",", "ServiceMilestone", ".", "Evaluation", "evaluation", ")", "...
Attaches a ServiceMilestone.Evaluation onto a service.
[ "Attaches", "a", "ServiceMilestone", ".", "Evaluation", "onto", "a", "service", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/core/src/main/java/org/xillium/core/util/ServiceMilestone.java#L78-L93
train
brianwhu/xillium
core/src/main/java/org/xillium/core/util/ServiceMilestone.java
ServiceMilestone.attach
public void attach(M m, Evaluation eval) { _evaluations[m.ordinal()] = _evaluations[m.ordinal()] == null ? eval : new CompoundMilestoneEvaluation(eval, _evaluations[m.ordinal()]); }
java
public void attach(M m, Evaluation eval) { _evaluations[m.ordinal()] = _evaluations[m.ordinal()] == null ? eval : new CompoundMilestoneEvaluation(eval, _evaluations[m.ordinal()]); }
[ "public", "void", "attach", "(", "M", "m", ",", "Evaluation", "eval", ")", "{", "_evaluations", "[", "m", ".", "ordinal", "(", ")", "]", "=", "_evaluations", "[", "m", ".", "ordinal", "(", ")", "]", "==", "null", "?", "eval", ":", "new", "CompoundM...
Attaches a ServiceMilestone.Evaluation.
[ "Attaches", "a", "ServiceMilestone", ".", "Evaluation", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/core/src/main/java/org/xillium/core/util/ServiceMilestone.java#L125-L127
train
brianwhu/xillium
core/src/main/java/org/xillium/core/util/ServiceMilestone.java
ServiceMilestone.detach
public void detach(M m, Evaluation eval) { _evaluations[m.ordinal()] = CompoundMilestoneEvaluation.cleanse(_evaluations[m.ordinal()], eval); }
java
public void detach(M m, Evaluation eval) { _evaluations[m.ordinal()] = CompoundMilestoneEvaluation.cleanse(_evaluations[m.ordinal()], eval); }
[ "public", "void", "detach", "(", "M", "m", ",", "Evaluation", "eval", ")", "{", "_evaluations", "[", "m", ".", "ordinal", "(", ")", "]", "=", "CompoundMilestoneEvaluation", ".", "cleanse", "(", "_evaluations", "[", "m", ".", "ordinal", "(", ")", "]", "...
Detaches a ServiceMilestone.Evaluation.
[ "Detaches", "a", "ServiceMilestone", ".", "Evaluation", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/core/src/main/java/org/xillium/core/util/ServiceMilestone.java#L132-L134
train
brianwhu/xillium
core/src/main/java/org/xillium/core/util/ServiceMilestone.java
ServiceMilestone.evaluate
@SuppressWarnings("unchecked") public Recommendation evaluate(M milestone, DataBinder binder, Reifier dict, Persistence persist) { Evaluation evaluation = _evaluations[milestone.ordinal()]; return evaluation != null ? evaluation.evaluate((Class<M>)milestone.getClass(), milestone.toString(), binder, dict, persist) : Recommendation.CONTINUE; }
java
@SuppressWarnings("unchecked") public Recommendation evaluate(M milestone, DataBinder binder, Reifier dict, Persistence persist) { Evaluation evaluation = _evaluations[milestone.ordinal()]; return evaluation != null ? evaluation.evaluate((Class<M>)milestone.getClass(), milestone.toString(), binder, dict, persist) : Recommendation.CONTINUE; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Recommendation", "evaluate", "(", "M", "milestone", ",", "DataBinder", "binder", ",", "Reifier", "dict", ",", "Persistence", "persist", ")", "{", "Evaluation", "evaluation", "=", "_evaluations", "[", ...
Executes evaluations at a milestone.
[ "Executes", "evaluations", "at", "a", "milestone", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/core/src/main/java/org/xillium/core/util/ServiceMilestone.java#L139-L143
train
incodehq-legacy/incode-module-document
dom/src/main/java/org/incode/module/document/dom/impl/types/DocumentTypeRepository.java
DocumentTypeRepository.findByReference
@Programmatic public DocumentType findByReference( final String reference) { return queryResultsCache.execute( () -> repositoryService.firstMatch( new QueryDefault<>(DocumentType.class, "findByReference", "reference", reference)), DocumentTypeRepository.class, "findByReference", reference); }
java
@Programmatic public DocumentType findByReference( final String reference) { return queryResultsCache.execute( () -> repositoryService.firstMatch( new QueryDefault<>(DocumentType.class, "findByReference", "reference", reference)), DocumentTypeRepository.class, "findByReference", reference); }
[ "@", "Programmatic", "public", "DocumentType", "findByReference", "(", "final", "String", "reference", ")", "{", "return", "queryResultsCache", ".", "execute", "(", "(", ")", "->", "repositoryService", ".", "firstMatch", "(", "new", "QueryDefault", "<>", "(", "D...
region > findByReference
[ "region", ">", "findByReference" ]
c62f064e96d6e6007f7fd6a4bc06e03b78b1816c
https://github.com/incodehq-legacy/incode-module-document/blob/c62f064e96d6e6007f7fd6a4bc06e03b78b1816c/dom/src/main/java/org/incode/module/document/dom/impl/types/DocumentTypeRepository.java#L53-L64
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
ClassWriter.xClassName
public Name xClassName(Type t) { if (t.hasTag(CLASS)) { return names.fromUtf(externalize(t.tsym.flatName())); } else if (t.hasTag(ARRAY)) { return typeSig(types.erasure(t)); } else { throw new AssertionError("xClassName"); } }
java
public Name xClassName(Type t) { if (t.hasTag(CLASS)) { return names.fromUtf(externalize(t.tsym.flatName())); } else if (t.hasTag(ARRAY)) { return typeSig(types.erasure(t)); } else { throw new AssertionError("xClassName"); } }
[ "public", "Name", "xClassName", "(", "Type", "t", ")", "{", "if", "(", "t", ".", "hasTag", "(", "CLASS", ")", ")", "{", "return", "names", ".", "fromUtf", "(", "externalize", "(", "t", ".", "tsym", ".", "flatName", "(", ")", ")", ")", ";", "}", ...
Given a type t, return the extended class name of its erasure in external representation.
[ "Given", "a", "type", "t", "return", "the", "extended", "class", "name", "of", "its", "erasure", "in", "external", "representation", "." ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java#L357-L365
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
ClassWriter.fieldName
Name fieldName(Symbol sym) { if (scramble && (sym.flags() & PRIVATE) != 0 || scrambleAll && (sym.flags() & (PROTECTED | PUBLIC)) == 0) return names.fromString("_$" + sym.name.getIndex()); else return sym.name; }
java
Name fieldName(Symbol sym) { if (scramble && (sym.flags() & PRIVATE) != 0 || scrambleAll && (sym.flags() & (PROTECTED | PUBLIC)) == 0) return names.fromString("_$" + sym.name.getIndex()); else return sym.name; }
[ "Name", "fieldName", "(", "Symbol", "sym", ")", "{", "if", "(", "scramble", "&&", "(", "sym", ".", "flags", "(", ")", "&", "PRIVATE", ")", "!=", "0", "||", "scrambleAll", "&&", "(", "sym", ".", "flags", "(", ")", "&", "(", "PROTECTED", "|", "PUBL...
Given a field, return its name.
[ "Given", "a", "field", "return", "its", "name", "." ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java#L494-L500
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
ClassWriter.writeMethod
void writeMethod(MethodSymbol m) { int flags = adjustFlags(m.flags()); databuf.appendChar(flags); if (dumpMethodModifiers) { PrintWriter pw = log.getWriter(Log.WriterKind.ERROR); pw.println("METHOD " + fieldName(m)); pw.println("---" + flagNames(m.flags())); } databuf.appendChar(pool.put(fieldName(m))); databuf.appendChar(pool.put(typeSig(m.externalType(types)))); int acountIdx = beginAttrs(); int acount = 0; if (m.code != null) { int alenIdx = writeAttr(names.Code); writeCode(m.code); m.code = null; // to conserve space endAttr(alenIdx); acount++; } List<Type> thrown = m.erasure(types).getThrownTypes(); if (thrown.nonEmpty()) { int alenIdx = writeAttr(names.Exceptions); databuf.appendChar(thrown.length()); for (List<Type> l = thrown; l.nonEmpty(); l = l.tail) databuf.appendChar(pool.put(l.head.tsym)); endAttr(alenIdx); acount++; } if (m.defaultValue != null) { int alenIdx = writeAttr(names.AnnotationDefault); m.defaultValue.accept(awriter); endAttr(alenIdx); acount++; } if (options.isSet(PARAMETERS)) acount += writeMethodParametersAttr(m); acount += writeMemberAttrs(m); acount += writeParameterAttrs(m); endAttrs(acountIdx, acount); }
java
void writeMethod(MethodSymbol m) { int flags = adjustFlags(m.flags()); databuf.appendChar(flags); if (dumpMethodModifiers) { PrintWriter pw = log.getWriter(Log.WriterKind.ERROR); pw.println("METHOD " + fieldName(m)); pw.println("---" + flagNames(m.flags())); } databuf.appendChar(pool.put(fieldName(m))); databuf.appendChar(pool.put(typeSig(m.externalType(types)))); int acountIdx = beginAttrs(); int acount = 0; if (m.code != null) { int alenIdx = writeAttr(names.Code); writeCode(m.code); m.code = null; // to conserve space endAttr(alenIdx); acount++; } List<Type> thrown = m.erasure(types).getThrownTypes(); if (thrown.nonEmpty()) { int alenIdx = writeAttr(names.Exceptions); databuf.appendChar(thrown.length()); for (List<Type> l = thrown; l.nonEmpty(); l = l.tail) databuf.appendChar(pool.put(l.head.tsym)); endAttr(alenIdx); acount++; } if (m.defaultValue != null) { int alenIdx = writeAttr(names.AnnotationDefault); m.defaultValue.accept(awriter); endAttr(alenIdx); acount++; } if (options.isSet(PARAMETERS)) acount += writeMethodParametersAttr(m); acount += writeMemberAttrs(m); acount += writeParameterAttrs(m); endAttrs(acountIdx, acount); }
[ "void", "writeMethod", "(", "MethodSymbol", "m", ")", "{", "int", "flags", "=", "adjustFlags", "(", "m", ".", "flags", "(", ")", ")", ";", "databuf", ".", "appendChar", "(", "flags", ")", ";", "if", "(", "dumpMethodModifiers", ")", "{", "PrintWriter", ...
Write method symbol, entering all references into constant pool.
[ "Write", "method", "symbol", "entering", "all", "references", "into", "constant", "pool", "." ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java#L1105-L1144
train
brianwhu/xillium
data/src/main/java/org/xillium/data/persistence/util/MetaDataHelper.java
MetaDataHelper.getPrimaryKey
public static Set<String> getPrimaryKey(DatabaseMetaData metadata, String tableName) throws Exception { Set<String> columns = new HashSet<String>(); ResultSet keys = metadata.getPrimaryKeys(metadata.getConnection().getCatalog(), metadata.getUserName(), tableName); while (keys.next()) { columns.add(keys.getString(PRIMARY_PK_COL_NAME)); } keys.close(); return columns; }
java
public static Set<String> getPrimaryKey(DatabaseMetaData metadata, String tableName) throws Exception { Set<String> columns = new HashSet<String>(); ResultSet keys = metadata.getPrimaryKeys(metadata.getConnection().getCatalog(), metadata.getUserName(), tableName); while (keys.next()) { columns.add(keys.getString(PRIMARY_PK_COL_NAME)); } keys.close(); return columns; }
[ "public", "static", "Set", "<", "String", ">", "getPrimaryKey", "(", "DatabaseMetaData", "metadata", ",", "String", "tableName", ")", "throws", "Exception", "{", "Set", "<", "String", ">", "columns", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";"...
Returns a table's primary key columns as a Set of strings.
[ "Returns", "a", "table", "s", "primary", "key", "columns", "as", "a", "Set", "of", "strings", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/persistence/util/MetaDataHelper.java#L103-L111
train
brianwhu/xillium
data/src/main/java/org/xillium/data/persistence/util/MetaDataHelper.java
MetaDataHelper.getExportedKeys
public static Map<String, ForeignKey> getExportedKeys(DatabaseMetaData metadata, String tableName) throws Exception { ResultSet keys = metadata.getExportedKeys(metadata.getConnection().getCatalog(), metadata.getUserName(), tableName); Map<String, ForeignKey> map = new HashMap<String, ForeignKey>(); while (keys.next()) { String table = keys.getString(EXPORTED_FK_TAB_NAME); String name = keys.getString(EXPORTED_FK_KEY_NAME); if (name == null || name.length() == 0) name = "UNNAMED_FK_" + table; ForeignKey key = map.get(name); if (key == null) { map.put(name, key = new ForeignKey(table)); } key.add(keys.getString(EXPORTED_FK_COL_NAME)); } keys.close(); return map; }
java
public static Map<String, ForeignKey> getExportedKeys(DatabaseMetaData metadata, String tableName) throws Exception { ResultSet keys = metadata.getExportedKeys(metadata.getConnection().getCatalog(), metadata.getUserName(), tableName); Map<String, ForeignKey> map = new HashMap<String, ForeignKey>(); while (keys.next()) { String table = keys.getString(EXPORTED_FK_TAB_NAME); String name = keys.getString(EXPORTED_FK_KEY_NAME); if (name == null || name.length() == 0) name = "UNNAMED_FK_" + table; ForeignKey key = map.get(name); if (key == null) { map.put(name, key = new ForeignKey(table)); } key.add(keys.getString(EXPORTED_FK_COL_NAME)); } keys.close(); return map; }
[ "public", "static", "Map", "<", "String", ",", "ForeignKey", ">", "getExportedKeys", "(", "DatabaseMetaData", "metadata", ",", "String", "tableName", ")", "throws", "Exception", "{", "ResultSet", "keys", "=", "metadata", ".", "getExportedKeys", "(", "metadata", ...
Returns a table's exported keys and their columns as a Map from the key name to the ForeignKey object. <p>A foreign key may not have a name. On such a database, 2 foreign keys must reference 2 different tables. Otherwise there's no way to tell them apart and the foreign key information reported by DatabaseMetaData becomes ill-formed.</p>
[ "Returns", "a", "table", "s", "exported", "keys", "and", "their", "columns", "as", "a", "Map", "from", "the", "key", "name", "to", "the", "ForeignKey", "object", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/persistence/util/MetaDataHelper.java#L119-L136
train
brianwhu/xillium
data/src/main/java/org/xillium/data/persistence/util/MetaDataHelper.java
MetaDataHelper.getForeignKeys
public static Map<String, ForeignKey> getForeignKeys(DatabaseMetaData metadata, String tableName) throws Exception { ResultSet keys = metadata.getImportedKeys(metadata.getConnection().getCatalog(), metadata.getUserName(), tableName); Map<String, ForeignKey> map = new HashMap<String, ForeignKey>(); while (keys.next()) { String table = keys.getString(IMPORTED_PK_TAB_NAME); String name = keys.getString(IMPORTED_FK_KEY_NAME); if (name == null || name.length() == 0) name = "UNNAMED_FK_" + table; ForeignKey key = map.get(name); if (key == null) { map.put(name, key = new ForeignKey(table)); } key.add(keys.getString(IMPORTED_FK_COL_NAME)); } keys.close(); return map; }
java
public static Map<String, ForeignKey> getForeignKeys(DatabaseMetaData metadata, String tableName) throws Exception { ResultSet keys = metadata.getImportedKeys(metadata.getConnection().getCatalog(), metadata.getUserName(), tableName); Map<String, ForeignKey> map = new HashMap<String, ForeignKey>(); while (keys.next()) { String table = keys.getString(IMPORTED_PK_TAB_NAME); String name = keys.getString(IMPORTED_FK_KEY_NAME); if (name == null || name.length() == 0) name = "UNNAMED_FK_" + table; ForeignKey key = map.get(name); if (key == null) { map.put(name, key = new ForeignKey(table)); } key.add(keys.getString(IMPORTED_FK_COL_NAME)); } keys.close(); return map; }
[ "public", "static", "Map", "<", "String", ",", "ForeignKey", ">", "getForeignKeys", "(", "DatabaseMetaData", "metadata", ",", "String", "tableName", ")", "throws", "Exception", "{", "ResultSet", "keys", "=", "metadata", ".", "getImportedKeys", "(", "metadata", "...
Returns a table's foreign keys and their columns as a Map from the key name to the ForeignKey object. <p>A foreign key may not have a name. On such a database, 2 foreign keys must reference 2 different tables. Otherwise there's no way to tell them apart and the foreign key information reported by DatabaseMetaData becomes ill-formed.</p>
[ "Returns", "a", "table", "s", "foreign", "keys", "and", "their", "columns", "as", "a", "Map", "from", "the", "key", "name", "to", "the", "ForeignKey", "object", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/persistence/util/MetaDataHelper.java#L144-L161
train
brianwhu/xillium
data/src/main/java/org/xillium/data/persistence/util/MetaDataHelper.java
MetaDataHelper.getColumns
public static List<Column> getColumns(DatabaseMetaData metadata, String tableName) throws Exception { List<Column> columns = new ArrayList<Column>(); PreparedStatement stmt = metadata.getConnection().prepareStatement("SELECT * FROM " + tableName); ResultSetMetaData rsmeta = stmt.getMetaData(); for (int i = 1, ii = rsmeta.getColumnCount(); i <= ii; ++i) { columns.add(new Column(rsmeta, i)); } stmt.close(); return columns; }
java
public static List<Column> getColumns(DatabaseMetaData metadata, String tableName) throws Exception { List<Column> columns = new ArrayList<Column>(); PreparedStatement stmt = metadata.getConnection().prepareStatement("SELECT * FROM " + tableName); ResultSetMetaData rsmeta = stmt.getMetaData(); for (int i = 1, ii = rsmeta.getColumnCount(); i <= ii; ++i) { columns.add(new Column(rsmeta, i)); } stmt.close(); return columns; }
[ "public", "static", "List", "<", "Column", ">", "getColumns", "(", "DatabaseMetaData", "metadata", ",", "String", "tableName", ")", "throws", "Exception", "{", "List", "<", "Column", ">", "columns", "=", "new", "ArrayList", "<", "Column", ">", "(", ")", ";...
Returns a table's columns
[ "Returns", "a", "table", "s", "columns" ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/persistence/util/MetaDataHelper.java#L166-L176
train
brianwhu/xillium
data/src/main/java/org/xillium/data/persistence/util/MetaDataHelper.java
MetaDataHelper.getTable
public static Table getTable(DatabaseMetaData metadata, String tableName) throws Exception { return new Table( tableName, getPrimaryKey(metadata, tableName), getForeignKeys(metadata, tableName), getExportedKeys(metadata, tableName), getColumns(metadata, tableName) ); }
java
public static Table getTable(DatabaseMetaData metadata, String tableName) throws Exception { return new Table( tableName, getPrimaryKey(metadata, tableName), getForeignKeys(metadata, tableName), getExportedKeys(metadata, tableName), getColumns(metadata, tableName) ); }
[ "public", "static", "Table", "getTable", "(", "DatabaseMetaData", "metadata", ",", "String", "tableName", ")", "throws", "Exception", "{", "return", "new", "Table", "(", "tableName", ",", "getPrimaryKey", "(", "metadata", ",", "tableName", ")", ",", "getForeignK...
Returns a table's structure
[ "Returns", "a", "table", "s", "structure" ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/persistence/util/MetaDataHelper.java#L181-L189
train
brianwhu/xillium
data/src/main/java/org/xillium/data/persistence/util/MetaDataHelper.java
MetaDataHelper.getClassName
public static String getClassName(ResultSetMetaData meta, int index) throws SQLException { switch (meta.getColumnType(index)) { case Types.NUMERIC: int precision = meta.getPrecision(index); if (meta.getScale(index) == 0) { if (precision > 18) { return "java.math.BigInteger"; } else if (precision > 9) { return "java.lang.Long"; } else if (precision > 4) { return "java.lang.Integer"; } else if (precision > 2) { return "java.lang.Short"; } else { return "java.lang.Byte"; } } else { if (precision > 16) { return "java.math.BigDecimal"; } else if (precision > 7) { return "java.lang.Double"; } else { return "java.lang.Float"; } } case Types.TIMESTAMP: if (meta.getScale(index) == 0) { return "java.sql.Date"; } else { return "java.sql.Timestamp"; } default: return meta.getColumnClassName(index); } }
java
public static String getClassName(ResultSetMetaData meta, int index) throws SQLException { switch (meta.getColumnType(index)) { case Types.NUMERIC: int precision = meta.getPrecision(index); if (meta.getScale(index) == 0) { if (precision > 18) { return "java.math.BigInteger"; } else if (precision > 9) { return "java.lang.Long"; } else if (precision > 4) { return "java.lang.Integer"; } else if (precision > 2) { return "java.lang.Short"; } else { return "java.lang.Byte"; } } else { if (precision > 16) { return "java.math.BigDecimal"; } else if (precision > 7) { return "java.lang.Double"; } else { return "java.lang.Float"; } } case Types.TIMESTAMP: if (meta.getScale(index) == 0) { return "java.sql.Date"; } else { return "java.sql.Timestamp"; } default: return meta.getColumnClassName(index); } }
[ "public", "static", "String", "getClassName", "(", "ResultSetMetaData", "meta", ",", "int", "index", ")", "throws", "SQLException", "{", "switch", "(", "meta", ".", "getColumnType", "(", "index", ")", ")", "{", "case", "Types", ".", "NUMERIC", ":", "int", ...
Returns a column's java class name.
[ "Returns", "a", "column", "s", "java", "class", "name", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/persistence/util/MetaDataHelper.java#L194-L228
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/provider/newrelic/MonitorCache.java
MonitorCache.add
public void add(Collection<Monitor> monitors) { for(Monitor monitor : monitors) this.monitors.put(monitor.getId(), monitor); }
java
public void add(Collection<Monitor> monitors) { for(Monitor monitor : monitors) this.monitors.put(monitor.getId(), monitor); }
[ "public", "void", "add", "(", "Collection", "<", "Monitor", ">", "monitors", ")", "{", "for", "(", "Monitor", "monitor", ":", "monitors", ")", "this", ".", "monitors", ".", "put", "(", "monitor", ".", "getId", "(", ")", ",", "monitor", ")", ";", "}" ...
Adds the monitor list to the monitors for the account. @param monitors The monitors to add
[ "Adds", "the", "monitor", "list", "to", "the", "monitors", "for", "the", "account", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/MonitorCache.java#L58-L62
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/provider/newrelic/MonitorCache.java
MonitorCache.labels
public LabelCache labels(String monitorId) { LabelCache cache = labels.get(monitorId); if(cache == null) labels.put(monitorId, cache = new LabelCache(monitorId)); return cache; }
java
public LabelCache labels(String monitorId) { LabelCache cache = labels.get(monitorId); if(cache == null) labels.put(monitorId, cache = new LabelCache(monitorId)); return cache; }
[ "public", "LabelCache", "labels", "(", "String", "monitorId", ")", "{", "LabelCache", "cache", "=", "labels", ".", "get", "(", "monitorId", ")", ";", "if", "(", "cache", "==", "null", ")", "labels", ".", "put", "(", "monitorId", ",", "cache", "=", "new...
Returns the cache of labels for the given monitor, creating one if it doesn't exist . @param monitorId The id of the monitor for the cache of labels @return The cache of labels for the given monitor
[ "Returns", "the", "cache", "of", "labels", "for", "the", "given", "monitor", "creating", "one", "if", "it", "doesn", "t", "exist", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/MonitorCache.java#L104-L110
train
magik6k/JWWF
src/main/java/net/magik6k/jwwf/widgets/basic/panel/TabbedPanel.java
TabbedPanel.put
public TabbedPanel put(Widget widget, String name, int index) { if (index < 0 || index >= content.length) throw new IndexOutOfBoundsException(); if (widget == null) return this; attach(widget); content[index] = new Tab(widget, name); this.sendElement(); return this; }
java
public TabbedPanel put(Widget widget, String name, int index) { if (index < 0 || index >= content.length) throw new IndexOutOfBoundsException(); if (widget == null) return this; attach(widget); content[index] = new Tab(widget, name); this.sendElement(); return this; }
[ "public", "TabbedPanel", "put", "(", "Widget", "widget", ",", "String", "name", ",", "int", "index", ")", "{", "if", "(", "index", "<", "0", "||", "index", ">=", "content", ".", "length", ")", "throw", "new", "IndexOutOfBoundsException", "(", ")", ";", ...
Puts new widget to the container @param widget Widget to put @param name Name of tab @param index id of 'cell' in the container to put widget to(numbered from 0) @return This instance for chaining
[ "Puts", "new", "widget", "to", "the", "container" ]
8ba334501396c3301495da8708733f6014f20665
https://github.com/magik6k/JWWF/blob/8ba334501396c3301495da8708733f6014f20665/src/main/java/net/magik6k/jwwf/widgets/basic/panel/TabbedPanel.java#L69-L76
train
phax/ph-masterdata
ph-masterdata/src/main/java/com/helger/masterdata/email/ExtendedEmailAddress.java
ExtendedEmailAddress.setAddress
@Nonnull public final EChange setAddress (@Nonnull final String sAddress) { ValueEnforcer.notNull (sAddress, "Address"); final String sRealAddress = EmailAddressHelper.getUnifiedEmailAddress (sAddress); if (EqualsHelper.equals (sRealAddress, m_sAddress)) return EChange.UNCHANGED; // Check only without MX record check here, because this is a performance // bottleneck when having multiple customers if (sRealAddress != null && !EmailAddressHelper.isValid (sRealAddress)) { if (LOGGER.isErrorEnabled ()) LOGGER.error ("Found an illegal email address: '" + sRealAddress + "'"); return EChange.UNCHANGED; } m_sAddress = sRealAddress; return EChange.CHANGED; }
java
@Nonnull public final EChange setAddress (@Nonnull final String sAddress) { ValueEnforcer.notNull (sAddress, "Address"); final String sRealAddress = EmailAddressHelper.getUnifiedEmailAddress (sAddress); if (EqualsHelper.equals (sRealAddress, m_sAddress)) return EChange.UNCHANGED; // Check only without MX record check here, because this is a performance // bottleneck when having multiple customers if (sRealAddress != null && !EmailAddressHelper.isValid (sRealAddress)) { if (LOGGER.isErrorEnabled ()) LOGGER.error ("Found an illegal email address: '" + sRealAddress + "'"); return EChange.UNCHANGED; } m_sAddress = sRealAddress; return EChange.CHANGED; }
[ "@", "Nonnull", "public", "final", "EChange", "setAddress", "(", "@", "Nonnull", "final", "String", "sAddress", ")", "{", "ValueEnforcer", ".", "notNull", "(", "sAddress", ",", "\"Address\"", ")", ";", "final", "String", "sRealAddress", "=", "EmailAddressHelper"...
Set the address part of the email address. Performs a validity check of the email address. @param sAddress The address part to be set. May not be <code>null</code>. @return {@link EChange#CHANGED} if the address was valid and different from the existing one. Returns {@link EChange#UNCHANGED} if the email address was the same as before, or the email address itself was invalid.
[ "Set", "the", "address", "part", "of", "the", "email", "address", ".", "Performs", "a", "validity", "check", "of", "the", "email", "address", "." ]
ca5e0b03c735b30b47930c018bfb5e71f00d0ff4
https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/email/ExtendedEmailAddress.java#L114-L133
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
JavacFileManager.preRegister
public static void preRegister(Context context) { context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() { public JavaFileManager make(Context c) { return new JavacFileManager(c, true, null); } }); }
java
public static void preRegister(Context context) { context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() { public JavaFileManager make(Context c) { return new JavacFileManager(c, true, null); } }); }
[ "public", "static", "void", "preRegister", "(", "Context", "context", ")", "{", "context", ".", "put", "(", "JavaFileManager", ".", "class", ",", "new", "Context", ".", "Factory", "<", "JavaFileManager", ">", "(", ")", "{", "public", "JavaFileManager", "make...
Register a Context.Factory to create a JavacFileManager.
[ "Register", "a", "Context", ".", "Factory", "to", "create", "a", "JavacFileManager", "." ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java#L112-L118
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
JavacFileManager.listDirectory
private void listDirectory(File directory, RelativeDirectory subdirectory, Set<JavaFileObject.Kind> fileKinds, boolean recurse, ListBuffer<JavaFileObject> resultList) { File d = subdirectory.getFile(directory); if (!caseMapCheck(d, subdirectory)) return; File[] files = d.listFiles(); if (files == null) return; if (sortFiles != null) Arrays.sort(files, sortFiles); for (File f: files) { String fname = f.getName(); if (f.isDirectory()) { if (recurse && SourceVersion.isIdentifier(fname)) { listDirectory(directory, new RelativeDirectory(subdirectory, fname), fileKinds, recurse, resultList); } } else { if (isValidFile(fname, fileKinds)) { JavaFileObject fe = new RegularFileObject(this, fname, new File(d, fname)); resultList.append(fe); } } } }
java
private void listDirectory(File directory, RelativeDirectory subdirectory, Set<JavaFileObject.Kind> fileKinds, boolean recurse, ListBuffer<JavaFileObject> resultList) { File d = subdirectory.getFile(directory); if (!caseMapCheck(d, subdirectory)) return; File[] files = d.listFiles(); if (files == null) return; if (sortFiles != null) Arrays.sort(files, sortFiles); for (File f: files) { String fname = f.getName(); if (f.isDirectory()) { if (recurse && SourceVersion.isIdentifier(fname)) { listDirectory(directory, new RelativeDirectory(subdirectory, fname), fileKinds, recurse, resultList); } } else { if (isValidFile(fname, fileKinds)) { JavaFileObject fe = new RegularFileObject(this, fname, new File(d, fname)); resultList.append(fe); } } } }
[ "private", "void", "listDirectory", "(", "File", "directory", ",", "RelativeDirectory", "subdirectory", ",", "Set", "<", "JavaFileObject", ".", "Kind", ">", "fileKinds", ",", "boolean", "recurse", ",", "ListBuffer", "<", "JavaFileObject", ">", "resultList", ")", ...
Insert all files in subdirectory subdirectory of directory directory which match fileKinds into resultList
[ "Insert", "all", "files", "in", "subdirectory", "subdirectory", "of", "directory", "directory", "which", "match", "fileKinds", "into", "resultList" ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java#L257-L291
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
JavacFileManager.listArchive
private void listArchive(Archive archive, RelativeDirectory subdirectory, Set<JavaFileObject.Kind> fileKinds, boolean recurse, ListBuffer<JavaFileObject> resultList) { // Get the files directly in the subdir List<String> files = archive.getFiles(subdirectory); if (files != null) { for (; !files.isEmpty(); files = files.tail) { String file = files.head; if (isValidFile(file, fileKinds)) { resultList.append(archive.getFileObject(subdirectory, file)); } } } if (recurse) { for (RelativeDirectory s: archive.getSubdirectories()) { if (subdirectory.contains(s)) { // Because the archive map is a flat list of directories, // the enclosing loop will pick up all child subdirectories. // Therefore, there is no need to recurse deeper. listArchive(archive, s, fileKinds, false, resultList); } } } }
java
private void listArchive(Archive archive, RelativeDirectory subdirectory, Set<JavaFileObject.Kind> fileKinds, boolean recurse, ListBuffer<JavaFileObject> resultList) { // Get the files directly in the subdir List<String> files = archive.getFiles(subdirectory); if (files != null) { for (; !files.isEmpty(); files = files.tail) { String file = files.head; if (isValidFile(file, fileKinds)) { resultList.append(archive.getFileObject(subdirectory, file)); } } } if (recurse) { for (RelativeDirectory s: archive.getSubdirectories()) { if (subdirectory.contains(s)) { // Because the archive map is a flat list of directories, // the enclosing loop will pick up all child subdirectories. // Therefore, there is no need to recurse deeper. listArchive(archive, s, fileKinds, false, resultList); } } } }
[ "private", "void", "listArchive", "(", "Archive", "archive", ",", "RelativeDirectory", "subdirectory", ",", "Set", "<", "JavaFileObject", ".", "Kind", ">", "fileKinds", ",", "boolean", "recurse", ",", "ListBuffer", "<", "JavaFileObject", ">", "resultList", ")", ...
Insert all files in subdirectory subdirectory of archive archive which match fileKinds into resultList
[ "Insert", "all", "files", "in", "subdirectory", "subdirectory", "of", "archive", "archive", "which", "match", "fileKinds", "into", "resultList" ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java#L297-L322
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
JavacFileManager.listContainer
private void listContainer(File container, RelativeDirectory subdirectory, Set<JavaFileObject.Kind> fileKinds, boolean recurse, ListBuffer<JavaFileObject> resultList) { Archive archive = archives.get(container); if (archive == null) { // archives are not created for directories. if (fsInfo.isDirectory(container)) { listDirectory(container, subdirectory, fileKinds, recurse, resultList); return; } // Not a directory; either a file or non-existant, create the archive try { archive = openArchive(container); } catch (IOException ex) { log.error("error.reading.file", container, getMessage(ex)); return; } } listArchive(archive, subdirectory, fileKinds, recurse, resultList); }
java
private void listContainer(File container, RelativeDirectory subdirectory, Set<JavaFileObject.Kind> fileKinds, boolean recurse, ListBuffer<JavaFileObject> resultList) { Archive archive = archives.get(container); if (archive == null) { // archives are not created for directories. if (fsInfo.isDirectory(container)) { listDirectory(container, subdirectory, fileKinds, recurse, resultList); return; } // Not a directory; either a file or non-existant, create the archive try { archive = openArchive(container); } catch (IOException ex) { log.error("error.reading.file", container, getMessage(ex)); return; } } listArchive(archive, subdirectory, fileKinds, recurse, resultList); }
[ "private", "void", "listContainer", "(", "File", "container", ",", "RelativeDirectory", "subdirectory", ",", "Set", "<", "JavaFileObject", ".", "Kind", ">", "fileKinds", ",", "boolean", "recurse", ",", "ListBuffer", "<", "JavaFileObject", ">", "resultList", ")", ...
container is a directory, a zip file, or a non-existant path. Insert all files in subdirectory subdirectory of container which match fileKinds into resultList
[ "container", "is", "a", "directory", "a", "zip", "file", "or", "a", "non", "-", "existant", "path", ".", "Insert", "all", "files", "in", "subdirectory", "subdirectory", "of", "container", "which", "match", "fileKinds", "into", "resultList" ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java#L329-L360
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
JavacFileManager.openArchive
private Archive openArchive(File zipFileName, boolean useOptimizedZip) throws IOException { File origZipFileName = zipFileName; if (symbolFileEnabled && locations.isDefaultBootClassPathRtJar(zipFileName)) { File file = zipFileName.getParentFile().getParentFile(); // ${java.home} if (new File(file.getName()).equals(new File("jre"))) file = file.getParentFile(); // file == ${jdk.home} for (String name : symbolFileLocation) file = new File(file, name); // file == ${jdk.home}/lib/ct.sym if (file.exists()) zipFileName = file; } Archive archive; try { ZipFile zdir = null; boolean usePreindexedCache = false; String preindexCacheLocation = null; if (!useOptimizedZip) { zdir = new ZipFile(zipFileName); } else { usePreindexedCache = options.isSet("usezipindex"); preindexCacheLocation = options.get("java.io.tmpdir"); String optCacheLoc = options.get("cachezipindexdir"); if (optCacheLoc != null && optCacheLoc.length() != 0) { if (optCacheLoc.startsWith("\"")) { if (optCacheLoc.endsWith("\"")) { optCacheLoc = optCacheLoc.substring(1, optCacheLoc.length() - 1); } else { optCacheLoc = optCacheLoc.substring(1); } } File cacheDir = new File(optCacheLoc); if (cacheDir.exists() && cacheDir.canWrite()) { preindexCacheLocation = optCacheLoc; if (!preindexCacheLocation.endsWith("/") && !preindexCacheLocation.endsWith(File.separator)) { preindexCacheLocation += File.separator; } } } } if (origZipFileName == zipFileName) { if (!useOptimizedZip) { archive = new ZipArchive(this, zdir); } else { archive = new ZipFileIndexArchive(this, zipFileIndexCache.getZipFileIndex(zipFileName, null, usePreindexedCache, preindexCacheLocation, options.isSet("writezipindexfiles"))); } } else { if (!useOptimizedZip) { archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix); } else { archive = new ZipFileIndexArchive(this, zipFileIndexCache.getZipFileIndex(zipFileName, symbolFilePrefix, usePreindexedCache, preindexCacheLocation, options.isSet("writezipindexfiles"))); } } } catch (FileNotFoundException ex) { archive = new MissingArchive(zipFileName); } catch (ZipFileIndex.ZipFormatException zfe) { throw zfe; } catch (IOException ex) { if (zipFileName.exists()) log.error("error.reading.file", zipFileName, getMessage(ex)); archive = new MissingArchive(zipFileName); } archives.put(origZipFileName, archive); return archive; }
java
private Archive openArchive(File zipFileName, boolean useOptimizedZip) throws IOException { File origZipFileName = zipFileName; if (symbolFileEnabled && locations.isDefaultBootClassPathRtJar(zipFileName)) { File file = zipFileName.getParentFile().getParentFile(); // ${java.home} if (new File(file.getName()).equals(new File("jre"))) file = file.getParentFile(); // file == ${jdk.home} for (String name : symbolFileLocation) file = new File(file, name); // file == ${jdk.home}/lib/ct.sym if (file.exists()) zipFileName = file; } Archive archive; try { ZipFile zdir = null; boolean usePreindexedCache = false; String preindexCacheLocation = null; if (!useOptimizedZip) { zdir = new ZipFile(zipFileName); } else { usePreindexedCache = options.isSet("usezipindex"); preindexCacheLocation = options.get("java.io.tmpdir"); String optCacheLoc = options.get("cachezipindexdir"); if (optCacheLoc != null && optCacheLoc.length() != 0) { if (optCacheLoc.startsWith("\"")) { if (optCacheLoc.endsWith("\"")) { optCacheLoc = optCacheLoc.substring(1, optCacheLoc.length() - 1); } else { optCacheLoc = optCacheLoc.substring(1); } } File cacheDir = new File(optCacheLoc); if (cacheDir.exists() && cacheDir.canWrite()) { preindexCacheLocation = optCacheLoc; if (!preindexCacheLocation.endsWith("/") && !preindexCacheLocation.endsWith(File.separator)) { preindexCacheLocation += File.separator; } } } } if (origZipFileName == zipFileName) { if (!useOptimizedZip) { archive = new ZipArchive(this, zdir); } else { archive = new ZipFileIndexArchive(this, zipFileIndexCache.getZipFileIndex(zipFileName, null, usePreindexedCache, preindexCacheLocation, options.isSet("writezipindexfiles"))); } } else { if (!useOptimizedZip) { archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix); } else { archive = new ZipFileIndexArchive(this, zipFileIndexCache.getZipFileIndex(zipFileName, symbolFilePrefix, usePreindexedCache, preindexCacheLocation, options.isSet("writezipindexfiles"))); } } } catch (FileNotFoundException ex) { archive = new MissingArchive(zipFileName); } catch (ZipFileIndex.ZipFormatException zfe) { throw zfe; } catch (IOException ex) { if (zipFileName.exists()) log.error("error.reading.file", zipFileName, getMessage(ex)); archive = new MissingArchive(zipFileName); } archives.put(origZipFileName, archive); return archive; }
[ "private", "Archive", "openArchive", "(", "File", "zipFileName", ",", "boolean", "useOptimizedZip", ")", "throws", "IOException", "{", "File", "origZipFileName", "=", "zipFileName", ";", "if", "(", "symbolFileEnabled", "&&", "locations", ".", "isDefaultBootClassPathRt...
Open a new zip file directory, and cache it.
[ "Open", "a", "new", "zip", "file", "directory", "and", "cache", "it", "." ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java#L474-L559
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/provider/newrelic/KeyTransactionCache.java
KeyTransactionCache.add
public void add(Collection<KeyTransaction> keyTransactions) { for(KeyTransaction keyTransaction : keyTransactions) this.keyTransactions.put(keyTransaction.getId(), keyTransaction); }
java
public void add(Collection<KeyTransaction> keyTransactions) { for(KeyTransaction keyTransaction : keyTransactions) this.keyTransactions.put(keyTransaction.getId(), keyTransaction); }
[ "public", "void", "add", "(", "Collection", "<", "KeyTransaction", ">", "keyTransactions", ")", "{", "for", "(", "KeyTransaction", "keyTransaction", ":", "keyTransactions", ")", "this", ".", "keyTransactions", ".", "put", "(", "keyTransaction", ".", "getId", "("...
Adds the key transaction list to the key transactions for the account. @param keyTransactions The key transactions to add
[ "Adds", "the", "key", "transaction", "list", "to", "the", "key", "transactions", "for", "the", "account", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/KeyTransactionCache.java#L67-L71
train
phax/ph-masterdata
ph-masterdata/src/main/java/com/helger/masterdata/vat/VATINStructureManager.java
VATINStructureManager.getFromValidVATIN
@Nullable public static VATINStructure getFromValidVATIN (@Nullable final String sVATIN) { if (StringHelper.getLength (sVATIN) > 2) for (final VATINStructure aStructure : s_aList) if (aStructure.isValid (sVATIN)) return aStructure; return null; }
java
@Nullable public static VATINStructure getFromValidVATIN (@Nullable final String sVATIN) { if (StringHelper.getLength (sVATIN) > 2) for (final VATINStructure aStructure : s_aList) if (aStructure.isValid (sVATIN)) return aStructure; return null; }
[ "@", "Nullable", "public", "static", "VATINStructure", "getFromValidVATIN", "(", "@", "Nullable", "final", "String", "sVATIN", ")", "{", "if", "(", "StringHelper", ".", "getLength", "(", "sVATIN", ")", ">", "2", ")", "for", "(", "final", "VATINStructure", "a...
Determine the structure for a given VATIN. @param sVATIN The VATIN to check @return <code>null</code> if no VATIN structure was found for the passed VATIN.
[ "Determine", "the", "structure", "for", "a", "given", "VATIN", "." ]
ca5e0b03c735b30b47930c018bfb5e71f00d0ff4
https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/vat/VATINStructureManager.java#L74-L82
train
phax/ph-masterdata
ph-masterdata/src/main/java/com/helger/masterdata/vat/VATINStructureManager.java
VATINStructureManager.getFromVATINCountry
@Nullable public static VATINStructure getFromVATINCountry (@Nullable final String sVATIN) { if (StringHelper.getLength (sVATIN) >= 2) { final String sCountry = sVATIN.substring (0, 2); for (final VATINStructure aStructure : s_aList) if (aStructure.getExamples ().get (0).substring (0, 2).equalsIgnoreCase (sCountry)) return aStructure; } return null; }
java
@Nullable public static VATINStructure getFromVATINCountry (@Nullable final String sVATIN) { if (StringHelper.getLength (sVATIN) >= 2) { final String sCountry = sVATIN.substring (0, 2); for (final VATINStructure aStructure : s_aList) if (aStructure.getExamples ().get (0).substring (0, 2).equalsIgnoreCase (sCountry)) return aStructure; } return null; }
[ "@", "Nullable", "public", "static", "VATINStructure", "getFromVATINCountry", "(", "@", "Nullable", "final", "String", "sVATIN", ")", "{", "if", "(", "StringHelper", ".", "getLength", "(", "sVATIN", ")", ">=", "2", ")", "{", "final", "String", "sCountry", "=...
Resolve the VATIN structure only from the country part of the given VATIN. This should help indicate how the VATIN is valid. @param sVATIN The VATIN with at least 2 characters for the country code. @return <code>null</code> if the passed string is shorter than 2 characters or if the passed VATIN country code is invalid/unknown.
[ "Resolve", "the", "VATIN", "structure", "only", "from", "the", "country", "part", "of", "the", "given", "VATIN", ".", "This", "should", "help", "indicate", "how", "the", "VATIN", "is", "valid", "." ]
ca5e0b03c735b30b47930c018bfb5e71f00d0ff4
https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/vat/VATINStructureManager.java#L93-L104
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/javac/api/WrappingJavaFileManager.java
WrappingJavaFileManager.wrap
protected Iterable<JavaFileObject> wrap(Iterable<JavaFileObject> fileObjects) { List<JavaFileObject> mapped = new ArrayList<JavaFileObject>(); for (JavaFileObject fileObject : fileObjects) mapped.add(wrap(fileObject)); return Collections.unmodifiableList(mapped); }
java
protected Iterable<JavaFileObject> wrap(Iterable<JavaFileObject> fileObjects) { List<JavaFileObject> mapped = new ArrayList<JavaFileObject>(); for (JavaFileObject fileObject : fileObjects) mapped.add(wrap(fileObject)); return Collections.unmodifiableList(mapped); }
[ "protected", "Iterable", "<", "JavaFileObject", ">", "wrap", "(", "Iterable", "<", "JavaFileObject", ">", "fileObjects", ")", "{", "List", "<", "JavaFileObject", ">", "mapped", "=", "new", "ArrayList", "<", "JavaFileObject", ">", "(", ")", ";", "for", "(", ...
This implementation maps the given list of file objects by calling wrap on each. Subclasses may override this behavior. @param fileObjects a list of file objects @return the mapping
[ "This", "implementation", "maps", "the", "given", "list", "of", "file", "objects", "by", "calling", "wrap", "on", "each", ".", "Subclasses", "may", "override", "this", "behavior", "." ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/api/WrappingJavaFileManager.java#L117-L122
train
syphr42/libmythtv-java
control/src/main/java/org/syphr/mythtv/control/ControlFactory.java
ControlFactory.createInstance
public static Control createInstance(ControlVersion version) { switch (version) { case _0_24: return new Control0_24(); case _0_25: return new Control0_25(); default: throw new IllegalArgumentException("Unknown control version: " + version); } }
java
public static Control createInstance(ControlVersion version) { switch (version) { case _0_24: return new Control0_24(); case _0_25: return new Control0_25(); default: throw new IllegalArgumentException("Unknown control version: " + version); } }
[ "public", "static", "Control", "createInstance", "(", "ControlVersion", "version", ")", "{", "switch", "(", "version", ")", "{", "case", "_0_24", ":", "return", "new", "Control0_24", "(", ")", ";", "case", "_0_25", ":", "return", "new", "Control0_25", "(", ...
Create a new instance of the frontend network control for the desired version. @param version the desired network control version @return a new network control instance
[ "Create", "a", "new", "instance", "of", "the", "frontend", "network", "control", "for", "the", "desired", "version", "." ]
cc7a2012fbd4a4ba2562dda6b2614fb0548526ea
https://github.com/syphr42/libmythtv-java/blob/cc7a2012fbd4a4ba2562dda6b2614fb0548526ea/control/src/main/java/org/syphr/mythtv/control/ControlFactory.java#L37-L50
train
magik6k/JWWF
src/main/java/net/magik6k/jwwf/core/Widget.java
Widget.attach
protected final void attach(Attachable widget) { if (user != null) { widget.addTo(user); } else { if (waitingForUser == null) waitingForUser = new LinkedList<Attachable>(); waitingForUser.add(widget); } }
java
protected final void attach(Attachable widget) { if (user != null) { widget.addTo(user); } else { if (waitingForUser == null) waitingForUser = new LinkedList<Attachable>(); waitingForUser.add(widget); } }
[ "protected", "final", "void", "attach", "(", "Attachable", "widget", ")", "{", "if", "(", "user", "!=", "null", ")", "{", "widget", ".", "addTo", "(", "user", ")", ";", "}", "else", "{", "if", "(", "waitingForUser", "==", "null", ")", "waitingForUser",...
Used to declare that instance of widget is 'held' by this widget. If this widget is container it must invoke this method for all widgets it stores @param widget Widget that is stored in this widget
[ "Used", "to", "declare", "that", "instance", "of", "widget", "is", "held", "by", "this", "widget", ".", "If", "this", "widget", "is", "container", "it", "must", "invoke", "this", "method", "for", "all", "widgets", "it", "stores" ]
8ba334501396c3301495da8708733f6014f20665
https://github.com/magik6k/JWWF/blob/8ba334501396c3301495da8708733f6014f20665/src/main/java/net/magik6k/jwwf/core/Widget.java#L126-L133
train
jbundle/osgi
core/src/main/java/org/jbundle/util/osgi/finder/ClassServiceUtility.java
ClassServiceUtility.getClassFinder
public org.jbundle.util.osgi.ClassFinder getClassFinder(Object context) { if (!classServiceAvailable) return null; try { if (classFinder == null) { Class.forName("org.osgi.framework.BundleActivator"); // This tests to see if osgi exists //classFinder = (org.jbundle.util.osgi.ClassFinder)org.jbundle.util.osgi.finder.ClassFinderActivator.getClassFinder(context, -1); try { // Use reflection so the smart jvm's don't try to retrieve this class. Class<?> clazz = Class.forName("org.jbundle.util.osgi.finder.ClassFinderActivator"); // This tests to see if osgi exists if (clazz != null) { java.lang.reflect.Method method = clazz.getMethod("getClassFinder", Object.class, int.class); if (method != null) classFinder = (org.jbundle.util.osgi.ClassFinder)method.invoke(null, context, -1); } } catch (Exception e) { e.printStackTrace(); } } return classFinder; } catch (ClassNotFoundException ex) { classServiceAvailable = false; // Osgi is not installed, no need to keep trying return null; } catch (Exception ex) { ex.printStackTrace(); return null; } }
java
public org.jbundle.util.osgi.ClassFinder getClassFinder(Object context) { if (!classServiceAvailable) return null; try { if (classFinder == null) { Class.forName("org.osgi.framework.BundleActivator"); // This tests to see if osgi exists //classFinder = (org.jbundle.util.osgi.ClassFinder)org.jbundle.util.osgi.finder.ClassFinderActivator.getClassFinder(context, -1); try { // Use reflection so the smart jvm's don't try to retrieve this class. Class<?> clazz = Class.forName("org.jbundle.util.osgi.finder.ClassFinderActivator"); // This tests to see if osgi exists if (clazz != null) { java.lang.reflect.Method method = clazz.getMethod("getClassFinder", Object.class, int.class); if (method != null) classFinder = (org.jbundle.util.osgi.ClassFinder)method.invoke(null, context, -1); } } catch (Exception e) { e.printStackTrace(); } } return classFinder; } catch (ClassNotFoundException ex) { classServiceAvailable = false; // Osgi is not installed, no need to keep trying return null; } catch (Exception ex) { ex.printStackTrace(); return null; } }
[ "public", "org", ".", "jbundle", ".", "util", ".", "osgi", ".", "ClassFinder", "getClassFinder", "(", "Object", "context", ")", "{", "if", "(", "!", "classServiceAvailable", ")", "return", "null", ";", "try", "{", "if", "(", "classFinder", "==", "null", ...
Doesn't need to be static since this is only created once
[ "Doesn", "t", "need", "to", "be", "static", "since", "this", "is", "only", "created", "once" ]
beb02aef78736a4f799aaac001c8f0327bf0536c
https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/finder/ClassServiceUtility.java#L55-L84
train
jbundle/osgi
core/src/main/java/org/jbundle/util/osgi/finder/ClassServiceUtility.java
ClassServiceUtility.getResourceBundle
public final ResourceBundle getResourceBundle(String className, Locale locale, String version, ClassLoader classLoader) throws MissingResourceException { MissingResourceException ex = null; ResourceBundle resourceBundle = null; try { resourceBundle = ResourceBundle.getBundle(className, locale); } catch (MissingResourceException e) { ex = e; } if (resourceBundle == null) { try { if (this.getClassFinder(null) != null) resourceBundle = this.getClassFinder(null).findResourceBundle(className, locale, version); // Try to find this class in the obr repos } catch (MissingResourceException e) { ex = e; } } if (resourceBundle == null) if (ex != null) throw ex; return resourceBundle; }
java
public final ResourceBundle getResourceBundle(String className, Locale locale, String version, ClassLoader classLoader) throws MissingResourceException { MissingResourceException ex = null; ResourceBundle resourceBundle = null; try { resourceBundle = ResourceBundle.getBundle(className, locale); } catch (MissingResourceException e) { ex = e; } if (resourceBundle == null) { try { if (this.getClassFinder(null) != null) resourceBundle = this.getClassFinder(null).findResourceBundle(className, locale, version); // Try to find this class in the obr repos } catch (MissingResourceException e) { ex = e; } } if (resourceBundle == null) if (ex != null) throw ex; return resourceBundle; }
[ "public", "final", "ResourceBundle", "getResourceBundle", "(", "String", "className", ",", "Locale", "locale", ",", "String", "version", ",", "ClassLoader", "classLoader", ")", "throws", "MissingResourceException", "{", "MissingResourceException", "ex", "=", "null", "...
Gets a resource bundle using the specified base name and locale, @param locale the locale for which a resource bundle is desired @param baseName the base name of the resource bundle, a fully qualified class name @exception NullPointerException if <code>baseName</code> or <code>locale</code> is <code>null</code> @exception MissingResourceException if no resource bundle for the specified base name can be found @return a resource bundle for the given base name and locale
[ "Gets", "a", "resource", "bundle", "using", "the", "specified", "base", "name", "and", "locale" ]
beb02aef78736a4f799aaac001c8f0327bf0536c
https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/finder/ClassServiceUtility.java#L195-L220
train
jbundle/osgi
core/src/main/java/org/jbundle/util/osgi/finder/ClassServiceUtility.java
ClassServiceUtility.getFullClassName
public static String getFullClassName(String packageName, String className) { return ClassServiceUtility.getFullClassName(null, packageName, className); }
java
public static String getFullClassName(String packageName, String className) { return ClassServiceUtility.getFullClassName(null, packageName, className); }
[ "public", "static", "String", "getFullClassName", "(", "String", "packageName", ",", "String", "className", ")", "{", "return", "ClassServiceUtility", ".", "getFullClassName", "(", "null", ",", "packageName", ",", "className", ")", ";", "}" ]
If class name starts with '.' append base package.
[ "If", "class", "name", "starts", "with", ".", "append", "base", "package", "." ]
beb02aef78736a4f799aaac001c8f0327bf0536c
https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/finder/ClassServiceUtility.java#L283-L285
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.find
public String find(String name) { String value = null; for (DataBinder top = this; top != null && (value = top.get(name)) == null; top = top.getLower()); return value; }
java
public String find(String name) { String value = null; for (DataBinder top = this; top != null && (value = top.get(name)) == null; top = top.getLower()); return value; }
[ "public", "String", "find", "(", "String", "name", ")", "{", "String", "value", "=", "null", ";", "for", "(", "DataBinder", "top", "=", "this", ";", "top", "!=", "null", "&&", "(", "value", "=", "top", ".", "get", "(", "name", ")", ")", "==", "nu...
Finds a string value from all data binders, starting from the current binder searching downwards. @param name the name of the value @return the first value found
[ "Finds", "a", "string", "value", "from", "all", "data", "binders", "starting", "from", "the", "current", "binder", "searching", "downwards", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L67-L71
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.put
public String put(String name, String value, String alternative) { return put(name, value != null ? value : alternative); }
java
public String put(String name, String value, String alternative) { return put(name, value != null ? value : alternative); }
[ "public", "String", "put", "(", "String", "name", ",", "String", "value", ",", "String", "alternative", ")", "{", "return", "put", "(", "name", ",", "value", "!=", "null", "?", "value", ":", "alternative", ")", ";", "}" ]
Puts a new string value into this binder, but using an alternative value if the given one is null.
[ "Puts", "a", "new", "string", "value", "into", "this", "binder", "but", "using", "an", "alternative", "value", "if", "the", "given", "one", "is", "null", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L76-L78
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.putResultSet
public CachedResultSet putResultSet(String name, CachedResultSet rs) { return _rsets.put(name, rs); }
java
public CachedResultSet putResultSet(String name, CachedResultSet rs) { return _rsets.put(name, rs); }
[ "public", "CachedResultSet", "putResultSet", "(", "String", "name", ",", "CachedResultSet", "rs", ")", "{", "return", "_rsets", ".", "put", "(", "name", ",", "rs", ")", ";", "}" ]
Puts a new result set into this binder.
[ "Puts", "a", "new", "result", "set", "into", "this", "binder", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L83-L85
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.putNamedObject
@SuppressWarnings("unchecked") public <T, V> T putNamedObject(String name, V object) { return (T)_named.put(name, object); }
java
@SuppressWarnings("unchecked") public <T, V> T putNamedObject(String name, V object) { return (T)_named.put(name, object); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ",", "V", ">", "T", "putNamedObject", "(", "String", "name", ",", "V", "object", ")", "{", "return", "(", "T", ")", "_named", ".", "put", "(", "name", ",", "object", ")", ";", ...
Puts a named object into this binder returning the original object under the name, if any.
[ "Puts", "a", "named", "object", "into", "this", "binder", "returning", "the", "original", "object", "under", "the", "name", "if", "any", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L104-L107
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.getNamedObject
@SuppressWarnings("unchecked") public <T> T getNamedObject(String name) { return (T)_named.get(name); }
java
@SuppressWarnings("unchecked") public <T> T getNamedObject(String name) { return (T)_named.get(name); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "getNamedObject", "(", "String", "name", ")", "{", "return", "(", "T", ")", "_named", ".", "get", "(", "name", ")", ";", "}" ]
Retrieves a named object from this binder.
[ "Retrieves", "a", "named", "object", "from", "this", "binder", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L112-L115
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.getNamedObject
public <T> T getNamedObject(String name, Class<T> type) { return type.cast(_named.get(name)); }
java
public <T> T getNamedObject(String name, Class<T> type) { return type.cast(_named.get(name)); }
[ "public", "<", "T", ">", "T", "getNamedObject", "(", "String", "name", ",", "Class", "<", "T", ">", "type", ")", "{", "return", "type", ".", "cast", "(", "_named", ".", "get", "(", "name", ")", ")", ";", "}" ]
Retrieves a named object of a specific type from this binder.
[ "Retrieves", "a", "named", "object", "of", "a", "specific", "type", "from", "this", "binder", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L120-L122
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.map
public <K, V> Map<K, V> map(String name, Class<K> ktype, Class<V> vtype) { Map<K, V> map = getNamedObject(name); if (map == null) putNamedObject(name, map = new HashMap<K, V>()); return map; }
java
public <K, V> Map<K, V> map(String name, Class<K> ktype, Class<V> vtype) { Map<K, V> map = getNamedObject(name); if (map == null) putNamedObject(name, map = new HashMap<K, V>()); return map; }
[ "public", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "map", "(", "String", "name", ",", "Class", "<", "K", ">", "ktype", ",", "Class", "<", "V", ">", "vtype", ")", "{", "Map", "<", "K", ",", "V", ">", "map", "=", "getNamedObje...
Introduces a HashMap under the given name if one does not exist yet.
[ "Introduces", "a", "HashMap", "under", "the", "given", "name", "if", "one", "does", "not", "exist", "yet", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L134-L138
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.mul
public <K, V> Multimap<K, V> mul(String name, Class<K> ktype, Class<V> vtype) { Multimap<K, V> map = getNamedObject(name); if (map == null) putNamedObject(name, map = new Multimap<K, V>()); return map; }
java
public <K, V> Multimap<K, V> mul(String name, Class<K> ktype, Class<V> vtype) { Multimap<K, V> map = getNamedObject(name); if (map == null) putNamedObject(name, map = new Multimap<K, V>()); return map; }
[ "public", "<", "K", ",", "V", ">", "Multimap", "<", "K", ",", "V", ">", "mul", "(", "String", "name", ",", "Class", "<", "K", ">", "ktype", ",", "Class", "<", "V", ">", "vtype", ")", "{", "Multimap", "<", "K", ",", "V", ">", "map", "=", "ge...
Introduces a Multimap under the given name if one does not exist yet.
[ "Introduces", "a", "Multimap", "under", "the", "given", "name", "if", "one", "does", "not", "exist", "yet", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L143-L147
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.process
@Override public DataBinder process(ResultSet rset) throws Exception { try { if (rset.next()) { ResultSetMetaData meta = rset.getMetaData(); int width = meta.getColumnCount(); for (int i = 1; i <= width; ++i) { Object value = rset.getObject(i); if (value != null) { put(Strings.toLowerCamelCase(meta.getColumnLabel(i), '_'), value.toString()); } } } else { throw new NoSuchElementException("NoSuchRow"); } return this; } finally { rset.close(); } }
java
@Override public DataBinder process(ResultSet rset) throws Exception { try { if (rset.next()) { ResultSetMetaData meta = rset.getMetaData(); int width = meta.getColumnCount(); for (int i = 1; i <= width; ++i) { Object value = rset.getObject(i); if (value != null) { put(Strings.toLowerCamelCase(meta.getColumnLabel(i), '_'), value.toString()); } } } else { throw new NoSuchElementException("NoSuchRow"); } return this; } finally { rset.close(); } }
[ "@", "Override", "public", "DataBinder", "process", "(", "ResultSet", "rset", ")", "throws", "Exception", "{", "try", "{", "if", "(", "rset", ".", "next", "(", ")", ")", "{", "ResultSetMetaData", "meta", "=", "rset", ".", "getMetaData", "(", ")", ";", ...
Fills the data binder with columns in the current row of a result set.
[ "Fills", "the", "data", "binder", "with", "columns", "in", "the", "current", "row", "of", "a", "result", "set", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L152-L171
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.put
public DataBinder put(Object object) throws Exception { for (Field field: Beans.getKnownInstanceFields(object.getClass())) { Object value = field.get(object); if (value != null) { put(field.getName(), value.toString()); } } return this; }
java
public DataBinder put(Object object) throws Exception { for (Field field: Beans.getKnownInstanceFields(object.getClass())) { Object value = field.get(object); if (value != null) { put(field.getName(), value.toString()); } } return this; }
[ "public", "DataBinder", "put", "(", "Object", "object", ")", "throws", "Exception", "{", "for", "(", "Field", "field", ":", "Beans", ".", "getKnownInstanceFields", "(", "object", ".", "getClass", "(", ")", ")", ")", "{", "Object", "value", "=", "field", ...
Fills the data binder with non-static, non-transient fields of an Object, excluding null values.
[ "Fills", "the", "data", "binder", "with", "non", "-", "static", "non", "-", "transient", "fields", "of", "an", "Object", "excluding", "null", "values", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L176-L184
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.put
public <T extends DataObject> DataBinder put(T object, String... names) throws Exception { Class<?> type = object.getClass(); Object value; for (String name: names) { Field field = Beans.getKnownField(type, name); if (!Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers()) && (value = field.get(object)) != null) { put(field.getName(), value.toString()); } } return this; }
java
public <T extends DataObject> DataBinder put(T object, String... names) throws Exception { Class<?> type = object.getClass(); Object value; for (String name: names) { Field field = Beans.getKnownField(type, name); if (!Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers()) && (value = field.get(object)) != null) { put(field.getName(), value.toString()); } } return this; }
[ "public", "<", "T", "extends", "DataObject", ">", "DataBinder", "put", "(", "T", "object", ",", "String", "...", "names", ")", "throws", "Exception", "{", "Class", "<", "?", ">", "type", "=", "object", ".", "getClass", "(", ")", ";", "Object", "value",...
Fills the data binder with a subset of non-static, non-transient fields of an Object, excluding null values. @param names - the names of the fields in the subset
[ "Fills", "the", "data", "binder", "with", "a", "subset", "of", "non", "-", "static", "non", "-", "transient", "fields", "of", "an", "Object", "excluding", "null", "values", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L191-L201
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.load
public DataBinder load(String[] args, int offset) { for (int i = offset; i < args.length; ++i) { int equal = args[i].indexOf('='); if (equal > 0) { put(args[i].substring(0, equal), args[i].substring(equal + 1)); } else { throw new RuntimeException("***InvalidParameter{" + args[i] + '}'); } } return this; }
java
public DataBinder load(String[] args, int offset) { for (int i = offset; i < args.length; ++i) { int equal = args[i].indexOf('='); if (equal > 0) { put(args[i].substring(0, equal), args[i].substring(equal + 1)); } else { throw new RuntimeException("***InvalidParameter{" + args[i] + '}'); } } return this; }
[ "public", "DataBinder", "load", "(", "String", "[", "]", "args", ",", "int", "offset", ")", "{", "for", "(", "int", "i", "=", "offset", ";", "i", "<", "args", ".", "length", ";", "++", "i", ")", "{", "int", "equal", "=", "args", "[", "i", "]", ...
Loads parameters from an array of strings each in the form of name=value.
[ "Loads", "parameters", "from", "an", "array", "of", "strings", "each", "in", "the", "form", "of", "name", "=", "value", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L224-L234
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.load
public DataBinder load(String filename) throws IOException { Properties props = new Properties(); Reader reader = new FileReader(filename); props.load(reader); reader.close(); return load(props); }
java
public DataBinder load(String filename) throws IOException { Properties props = new Properties(); Reader reader = new FileReader(filename); props.load(reader); reader.close(); return load(props); }
[ "public", "DataBinder", "load", "(", "String", "filename", ")", "throws", "IOException", "{", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "Reader", "reader", "=", "new", "FileReader", "(", "filename", ")", ";", "props", ".", "load", "("...
Loads parameters from a property file.
[ "Loads", "parameters", "from", "a", "property", "file", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L239-L245
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.load
public DataBinder load(Properties props) { Enumeration<?> enumeration = props.propertyNames(); while (enumeration.hasMoreElements()) { String key = (String)enumeration.nextElement(); put(key, props.getProperty(key)); } return this; }
java
public DataBinder load(Properties props) { Enumeration<?> enumeration = props.propertyNames(); while (enumeration.hasMoreElements()) { String key = (String)enumeration.nextElement(); put(key, props.getProperty(key)); } return this; }
[ "public", "DataBinder", "load", "(", "Properties", "props", ")", "{", "Enumeration", "<", "?", ">", "enumeration", "=", "props", ".", "propertyNames", "(", ")", ";", "while", "(", "enumeration", ".", "hasMoreElements", "(", ")", ")", "{", "String", "key", ...
Loads parameters from a Properties object.
[ "Loads", "parameters", "from", "a", "Properties", "object", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L250-L257
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.estimateMaximumBytes
public int estimateMaximumBytes() { int count = this.size(); for (String key: _rsets.keySet()) { CachedResultSet crs = _rsets.get(key); if (crs.rows != null) { count += crs.columns.length*crs.rows.size(); } } return count * 64; }
java
public int estimateMaximumBytes() { int count = this.size(); for (String key: _rsets.keySet()) { CachedResultSet crs = _rsets.get(key); if (crs.rows != null) { count += crs.columns.length*crs.rows.size(); } } return count * 64; }
[ "public", "int", "estimateMaximumBytes", "(", ")", "{", "int", "count", "=", "this", ".", "size", "(", ")", ";", "for", "(", "String", "key", ":", "_rsets", ".", "keySet", "(", ")", ")", "{", "CachedResultSet", "crs", "=", "_rsets", ".", "get", "(", ...
Provides a very rough estimate of how big a JSON representative of this binder might be.
[ "Provides", "a", "very", "rough", "estimate", "of", "how", "big", "a", "JSON", "representative", "of", "this", "binder", "might", "be", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L262-L271
train
brianwhu/xillium
data/src/main/java/org/xillium/data/DataBinder.java
DataBinder.toJSON
public String toJSON() { JSONBuilder jb = new JSONBuilder(estimateMaximumBytes()).append('{'); appendParams(jb).append(','); appendTables(jb); jb.append('}'); return jb.toString(); }
java
public String toJSON() { JSONBuilder jb = new JSONBuilder(estimateMaximumBytes()).append('{'); appendParams(jb).append(','); appendTables(jb); jb.append('}'); return jb.toString(); }
[ "public", "String", "toJSON", "(", ")", "{", "JSONBuilder", "jb", "=", "new", "JSONBuilder", "(", "estimateMaximumBytes", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "appendParams", "(", "jb", ")", ".", "append", "(", "'", "'", ")", ";", ...
Returns a JSON string representing the contents of this data binder, excluding named objects.
[ "Returns", "a", "JSON", "string", "representing", "the", "contents", "of", "this", "data", "binder", "excluding", "named", "objects", "." ]
e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/DataBinder.java#L276-L283
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/util/DateUtilities.java
DateUtilities.getDateForHour
private static long getDateForHour(long dt, TimeZone tz, int hour, int dayoffset) { Calendar c = getCalendar(tz); c.setTimeInMillis(dt); int dd = c.get(Calendar.DAY_OF_MONTH); int mm = c.get(Calendar.MONTH); int yy = c.get(Calendar.YEAR); c.set(yy, mm, dd, hour, 0, 0); c.set(Calendar.MILLISECOND, 0); if(dayoffset != 0) c.add(Calendar.DAY_OF_MONTH, dayoffset); return c.getTimeInMillis(); }
java
private static long getDateForHour(long dt, TimeZone tz, int hour, int dayoffset) { Calendar c = getCalendar(tz); c.setTimeInMillis(dt); int dd = c.get(Calendar.DAY_OF_MONTH); int mm = c.get(Calendar.MONTH); int yy = c.get(Calendar.YEAR); c.set(yy, mm, dd, hour, 0, 0); c.set(Calendar.MILLISECOND, 0); if(dayoffset != 0) c.add(Calendar.DAY_OF_MONTH, dayoffset); return c.getTimeInMillis(); }
[ "private", "static", "long", "getDateForHour", "(", "long", "dt", ",", "TimeZone", "tz", ",", "int", "hour", ",", "int", "dayoffset", ")", "{", "Calendar", "c", "=", "getCalendar", "(", "tz", ")", ";", "c", ".", "setTimeInMillis", "(", "dt", ")", ";", ...
Returns the date for the given hour. @param dt The date to be checked @param tz The timezone associated with the date @param hour The hour to be checked @param dayoffset The day of the month to offset @return The date for the given hour
[ "Returns", "the", "date", "for", "the", "given", "hour", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/DateUtilities.java#L175-L187
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/util/DateUtilities.java
DateUtilities.getCalendar
public static Calendar getCalendar(TimeZone tz, Locale locale) { if(tz == null) tz = getCurrentTimeZone(); if(locale == null) locale = getCurrentLocale(); return Calendar.getInstance(tz, locale); }
java
public static Calendar getCalendar(TimeZone tz, Locale locale) { if(tz == null) tz = getCurrentTimeZone(); if(locale == null) locale = getCurrentLocale(); return Calendar.getInstance(tz, locale); }
[ "public", "static", "Calendar", "getCalendar", "(", "TimeZone", "tz", ",", "Locale", "locale", ")", "{", "if", "(", "tz", "==", "null", ")", "tz", "=", "getCurrentTimeZone", "(", ")", ";", "if", "(", "locale", "==", "null", ")", "locale", "=", "getCurr...
Returns a new calendar object using the given timezone and locale. @param tz The timezone associated with the new calendar @param locale The locale associated with the new calendar @return A new calendar object for the given timezone and locale
[ "Returns", "a", "new", "calendar", "object", "using", "the", "given", "timezone", "and", "locale", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/DateUtilities.java#L195-L202
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/util/DateUtilities.java
DateUtilities.getLocale
public static Locale getLocale(String country) { if(country == null || country.length() == 0) country = Locale.getDefault().getCountry(); List<Locale> locales = LocaleUtils.languagesByCountry(country); Locale locale = Locale.getDefault(); if(locales.size() > 0) locale = locales.get(0); // Use the first locale that matches the country return locale; }
java
public static Locale getLocale(String country) { if(country == null || country.length() == 0) country = Locale.getDefault().getCountry(); List<Locale> locales = LocaleUtils.languagesByCountry(country); Locale locale = Locale.getDefault(); if(locales.size() > 0) locale = locales.get(0); // Use the first locale that matches the country return locale; }
[ "public", "static", "Locale", "getLocale", "(", "String", "country", ")", "{", "if", "(", "country", "==", "null", "||", "country", ".", "length", "(", ")", "==", "0", ")", "country", "=", "Locale", ".", "getDefault", "(", ")", ".", "getCountry", "(", ...
Returns the locale for the given country. @param country The country for the locale @return The locale for the given country
[ "Returns", "the", "locale", "for", "the", "given", "country", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/DateUtilities.java#L317-L326
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/util/DateUtilities.java
DateUtilities.setCalendarData
public static void setCalendarData(Calendar calendar, Locale locale) { int[] array = (int[])localeData.get(locale); if(array == null) { Calendar c = Calendar.getInstance(locale); array = new int[2]; array[0] = c.getFirstDayOfWeek(); array[1] = c.getMinimalDaysInFirstWeek(); localeData.putIfAbsent(locale, array); } calendar.setFirstDayOfWeek(array[0]); calendar.setMinimalDaysInFirstWeek(array[1]); }
java
public static void setCalendarData(Calendar calendar, Locale locale) { int[] array = (int[])localeData.get(locale); if(array == null) { Calendar c = Calendar.getInstance(locale); array = new int[2]; array[0] = c.getFirstDayOfWeek(); array[1] = c.getMinimalDaysInFirstWeek(); localeData.putIfAbsent(locale, array); } calendar.setFirstDayOfWeek(array[0]); calendar.setMinimalDaysInFirstWeek(array[1]); }
[ "public", "static", "void", "setCalendarData", "(", "Calendar", "calendar", ",", "Locale", "locale", ")", "{", "int", "[", "]", "array", "=", "(", "int", "[", "]", ")", "localeData", ".", "get", "(", "locale", ")", ";", "if", "(", "array", "==", "nul...
Set the attributes of the given calendar from the given locale. @param calendar The calendar to set the date settings on @param locale The locale to use for the date settings
[ "Set", "the", "attributes", "of", "the", "given", "calendar", "from", "the", "given", "locale", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/DateUtilities.java#L333-L346
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/util/DateUtilities.java
DateUtilities.addDays
public static Date addDays(long dt, int days) { Calendar c = getCalendar(); if(dt > 0L) c.setTimeInMillis(dt); c.add(Calendar.DATE, days); return c.getTime(); }
java
public static Date addDays(long dt, int days) { Calendar c = getCalendar(); if(dt > 0L) c.setTimeInMillis(dt); c.add(Calendar.DATE, days); return c.getTime(); }
[ "public", "static", "Date", "addDays", "(", "long", "dt", ",", "int", "days", ")", "{", "Calendar", "c", "=", "getCalendar", "(", ")", ";", "if", "(", "dt", ">", "0L", ")", "c", ".", "setTimeInMillis", "(", "dt", ")", ";", "c", ".", "add", "(", ...
Returns the given date adding the given number of days. @param dt The date to add the days to @param days The number of days to add. To subtract days, use a negative value. @return The date with the given days added
[ "Returns", "the", "given", "date", "adding", "the", "given", "number", "of", "days", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/DateUtilities.java#L354-L361
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/util/DateUtilities.java
DateUtilities.convertToUtc
public static long convertToUtc(long millis, String tz) { long ret = millis; if(tz != null && tz.length() > 0) { DateTime dt = new DateTime(millis, DateTimeZone.forID(tz)); ret = dt.withZoneRetainFields(DateTimeZone.forID("UTC")).getMillis(); } return ret; }
java
public static long convertToUtc(long millis, String tz) { long ret = millis; if(tz != null && tz.length() > 0) { DateTime dt = new DateTime(millis, DateTimeZone.forID(tz)); ret = dt.withZoneRetainFields(DateTimeZone.forID("UTC")).getMillis(); } return ret; }
[ "public", "static", "long", "convertToUtc", "(", "long", "millis", ",", "String", "tz", ")", "{", "long", "ret", "=", "millis", ";", "if", "(", "tz", "!=", "null", "&&", "tz", ".", "length", "(", ")", ">", "0", ")", "{", "DateTime", "dt", "=", "n...
Returns the given date converted to UTC using the given timezone. @param millis The date to convert @param tz The timezone associated with the date @return The given date converted using the given timezone
[ "Returns", "the", "given", "date", "converted", "to", "UTC", "using", "the", "given", "timezone", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/DateUtilities.java#L379-L388
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/sjavac/server/JavacServer.java
JavacServer.useServer
public static int useServer(String settings, String[] args, Set<URI> sourcesToCompile, Set<URI> visibleSources, Map<URI, Set<String>> visibleClasses, Map<String, Set<URI>> packageArtifacts, Map<String, Set<String>> packageDependencies, Map<String, String> packagePubapis, SysInfo sysinfo, PrintStream out, PrintStream err) { try { // The id can perhaps be used in the future by the javac server to reuse the // JavaCompiler instance for several compiles using the same id. String id = Util.extractStringOption("id", settings); String portfile = Util.extractStringOption("portfile", settings); String logfile = Util.extractStringOption("logfile", settings); String stdouterrfile = Util.extractStringOption("stdouterrfile", settings); String background = Util.extractStringOption("background", settings); if (background == null || !background.equals("false")) { background = "true"; } // The sjavac option specifies how the server part of sjavac is spawned. // If you have the experimental sjavac in your path, you are done. If not, you have // to point to a com.sun.tools.sjavac.Main that supports --startserver // for example by setting: sjavac=java%20-jar%20...javac.jar%com.sun.tools.sjavac.Main String sjavac = Util.extractStringOption("sjavac", settings); int poolsize = Util.extractIntOption("poolsize", settings); int keepalive = Util.extractIntOption("keepalive", settings); if (keepalive <= 0) { // Default keepalive for server is 120 seconds. // I.e. it will accept 120 seconds of inactivity before quitting. keepalive = 120; } if (portfile == null) { err.println("No portfile was specified!"); return -1; } if (logfile == null) { logfile = portfile + ".javaclog"; } if (stdouterrfile == null) { stdouterrfile = portfile + ".stdouterr"; } // Default to sjavac and hope it is in the path. if (sjavac == null) { sjavac = "sjavac"; } int attempts = 0; int rc = -1; do { PortFile port_file = getPortFile(portfile); synchronized (port_file) { port_file.lock(); port_file.getValues(); port_file.unlock(); } if (!port_file.containsPortInfo()) { String cmd = fork(sjavac, port_file.getFilename(), logfile, poolsize, keepalive, err, stdouterrfile, background); if (background.equals("true") && !port_file.waitForValidValues()) { // Ouch the server did not start! Lets print its stdouterrfile and the command used. printFailedAttempt(cmd, stdouterrfile, err); // And give up. return -1; } } rc = connectAndCompile(port_file, id, args, sourcesToCompile, visibleSources, packageArtifacts, packageDependencies, packagePubapis, sysinfo, out, err); // Try again until we manage to connect. Any error after that // will cause the compilation to fail. if (rc == ERROR_BUT_TRY_AGAIN) { // We could not connect to the server. Try again. attempts++; try { Thread.sleep(WAIT_BETWEEN_CONNECT_ATTEMPTS); } catch (InterruptedException e) { } } } while (rc == ERROR_BUT_TRY_AGAIN && attempts < MAX_NUM_CONNECT_ATTEMPTS); return rc; } catch (Exception e) { e.printStackTrace(err); return -1; } }
java
public static int useServer(String settings, String[] args, Set<URI> sourcesToCompile, Set<URI> visibleSources, Map<URI, Set<String>> visibleClasses, Map<String, Set<URI>> packageArtifacts, Map<String, Set<String>> packageDependencies, Map<String, String> packagePubapis, SysInfo sysinfo, PrintStream out, PrintStream err) { try { // The id can perhaps be used in the future by the javac server to reuse the // JavaCompiler instance for several compiles using the same id. String id = Util.extractStringOption("id", settings); String portfile = Util.extractStringOption("portfile", settings); String logfile = Util.extractStringOption("logfile", settings); String stdouterrfile = Util.extractStringOption("stdouterrfile", settings); String background = Util.extractStringOption("background", settings); if (background == null || !background.equals("false")) { background = "true"; } // The sjavac option specifies how the server part of sjavac is spawned. // If you have the experimental sjavac in your path, you are done. If not, you have // to point to a com.sun.tools.sjavac.Main that supports --startserver // for example by setting: sjavac=java%20-jar%20...javac.jar%com.sun.tools.sjavac.Main String sjavac = Util.extractStringOption("sjavac", settings); int poolsize = Util.extractIntOption("poolsize", settings); int keepalive = Util.extractIntOption("keepalive", settings); if (keepalive <= 0) { // Default keepalive for server is 120 seconds. // I.e. it will accept 120 seconds of inactivity before quitting. keepalive = 120; } if (portfile == null) { err.println("No portfile was specified!"); return -1; } if (logfile == null) { logfile = portfile + ".javaclog"; } if (stdouterrfile == null) { stdouterrfile = portfile + ".stdouterr"; } // Default to sjavac and hope it is in the path. if (sjavac == null) { sjavac = "sjavac"; } int attempts = 0; int rc = -1; do { PortFile port_file = getPortFile(portfile); synchronized (port_file) { port_file.lock(); port_file.getValues(); port_file.unlock(); } if (!port_file.containsPortInfo()) { String cmd = fork(sjavac, port_file.getFilename(), logfile, poolsize, keepalive, err, stdouterrfile, background); if (background.equals("true") && !port_file.waitForValidValues()) { // Ouch the server did not start! Lets print its stdouterrfile and the command used. printFailedAttempt(cmd, stdouterrfile, err); // And give up. return -1; } } rc = connectAndCompile(port_file, id, args, sourcesToCompile, visibleSources, packageArtifacts, packageDependencies, packagePubapis, sysinfo, out, err); // Try again until we manage to connect. Any error after that // will cause the compilation to fail. if (rc == ERROR_BUT_TRY_AGAIN) { // We could not connect to the server. Try again. attempts++; try { Thread.sleep(WAIT_BETWEEN_CONNECT_ATTEMPTS); } catch (InterruptedException e) { } } } while (rc == ERROR_BUT_TRY_AGAIN && attempts < MAX_NUM_CONNECT_ATTEMPTS); return rc; } catch (Exception e) { e.printStackTrace(err); return -1; } }
[ "public", "static", "int", "useServer", "(", "String", "settings", ",", "String", "[", "]", "args", ",", "Set", "<", "URI", ">", "sourcesToCompile", ",", "Set", "<", "URI", ">", "visibleSources", ",", "Map", "<", "URI", ",", "Set", "<", "String", ">", ...
Dispatch a compilation request to a javac server. @param args are the command line args to javac and is allowed to contain source files, @file and other command line options to javac. The generated classes, h files and other artifacts from the javac invocation are stored by the javac server to disk. @param sources_to_compile The sources to compile. @param visibleSources If visible sources has a non zero size, then visible_sources are the only files in the file system that the javac server can see! (Sources to compile are always visible.) The visible sources are those supplied by the (filtered) -sourcepath @param visibleClasses If visible classes for a specific root/jar has a non zero size, then visible_classes are the only class files that the javac server can see, in that root/jar. It maps from a classpath root or a jar file to the set of visible classes for that root/jar. The server return meta data about the build in the following parameters. @param package_artifacts, map from package name to set of created artifacts for that package. @param package_dependencies, map from package name to set of packages that it depends upon. @param package_pubapis, map from package name to unique string identifying its pub api.
[ "Dispatch", "a", "compilation", "request", "to", "a", "javac", "server", "." ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java#L231-L318
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/sjavac/server/JavacServer.java
JavacServer.fork
private static String fork(String sjavac, String portfile, String logfile, int poolsize, int keepalive, final PrintStream err, String stdouterrfile, String background) throws IOException, ProblemException { if (stdouterrfile != null && stdouterrfile.trim().equals("")) { stdouterrfile = null; } final String startserver = "--startserver:portfile=" + portfile + ",logfile=" + logfile + ",stdouterrfile=" + stdouterrfile + ",poolsize=" + poolsize + ",keepalive="+ keepalive; if (background.equals("true")) { sjavac += "%20" + startserver; sjavac = sjavac.replaceAll("%20", " "); sjavac = sjavac.replaceAll("%2C", ","); // If the java/sh/cmd launcher fails the failure will be captured by stdouterr because of the redirection here. String[] cmd = {"/bin/sh", "-c", sjavac + " >> " + stdouterrfile + " 2>&1"}; if (!(new File("/bin/sh")).canExecute()) { ArrayList<String> wincmd = new ArrayList<String>(); wincmd.add("cmd"); wincmd.add("/c"); wincmd.add("start"); wincmd.add("cmd"); wincmd.add("/c"); wincmd.add(sjavac + " >> " + stdouterrfile + " 2>&1"); cmd = wincmd.toArray(new String[wincmd.size()]); } Process pp = null; try { pp = Runtime.getRuntime().exec(cmd); } catch (Exception e) { e.printStackTrace(err); e.printStackTrace(new PrintWriter(stdouterrfile)); } StringBuilder rs = new StringBuilder(); for (String s : cmd) { rs.append(s + " "); } return rs.toString(); } // Do not spawn a background server, instead run it within the same JVM. Thread t = new Thread() { @Override public void run() { try { JavacServer.startServer(startserver, err); } catch (Throwable t) { t.printStackTrace(err); } } }; t.start(); return ""; }
java
private static String fork(String sjavac, String portfile, String logfile, int poolsize, int keepalive, final PrintStream err, String stdouterrfile, String background) throws IOException, ProblemException { if (stdouterrfile != null && stdouterrfile.trim().equals("")) { stdouterrfile = null; } final String startserver = "--startserver:portfile=" + portfile + ",logfile=" + logfile + ",stdouterrfile=" + stdouterrfile + ",poolsize=" + poolsize + ",keepalive="+ keepalive; if (background.equals("true")) { sjavac += "%20" + startserver; sjavac = sjavac.replaceAll("%20", " "); sjavac = sjavac.replaceAll("%2C", ","); // If the java/sh/cmd launcher fails the failure will be captured by stdouterr because of the redirection here. String[] cmd = {"/bin/sh", "-c", sjavac + " >> " + stdouterrfile + " 2>&1"}; if (!(new File("/bin/sh")).canExecute()) { ArrayList<String> wincmd = new ArrayList<String>(); wincmd.add("cmd"); wincmd.add("/c"); wincmd.add("start"); wincmd.add("cmd"); wincmd.add("/c"); wincmd.add(sjavac + " >> " + stdouterrfile + " 2>&1"); cmd = wincmd.toArray(new String[wincmd.size()]); } Process pp = null; try { pp = Runtime.getRuntime().exec(cmd); } catch (Exception e) { e.printStackTrace(err); e.printStackTrace(new PrintWriter(stdouterrfile)); } StringBuilder rs = new StringBuilder(); for (String s : cmd) { rs.append(s + " "); } return rs.toString(); } // Do not spawn a background server, instead run it within the same JVM. Thread t = new Thread() { @Override public void run() { try { JavacServer.startServer(startserver, err); } catch (Throwable t) { t.printStackTrace(err); } } }; t.start(); return ""; }
[ "private", "static", "String", "fork", "(", "String", "sjavac", ",", "String", "portfile", ",", "String", "logfile", ",", "int", "poolsize", ",", "int", "keepalive", ",", "final", "PrintStream", "err", ",", "String", "stdouterrfile", ",", "String", "background...
Fork a background process. Returns the command line used that can be printed if something failed.
[ "Fork", "a", "background", "process", ".", "Returns", "the", "command", "line", "used", "that", "can", "be", "printed", "if", "something", "failed", "." ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java#L359-L410
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/sjavac/server/JavacServer.java
JavacServer.connectGetSysInfo
public static SysInfo connectGetSysInfo(String serverSettings, PrintStream out, PrintStream err) { SysInfo sysinfo = new SysInfo(-1, -1); String id = Util.extractStringOption("id", serverSettings); String portfile = Util.extractStringOption("portfile", serverSettings); try { PortFile pf = getPortFile(portfile); useServer(serverSettings, new String[0], new HashSet<URI>(), new HashSet<URI>(), new HashMap<URI, Set<String>>(), new HashMap<String, Set<URI>>(), new HashMap<String, Set<String>>(), new HashMap<String, String>(), sysinfo, out, err); } catch (Exception e) { e.printStackTrace(err); } return sysinfo; }
java
public static SysInfo connectGetSysInfo(String serverSettings, PrintStream out, PrintStream err) { SysInfo sysinfo = new SysInfo(-1, -1); String id = Util.extractStringOption("id", serverSettings); String portfile = Util.extractStringOption("portfile", serverSettings); try { PortFile pf = getPortFile(portfile); useServer(serverSettings, new String[0], new HashSet<URI>(), new HashSet<URI>(), new HashMap<URI, Set<String>>(), new HashMap<String, Set<URI>>(), new HashMap<String, Set<String>>(), new HashMap<String, String>(), sysinfo, out, err); } catch (Exception e) { e.printStackTrace(err); } return sysinfo; }
[ "public", "static", "SysInfo", "connectGetSysInfo", "(", "String", "serverSettings", ",", "PrintStream", "out", ",", "PrintStream", "err", ")", "{", "SysInfo", "sysinfo", "=", "new", "SysInfo", "(", "-", "1", ",", "-", "1", ")", ";", "String", "id", "=", ...
Make a request to the server only to get the maximum possible heap size to use for compilations. @param port_file The port file used to synchronize creation of this server. @param id The identify of the compilation. @param out Standard out information. @param err Standard err information. @return The maximum heap size in bytes.
[ "Make", "a", "request", "to", "the", "server", "only", "to", "get", "the", "maximum", "possible", "heap", "size", "to", "use", "for", "compilations", "." ]
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java#L432-L450
train
wmdietl/jsr308-langtools
src/share/classes/com/sun/tools/sjavac/server/JavacServer.java
JavacServer.run
private void run(PortFile portFile, PrintStream err, int keepalive) { boolean fileDeleted = false; long timeSinceLastCompile; try { // Every 5 second (check_portfile_interval) we test if the portfile has disappeared => quit // Or if the last request was finished more than 125 seconds ago => quit // 125 = seconds_of_inactivity_before_shutdown+check_portfile_interval serverSocket.setSoTimeout(CHECK_PORTFILE_INTERVAL*1000); for (;;) { try { Socket s = serverSocket.accept(); CompilerThread ct = compilerPool.grabCompilerThread(); ct.setSocket(s); compilerPool.execute(ct); flushLog(); } catch (java.net.SocketTimeoutException e) { if (compilerPool.numActiveRequests() > 0) { // Never quit while there are active requests! continue; } // If this is the timeout after the portfile // has been deleted by us. Then we truly stop. if (fileDeleted) { log("Quitting because of "+(keepalive+CHECK_PORTFILE_INTERVAL)+" seconds of inactivity!"); break; } // Check if the portfile is still there. if (!portFile.exists()) { // Time to quit because the portfile was deleted by another // process, probably by the makefile that is done building. log("Quitting because portfile was deleted!"); flushLog(); break; } // Check if portfile.stop is still there. if (portFile.markedForStop()) { // Time to quit because another process touched the file // server.port.stop to signal that the server should stop. // This is necessary on some operating systems that lock // the port file hard! log("Quitting because a portfile.stop file was found!"); portFile.delete(); flushLog(); break; } // Does the portfile still point to me? if (!portFile.stillMyValues()) { // Time to quit because another build has started. log("Quitting because portfile is now owned by another javac server!"); flushLog(); break; } // Check how long since the last request finished. long diff = System.currentTimeMillis() - compilerPool.lastRequestFinished(); if (diff < keepalive * 1000) { // Do not quit if we have waited less than 120 seconds. continue; } // Ok, time to quit because of inactivity. Perhaps the build // was killed and the portfile not cleaned up properly. portFile.delete(); fileDeleted = true; log("" + keepalive + " seconds of inactivity quitting in " + CHECK_PORTFILE_INTERVAL + " seconds!"); flushLog(); // Now we have a second 5 second grace // period where javac remote requests // that have loaded the data from the // recently deleted portfile can connect // and complete their requests. } } } catch (Exception e) { e.printStackTrace(err); e.printStackTrace(theLog); flushLog(); } finally { compilerPool.shutdown(); } long realTime = System.currentTimeMillis() - serverStart; log("Shutting down."); log("Total wall clock time " + realTime + "ms build time " + totalBuildTime + "ms"); flushLog(); }
java
private void run(PortFile portFile, PrintStream err, int keepalive) { boolean fileDeleted = false; long timeSinceLastCompile; try { // Every 5 second (check_portfile_interval) we test if the portfile has disappeared => quit // Or if the last request was finished more than 125 seconds ago => quit // 125 = seconds_of_inactivity_before_shutdown+check_portfile_interval serverSocket.setSoTimeout(CHECK_PORTFILE_INTERVAL*1000); for (;;) { try { Socket s = serverSocket.accept(); CompilerThread ct = compilerPool.grabCompilerThread(); ct.setSocket(s); compilerPool.execute(ct); flushLog(); } catch (java.net.SocketTimeoutException e) { if (compilerPool.numActiveRequests() > 0) { // Never quit while there are active requests! continue; } // If this is the timeout after the portfile // has been deleted by us. Then we truly stop. if (fileDeleted) { log("Quitting because of "+(keepalive+CHECK_PORTFILE_INTERVAL)+" seconds of inactivity!"); break; } // Check if the portfile is still there. if (!portFile.exists()) { // Time to quit because the portfile was deleted by another // process, probably by the makefile that is done building. log("Quitting because portfile was deleted!"); flushLog(); break; } // Check if portfile.stop is still there. if (portFile.markedForStop()) { // Time to quit because another process touched the file // server.port.stop to signal that the server should stop. // This is necessary on some operating systems that lock // the port file hard! log("Quitting because a portfile.stop file was found!"); portFile.delete(); flushLog(); break; } // Does the portfile still point to me? if (!portFile.stillMyValues()) { // Time to quit because another build has started. log("Quitting because portfile is now owned by another javac server!"); flushLog(); break; } // Check how long since the last request finished. long diff = System.currentTimeMillis() - compilerPool.lastRequestFinished(); if (diff < keepalive * 1000) { // Do not quit if we have waited less than 120 seconds. continue; } // Ok, time to quit because of inactivity. Perhaps the build // was killed and the portfile not cleaned up properly. portFile.delete(); fileDeleted = true; log("" + keepalive + " seconds of inactivity quitting in " + CHECK_PORTFILE_INTERVAL + " seconds!"); flushLog(); // Now we have a second 5 second grace // period where javac remote requests // that have loaded the data from the // recently deleted portfile can connect // and complete their requests. } } } catch (Exception e) { e.printStackTrace(err); e.printStackTrace(theLog); flushLog(); } finally { compilerPool.shutdown(); } long realTime = System.currentTimeMillis() - serverStart; log("Shutting down."); log("Total wall clock time " + realTime + "ms build time " + totalBuildTime + "ms"); flushLog(); }
[ "private", "void", "run", "(", "PortFile", "portFile", ",", "PrintStream", "err", ",", "int", "keepalive", ")", "{", "boolean", "fileDeleted", "=", "false", ";", "long", "timeSinceLastCompile", ";", "try", "{", "// Every 5 second (check_portfile_interval) we test if t...
Run the server thread until it exits. Either because of inactivity or because the port file has been deleted by someone else, or overtaken by some other javac server.
[ "Run", "the", "server", "thread", "until", "it", "exits", ".", "Either", "because", "of", "inactivity", "or", "because", "the", "port", "file", "has", "been", "deleted", "by", "someone", "else", "or", "overtaken", "by", "some", "other", "javac", "server", ...
8812d28c20f4de070a0dd6de1b45602431379834
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java#L653-L737
train
koendeschacht/bow-utils
src/main/java/be/bagofwords/util/SocketConnection.java
SocketConnection.writeValue
public <T extends Object> void writeValue(T value) throws IOException { writeValue(value, (Class<T>) value.getClass()); }
java
public <T extends Object> void writeValue(T value) throws IOException { writeValue(value, (Class<T>) value.getClass()); }
[ "public", "<", "T", "extends", "Object", ">", "void", "writeValue", "(", "T", "value", ")", "throws", "IOException", "{", "writeValue", "(", "value", ",", "(", "Class", "<", "T", ">", ")", "value", ".", "getClass", "(", ")", ")", ";", "}" ]
Value can not be null
[ "Value", "can", "not", "be", "null" ]
f599da17cb7a40b8ffc5610a9761fa922e99d7cb
https://github.com/koendeschacht/bow-utils/blob/f599da17cb7a40b8ffc5610a9761fa922e99d7cb/src/main/java/be/bagofwords/util/SocketConnection.java#L271-L273
train
pierre/serialization
thrift/src/main/java/com/ning/metrics/serialization/event/ThriftEnvelopeEvent.java
ThriftEnvelopeEvent.deserializeFromStream
private void deserializeFromStream(final InputStream in) throws IOException { final byte[] dateTimeBytes = new byte[8]; in.read(dateTimeBytes, 0, 8); eventDateTime = new DateTime(ByteBuffer.wrap(dateTimeBytes).getLong(0)); final byte[] sizeGranularityInBytes = new byte[4]; in.read(sizeGranularityInBytes, 0, 4); final byte[] granularityBytes = new byte[ByteBuffer.wrap(sizeGranularityInBytes).getInt(0)]; in.read(granularityBytes, 0, granularityBytes.length); granularity = Granularity.valueOf(new String(granularityBytes, Charset.forName("UTF-8"))); thriftEnvelope = deserializer.deserialize(null); }
java
private void deserializeFromStream(final InputStream in) throws IOException { final byte[] dateTimeBytes = new byte[8]; in.read(dateTimeBytes, 0, 8); eventDateTime = new DateTime(ByteBuffer.wrap(dateTimeBytes).getLong(0)); final byte[] sizeGranularityInBytes = new byte[4]; in.read(sizeGranularityInBytes, 0, 4); final byte[] granularityBytes = new byte[ByteBuffer.wrap(sizeGranularityInBytes).getInt(0)]; in.read(granularityBytes, 0, granularityBytes.length); granularity = Granularity.valueOf(new String(granularityBytes, Charset.forName("UTF-8"))); thriftEnvelope = deserializer.deserialize(null); }
[ "private", "void", "deserializeFromStream", "(", "final", "InputStream", "in", ")", "throws", "IOException", "{", "final", "byte", "[", "]", "dateTimeBytes", "=", "new", "byte", "[", "8", "]", ";", "in", ".", "read", "(", "dateTimeBytes", ",", "0", ",", ...
Given an InputStream, extract the eventDateTime, granularity and thriftEnvelope to build the ThriftEnvelopeEvent. This method expects the stream to be open and won't close it for you. @param in InputStream to read @throws IOException generic I/O Exception
[ "Given", "an", "InputStream", "extract", "the", "eventDateTime", "granularity", "and", "thriftEnvelope", "to", "build", "the", "ThriftEnvelopeEvent", ".", "This", "method", "expects", "the", "stream", "to", "be", "open", "and", "won", "t", "close", "it", "for", ...
b15b7c749ba78bfe94dce8fc22f31b30b2e6830b
https://github.com/pierre/serialization/blob/b15b7c749ba78bfe94dce8fc22f31b30b2e6830b/thrift/src/main/java/com/ning/metrics/serialization/event/ThriftEnvelopeEvent.java#L150-L163
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/provider/newrelic/ApplicationInstanceCache.java
ApplicationInstanceCache.add
public void add(Collection<ApplicationInstance> applicationInstances) { for(ApplicationInstance applicationInstance : applicationInstances) this.applicationInstances.put(applicationInstance.getId(), applicationInstance); }
java
public void add(Collection<ApplicationInstance> applicationInstances) { for(ApplicationInstance applicationInstance : applicationInstances) this.applicationInstances.put(applicationInstance.getId(), applicationInstance); }
[ "public", "void", "add", "(", "Collection", "<", "ApplicationInstance", ">", "applicationInstances", ")", "{", "for", "(", "ApplicationInstance", "applicationInstance", ":", "applicationInstances", ")", "this", ".", "applicationInstances", ".", "put", "(", "applicatio...
Adds the application instance list to the application instances for the account. @param applicationInstances The application instances to add
[ "Adds", "the", "application", "instance", "list", "to", "the", "application", "instances", "for", "the", "account", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/ApplicationInstanceCache.java#L67-L71
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/util/DateFormatPool.java
DateFormatPool.get
public Object get() { synchronized(this) { if (freePool.isEmpty() || usedPool.size() >= capacity) { try { wait(1000); } catch (InterruptedException e) { } // The timeout value was reached if (freePool.isEmpty()) add(new SimpleDateFormat()); } Object o = freePool.get(0); freePool.remove(o); usedPool.add(o); return o; } }
java
public Object get() { synchronized(this) { if (freePool.isEmpty() || usedPool.size() >= capacity) { try { wait(1000); } catch (InterruptedException e) { } // The timeout value was reached if (freePool.isEmpty()) add(new SimpleDateFormat()); } Object o = freePool.get(0); freePool.remove(o); usedPool.add(o); return o; } }
[ "public", "Object", "get", "(", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "freePool", ".", "isEmpty", "(", ")", "||", "usedPool", ".", "size", "(", ")", ">=", "capacity", ")", "{", "try", "{", "wait", "(", "1000", ")", ";", "}",...
Retrieve a resource from the pool of free resources. @return The next available resource from the pool
[ "Retrieve", "a", "resource", "from", "the", "pool", "of", "free", "resources", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/DateFormatPool.java#L70-L94
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/util/DateFormatPool.java
DateFormatPool.getFormat
public SimpleDateFormat getFormat(String format) { SimpleDateFormat f = (SimpleDateFormat)get(); f.applyPattern(format); return f; }
java
public SimpleDateFormat getFormat(String format) { SimpleDateFormat f = (SimpleDateFormat)get(); f.applyPattern(format); return f; }
[ "public", "SimpleDateFormat", "getFormat", "(", "String", "format", ")", "{", "SimpleDateFormat", "f", "=", "(", "SimpleDateFormat", ")", "get", "(", ")", ";", "f", ".", "applyPattern", "(", "format", ")", ";", "return", "f", ";", "}" ]
Retrieve a date format from the pool of free resources. @param format The date format to apply to the resource returned @return The next available date format from the pool of free resources
[ "Retrieve", "a", "date", "format", "from", "the", "pool", "of", "free", "resources", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/DateFormatPool.java#L101-L106
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/util/DateFormatPool.java
DateFormatPool.release
public void release(Object o) { synchronized(this) { usedPool.remove(o); freePool.add(o); notify(); } }
java
public void release(Object o) { synchronized(this) { usedPool.remove(o); freePool.add(o); notify(); } }
[ "public", "void", "release", "(", "Object", "o", ")", "{", "synchronized", "(", "this", ")", "{", "usedPool", ".", "remove", "(", "o", ")", ";", "freePool", ".", "add", "(", "o", ")", ";", "notify", "(", ")", ";", "}", "}" ]
Release a resource and put it back in the pool of free resources. @param o The object to return to the pool
[ "Release", "a", "resource", "and", "put", "it", "back", "in", "the", "pool", "of", "free", "resources", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/DateFormatPool.java#L112-L120
train
mcpat/microjiac-public
tools/microjiac-midlet-maven-plugin/src/main/java/de/jiac/micro/mojo/ConfiguratorMojo.java
ConfiguratorMojo.execute
public void execute() throws MojoExecutionException { ClassLoader classloader; try { classloader= createClassLoader(); } catch (Exception e) { throw new MojoExecutionException("could not create classloader from dependencies", e); } AbstractConfiguration[] configurations; try { configurations= ConfigurationGenerator.execute(generatedSourceDirectory, applicationDefinition, classloader, getSLF4JLogger()); } catch (Exception e) { throw new MojoExecutionException("could not generate the configurator", e); } getPluginContext().put(GENERATED_CONFIGURATIONS_KEY, configurations); project.addCompileSourceRoot(generatedSourceDirectory.getPath()); }
java
public void execute() throws MojoExecutionException { ClassLoader classloader; try { classloader= createClassLoader(); } catch (Exception e) { throw new MojoExecutionException("could not create classloader from dependencies", e); } AbstractConfiguration[] configurations; try { configurations= ConfigurationGenerator.execute(generatedSourceDirectory, applicationDefinition, classloader, getSLF4JLogger()); } catch (Exception e) { throw new MojoExecutionException("could not generate the configurator", e); } getPluginContext().put(GENERATED_CONFIGURATIONS_KEY, configurations); project.addCompileSourceRoot(generatedSourceDirectory.getPath()); }
[ "public", "void", "execute", "(", ")", "throws", "MojoExecutionException", "{", "ClassLoader", "classloader", ";", "try", "{", "classloader", "=", "createClassLoader", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "MojoExecution...
Processes all dependencies first and then creates a new JVM to generate the configurator implementation with.
[ "Processes", "all", "dependencies", "first", "and", "then", "creates", "a", "new", "JVM", "to", "generate", "the", "configurator", "implementation", "with", "." ]
3c649e44846981a68e84cc4578719532414d8d35
https://github.com/mcpat/microjiac-public/blob/3c649e44846981a68e84cc4578719532414d8d35/tools/microjiac-midlet-maven-plugin/src/main/java/de/jiac/micro/mojo/ConfiguratorMojo.java#L185-L204
train
wanglinsong/thx-android
uia-client/src/main/java/com/android/uiautomator/stub/Rect.java
Rect.toShortString
public String toShortString(StringBuilder sb) { sb.setLength(0); sb.append('['); sb.append(left); sb.append(','); sb.append(top); sb.append("]["); sb.append(right); sb.append(','); sb.append(bottom); sb.append(']'); return sb.toString(); }
java
public String toShortString(StringBuilder sb) { sb.setLength(0); sb.append('['); sb.append(left); sb.append(','); sb.append(top); sb.append("]["); sb.append(right); sb.append(','); sb.append(bottom); sb.append(']'); return sb.toString(); }
[ "public", "String", "toShortString", "(", "StringBuilder", "sb", ")", "{", "sb", ".", "setLength", "(", "0", ")", ";", "sb", ".", "append", "(", "'", "'", ")", ";", "sb", ".", "append", "(", "left", ")", ";", "sb", ".", "append", "(", "'", "'", ...
Return a string representation of the rectangle in a compact form. @param sb sb @return string
[ "Return", "a", "string", "representation", "of", "the", "rectangle", "in", "a", "compact", "form", "." ]
4a98c4181b3e8876e688591737da37627c07e72b
https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/Rect.java#L138-L150
train
wanglinsong/thx-android
uia-client/src/main/java/com/android/uiautomator/stub/Rect.java
Rect.flattenToString
public String flattenToString() { StringBuilder sb = new StringBuilder(32); // WARNING: Do not change the format of this string, it must be // preserved because Rects are saved in this flattened format. sb.append(left); sb.append(' '); sb.append(top); sb.append(' '); sb.append(right); sb.append(' '); sb.append(bottom); return sb.toString(); }
java
public String flattenToString() { StringBuilder sb = new StringBuilder(32); // WARNING: Do not change the format of this string, it must be // preserved because Rects are saved in this flattened format. sb.append(left); sb.append(' '); sb.append(top); sb.append(' '); sb.append(right); sb.append(' '); sb.append(bottom); return sb.toString(); }
[ "public", "String", "flattenToString", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "32", ")", ";", "// WARNING: Do not change the format of this string, it must be", "// preserved because Rects are saved in this flattened format.", "sb", ".", "append...
Return a string representation of the rectangle in a well-defined format. You can later recover the Rect from this string through {@link #unflattenFromString(String)}. @return Returns a new String of the form "left top right bottom"
[ "Return", "a", "string", "representation", "of", "the", "rectangle", "in", "a", "well", "-", "defined", "format", "." ]
4a98c4181b3e8876e688591737da37627c07e72b
https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/Rect.java#L160-L172
train
wanglinsong/thx-android
uia-client/src/main/java/com/android/uiautomator/stub/Rect.java
Rect.set
public void set(Rect src) { this.left = src.left; this.top = src.top; this.right = src.right; this.bottom = src.bottom; }
java
public void set(Rect src) { this.left = src.left; this.top = src.top; this.right = src.right; this.bottom = src.bottom; }
[ "public", "void", "set", "(", "Rect", "src", ")", "{", "this", ".", "left", "=", "src", ".", "left", ";", "this", ".", "top", "=", "src", ".", "top", ";", "this", ".", "right", "=", "src", ".", "right", ";", "this", ".", "bottom", "=", "src", ...
Copy the coordinates from src into this rectangle. @param src The rectangle whose coordinates are copied into this rectangle.
[ "Copy", "the", "coordinates", "from", "src", "into", "this", "rectangle", "." ]
4a98c4181b3e8876e688591737da37627c07e72b
https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/Rect.java#L280-L285
train
wanglinsong/thx-android
uia-client/src/main/java/com/android/uiautomator/stub/Rect.java
Rect.offset
public void offset(int dx, int dy) { left += dx; top += dy; right += dx; bottom += dy; }
java
public void offset(int dx, int dy) { left += dx; top += dy; right += dx; bottom += dy; }
[ "public", "void", "offset", "(", "int", "dx", ",", "int", "dy", ")", "{", "left", "+=", "dx", ";", "top", "+=", "dy", ";", "right", "+=", "dx", ";", "bottom", "+=", "dy", ";", "}" ]
Offset the rectangle by adding dx to its left and right coordinates, and adding dy to its top and bottom coordinates. @param dx The amount to add to the rectangle's left and right coordinates @param dy The amount to add to the rectangle's top and bottom coordinates
[ "Offset", "the", "rectangle", "by", "adding", "dx", "to", "its", "left", "and", "right", "coordinates", "and", "adding", "dy", "to", "its", "top", "and", "bottom", "coordinates", "." ]
4a98c4181b3e8876e688591737da37627c07e72b
https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/Rect.java#L294-L299
train
wanglinsong/thx-android
uia-client/src/main/java/com/android/uiautomator/stub/Rect.java
Rect.contains
public boolean contains(int left, int top, int right, int bottom) { // check for empty first return this.left < this.right && this.top < this.bottom // now check for containment && this.left <= left && this.top <= top && this.right >= right && this.bottom >= bottom; }
java
public boolean contains(int left, int top, int right, int bottom) { // check for empty first return this.left < this.right && this.top < this.bottom // now check for containment && this.left <= left && this.top <= top && this.right >= right && this.bottom >= bottom; }
[ "public", "boolean", "contains", "(", "int", "left", ",", "int", "top", ",", "int", "right", ",", "int", "bottom", ")", "{", "// check for empty first", "return", "this", ".", "left", "<", "this", ".", "right", "&&", "this", ".", "top", "<", "this", "....
Returns true iff the 4 specified sides of a rectangle are inside or equal to this rectangle. i.e. is this rectangle a superset of the specified rectangle. An empty rectangle never contains another rectangle. @param left The left side of the rectangle being tested for containment @param top The top of the rectangle being tested for containment @param right The right side of the rectangle being tested for containment @param bottom The bottom of the rectangle being tested for containment @return true iff the the 4 specified sides of a rectangle are inside or equal to this rectangle
[ "Returns", "true", "iff", "the", "4", "specified", "sides", "of", "a", "rectangle", "are", "inside", "or", "equal", "to", "this", "rectangle", ".", "i", ".", "e", ".", "is", "this", "rectangle", "a", "superset", "of", "the", "specified", "rectangle", "."...
4a98c4181b3e8876e688591737da37627c07e72b
https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/Rect.java#L361-L367
train
wanglinsong/thx-android
uia-client/src/main/java/com/android/uiautomator/stub/Rect.java
Rect.contains
public boolean contains(Rect r) { // check for empty first return this.left < this.right && this.top < this.bottom // now check for containment && left <= r.left && top <= r.top && right >= r.right && bottom >= r.bottom; }
java
public boolean contains(Rect r) { // check for empty first return this.left < this.right && this.top < this.bottom // now check for containment && left <= r.left && top <= r.top && right >= r.right && bottom >= r.bottom; }
[ "public", "boolean", "contains", "(", "Rect", "r", ")", "{", "// check for empty first", "return", "this", ".", "left", "<", "this", ".", "right", "&&", "this", ".", "top", "<", "this", ".", "bottom", "// now check for containment", "&&", "left", "<=", "r", ...
Returns true iff the specified rectangle r is inside or equal to this rectangle. An empty rectangle never contains another rectangle. @param r The rectangle being tested for containment. @return true iff the specified rectangle r is inside or equal to this rectangle
[ "Returns", "true", "iff", "the", "specified", "rectangle", "r", "is", "inside", "or", "equal", "to", "this", "rectangle", ".", "An", "empty", "rectangle", "never", "contains", "another", "rectangle", "." ]
4a98c4181b3e8876e688591737da37627c07e72b
https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/Rect.java#L378-L383
train
wanglinsong/thx-android
uia-client/src/main/java/com/android/uiautomator/stub/Rect.java
Rect.union
public void union(Rect r) { union(r.left, r.top, r.right, r.bottom); }
java
public void union(Rect r) { union(r.left, r.top, r.right, r.bottom); }
[ "public", "void", "union", "(", "Rect", "r", ")", "{", "union", "(", "r", ".", "left", ",", "r", ".", "top", ",", "r", ".", "right", ",", "r", ".", "bottom", ")", ";", "}" ]
Update this Rect to enclose itself and the specified rectangle. If the specified rectangle is empty, nothing is done. If this rectangle is empty it is set to the specified rectangle. @param r The rectangle being unioned with this rectangle
[ "Update", "this", "Rect", "to", "enclose", "itself", "and", "the", "specified", "rectangle", ".", "If", "the", "specified", "rectangle", "is", "empty", "nothing", "is", "done", ".", "If", "this", "rectangle", "is", "empty", "it", "is", "set", "to", "the", ...
4a98c4181b3e8876e688591737da37627c07e72b
https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/Rect.java#L538-L540
train
wanglinsong/thx-android
uia-client/src/main/java/com/android/uiautomator/stub/Rect.java
Rect.scale
public void scale(float scale) { if (scale != 1.0f) { left = (int) (left * scale + 0.5f); top = (int) (top * scale + 0.5f); right = (int) (right * scale + 0.5f); bottom = (int) (bottom * scale + 0.5f); } }
java
public void scale(float scale) { if (scale != 1.0f) { left = (int) (left * scale + 0.5f); top = (int) (top * scale + 0.5f); right = (int) (right * scale + 0.5f); bottom = (int) (bottom * scale + 0.5f); } }
[ "public", "void", "scale", "(", "float", "scale", ")", "{", "if", "(", "scale", "!=", "1.0f", ")", "{", "left", "=", "(", "int", ")", "(", "left", "*", "scale", "+", "0.5f", ")", ";", "top", "=", "(", "int", ")", "(", "top", "*", "scale", "+"...
Scales up the rect by the given scale. @param scale scale
[ "Scales", "up", "the", "rect", "by", "the", "given", "scale", "." ]
4a98c4181b3e8876e688591737da37627c07e72b
https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/Rect.java#L587-L594
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/provider/newrelic/PluginCache.java
PluginCache.add
public void add(Collection<Plugin> plugins) { for(Plugin plugin : plugins) this.plugins.put(plugin.getId(), plugin); }
java
public void add(Collection<Plugin> plugins) { for(Plugin plugin : plugins) this.plugins.put(plugin.getId(), plugin); }
[ "public", "void", "add", "(", "Collection", "<", "Plugin", ">", "plugins", ")", "{", "for", "(", "Plugin", "plugin", ":", "plugins", ")", "this", ".", "plugins", ".", "put", "(", "plugin", ".", "getId", "(", ")", ",", "plugin", ")", ";", "}" ]
Adds the plugin list to the plugins for the account. @param plugins The plugins to add
[ "Adds", "the", "plugin", "list", "to", "the", "plugins", "for", "the", "account", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/PluginCache.java#L56-L60
train
opsmatters/opsmatters-core
src/main/java/com/opsmatters/core/provider/newrelic/PluginCache.java
PluginCache.components
public PluginComponentCache components(long pluginId) { PluginComponentCache cache = components.get(pluginId); if(cache == null) components.put(pluginId, cache = new PluginComponentCache(pluginId)); return cache; }
java
public PluginComponentCache components(long pluginId) { PluginComponentCache cache = components.get(pluginId); if(cache == null) components.put(pluginId, cache = new PluginComponentCache(pluginId)); return cache; }
[ "public", "PluginComponentCache", "components", "(", "long", "pluginId", ")", "{", "PluginComponentCache", "cache", "=", "components", ".", "get", "(", "pluginId", ")", ";", "if", "(", "cache", "==", "null", ")", "components", ".", "put", "(", "pluginId", ",...
Returns the cache of plugin components for the given plugin, creating one if it doesn't exist . @param pluginId The id of the plugin for the cache of plugin component @return The cache of plugin components for the given plugin
[ "Returns", "the", "cache", "of", "plugin", "components", "for", "the", "given", "plugin", "creating", "one", "if", "it", "doesn", "t", "exist", "." ]
c48904f7e8d029fd45357811ec38a735e261e3fd
https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/PluginCache.java#L102-L108
train
coopernurse/barrister-java
src/main/java/com/bitmechanic/barrister/Field.java
Field.getTypeConverter
public TypeConverter getTypeConverter() throws RpcException { if (contract == null) { throw new IllegalStateException("contract cannot be null"); } if (type == null) { throw new IllegalStateException("field type cannot be null"); } TypeConverter tc = null; if (type.equals("string")) tc = new StringTypeConverter(isOptional); else if (type.equals("int")) tc = new IntTypeConverter(isOptional); else if (type.equals("float")) tc = new FloatTypeConverter(isOptional); else if (type.equals("bool")) tc = new BoolTypeConverter(isOptional); else { Struct s = contract.getStructs().get(type); if (s != null) { tc = new StructTypeConverter(s, isOptional); } Enum e = contract.getEnums().get(type); if (e != null) { tc = new EnumTypeConverter(e, isOptional); } } if (tc == null) { throw RpcException.Error.INTERNAL.exc("Unknown type: " + type); } else if (isArray) { return new ArrayTypeConverter(tc, isOptional); } else { return tc; } }
java
public TypeConverter getTypeConverter() throws RpcException { if (contract == null) { throw new IllegalStateException("contract cannot be null"); } if (type == null) { throw new IllegalStateException("field type cannot be null"); } TypeConverter tc = null; if (type.equals("string")) tc = new StringTypeConverter(isOptional); else if (type.equals("int")) tc = new IntTypeConverter(isOptional); else if (type.equals("float")) tc = new FloatTypeConverter(isOptional); else if (type.equals("bool")) tc = new BoolTypeConverter(isOptional); else { Struct s = contract.getStructs().get(type); if (s != null) { tc = new StructTypeConverter(s, isOptional); } Enum e = contract.getEnums().get(type); if (e != null) { tc = new EnumTypeConverter(e, isOptional); } } if (tc == null) { throw RpcException.Error.INTERNAL.exc("Unknown type: " + type); } else if (isArray) { return new ArrayTypeConverter(tc, isOptional); } else { return tc; } }
[ "public", "TypeConverter", "getTypeConverter", "(", ")", "throws", "RpcException", "{", "if", "(", "contract", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"contract cannot be null\"", ")", ";", "}", "if", "(", "type", "==", "null", ...
Returns a new TypeConverter appropriate for the Field's type. @throws RpcException If type is not defined in the Contract
[ "Returns", "a", "new", "TypeConverter", "appropriate", "for", "the", "Field", "s", "type", "." ]
c2b639634c88a25002b66d1fb4a8f5fb51ade6a2
https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/Field.java#L52-L91
train
coopernurse/barrister-java
src/main/java/com/bitmechanic/barrister/Field.java
Field.getJavaType
public String getJavaType(boolean wrapArray) { String t = ""; if (type.equals("string")) { t = "String"; } else if (type.equals("float")) { t = "Double"; } else if (type.equals("int")) { t = "Long"; } else if (type.equals("bool")) { t = "Boolean"; } else { t = type; } if (wrapArray && isArray) { return t + "[]"; } else { return t; } }
java
public String getJavaType(boolean wrapArray) { String t = ""; if (type.equals("string")) { t = "String"; } else if (type.equals("float")) { t = "Double"; } else if (type.equals("int")) { t = "Long"; } else if (type.equals("bool")) { t = "Boolean"; } else { t = type; } if (wrapArray && isArray) { return t + "[]"; } else { return t; } }
[ "public", "String", "getJavaType", "(", "boolean", "wrapArray", ")", "{", "String", "t", "=", "\"\"", ";", "if", "(", "type", ".", "equals", "(", "\"string\"", ")", ")", "{", "t", "=", "\"String\"", ";", "}", "else", "if", "(", "type", ".", "equals",...
Returns the Java type this type maps to. Used by Idl2Java code generator. @param wrapArray If true, returned String will include '[]' after type to designate a Java array type
[ "Returns", "the", "Java", "type", "this", "type", "maps", "to", ".", "Used", "by", "Idl2Java", "code", "generator", "." ]
c2b639634c88a25002b66d1fb4a8f5fb51ade6a2
https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/Field.java#L148-L172
train