_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q19800 | Comment.seeTags | train | SeeTag[] seeTags() {
ListBuffer<SeeTag> found = new ListBuffer<SeeTag>();
for (Tag next : tagList) {
if (next instanceof SeeTag) {
found.append((SeeTag)next);
}
}
return found.toArray(new SeeTag[found.length()]);
} | java | {
"resource": ""
} |
q19801 | ContainerRegistry.get | train | public C get(String id){
C container = this.containerMap.get(id);
if(container != null && (container.getState()).equals(State.REMOVED)){
return null;
}
return container;
} | java | {
"resource": ""
} |
q19802 | ContainerRegistry.getAll | train | public Collection<C> getAll(Collection<String> ids){
Set<C> list = new LinkedHashSet<C>();
for(String id : ids){
C container = get(id);
if(container != null){
list.add(container);
}
}
return list;
} | java | {
"resource": ""
} |
q19803 | Idl2Java.main | train | public static void main(String argv[]) throws Exception {
String idlFile = null;
String pkgName = null;
String outDir = null;
String nsPkgName = null;
boolean allImmutable = false;
List<String> immutableSubstr = new ArrayList<String>();
for (int i = 0; i < argv.length; i++) {
if (argv[i].equals("-j")) {
idlFile = argv[++i];
}
else if (argv[i].equals("-p")) {
pkgName = argv[++i];
}
else if (argv[i].equals("-o")) {
outDir = argv[++i];
}
else if (argv[i].equals("-b")) {
nsPkgName = argv[++i];
}
else if (argv[i].equals("-s")) {
immutableSubstr.add(argv[++i]);
}
else if (argv[i].equals("-i")) {
allImmutable = true;
}
}
if (isBlank(idlFile) || isBlank(pkgName) || isBlank(outDir)) {
out("Usage: java com.bitmechanic.barrister.Idl2Java -j [idl file] -p [Java package prefix] -b [Java package prefix for namespaced entities] -o [out dir] -i -s [immutable class substr]");
System.exit(1);
}
if (nsPkgName == null) {
nsPkgName = pkgName;
}
new Idl2Java(idlFile, pkgName, nsPkgName, outDir, allImmutable, immutableSubstr);
} | java | {
"resource": ""
} |
q19804 | HttpServiceDispatcher.init | train | public void init() throws ServletException {
_application = ((ManagedPlatform)ServicePlatform.getService(ManagedPlatform.INSTANCE).first).getName();
/*
ApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
if (wac.containsBean("persistence")) { // persistence may not be there if persistent storage is not required
_persistence = (Persistence)wac.getBean("persistence");
}
*/
} | java | {
"resource": ""
} |
q19805 | ProfileSummaryBuilder.getInstance | train | public static ProfileSummaryBuilder getInstance(Context context,
Profile profile, ProfileSummaryWriter profileWriter) {
return new ProfileSummaryBuilder(context, profile, profileWriter);
} | java | {
"resource": ""
} |
q19806 | ProfileSummaryBuilder.buildProfileDoc | train | public void buildProfileDoc(XMLNode node, Content contentTree) throws Exception {
contentTree = profileWriter.getProfileHeader(profile.name);
buildChildren(node, contentTree);
profileWriter.addProfileFooter(contentTree);
profileWriter.printDocument(contentTree);
profileWriter.close();
Util.copyDocFiles(configuration, DocPaths.profileSummary(profile.name));
} | java | {
"resource": ""
} |
q19807 | ProfileSummaryBuilder.buildContent | train | public void buildContent(XMLNode node, Content contentTree) {
Content profileContentTree = profileWriter.getContentHeader();
buildChildren(node, profileContentTree);
contentTree.addContent(profileContentTree);
} | java | {
"resource": ""
} |
q19808 | ProfileSummaryBuilder.buildSummary | train | public void buildSummary(XMLNode node, Content profileContentTree) {
Content summaryContentTree = profileWriter.getSummaryHeader();
buildChildren(node, summaryContentTree);
profileContentTree.addContent(profileWriter.getSummaryTree(summaryContentTree));
} | java | {
"resource": ""
} |
q19809 | ProfileSummaryBuilder.buildPackageSummary | train | public void buildPackageSummary(XMLNode node, Content summaryContentTree) {
PackageDoc[] packages = configuration.profilePackages.get(profile.name);
for (int i = 0; i < packages.length; i++) {
this.pkg = packages[i];
Content packageSummaryContentTree = profileWriter.getPackageSummaryHeader(this.pkg);
buildChildren(node, packageSummaryContentTree);
summaryContentTree.addContent(profileWriter.getPackageSummaryTree(
packageSummaryContentTree));
}
} | java | {
"resource": ""
} |
q19810 | ProfileSummaryBuilder.buildInterfaceSummary | train | public void buildInterfaceSummary(XMLNode node, Content packageSummaryContentTree) {
String interfaceTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Interface_Summary"),
configuration.getText("doclet.interfaces"));
String[] interfaceTableHeader = new String[] {
configuration.getText("doclet.Interface"),
configuration.getText("doclet.Description")
};
ClassDoc[] interfaces = pkg.interfaces();
if (interfaces.length > 0) {
profileWriter.addClassesSummary(
interfaces,
configuration.getText("doclet.Interface_Summary"),
interfaceTableSummary, interfaceTableHeader, packageSummaryContentTree);
}
} | java | {
"resource": ""
} |
q19811 | ProfileSummaryBuilder.buildClassSummary | train | public void buildClassSummary(XMLNode node, Content packageSummaryContentTree) {
String classTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Class_Summary"),
configuration.getText("doclet.classes"));
String[] classTableHeader = new String[] {
configuration.getText("doclet.Class"),
configuration.getText("doclet.Description")
};
ClassDoc[] classes = pkg.ordinaryClasses();
if (classes.length > 0) {
profileWriter.addClassesSummary(
classes,
configuration.getText("doclet.Class_Summary"),
classTableSummary, classTableHeader, packageSummaryContentTree);
}
} | java | {
"resource": ""
} |
q19812 | ProfileSummaryBuilder.buildEnumSummary | train | public void buildEnumSummary(XMLNode node, Content packageSummaryContentTree) {
String enumTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Enum_Summary"),
configuration.getText("doclet.enums"));
String[] enumTableHeader = new String[] {
configuration.getText("doclet.Enum"),
configuration.getText("doclet.Description")
};
ClassDoc[] enums = pkg.enums();
if (enums.length > 0) {
profileWriter.addClassesSummary(
enums,
configuration.getText("doclet.Enum_Summary"),
enumTableSummary, enumTableHeader, packageSummaryContentTree);
}
} | java | {
"resource": ""
} |
q19813 | ProfileSummaryBuilder.buildExceptionSummary | train | public void buildExceptionSummary(XMLNode node, Content packageSummaryContentTree) {
String exceptionTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Exception_Summary"),
configuration.getText("doclet.exceptions"));
String[] exceptionTableHeader = new String[] {
configuration.getText("doclet.Exception"),
configuration.getText("doclet.Description")
};
ClassDoc[] exceptions = pkg.exceptions();
if (exceptions.length > 0) {
profileWriter.addClassesSummary(
exceptions,
configuration.getText("doclet.Exception_Summary"),
exceptionTableSummary, exceptionTableHeader, packageSummaryContentTree);
}
} | java | {
"resource": ""
} |
q19814 | ProfileSummaryBuilder.buildErrorSummary | train | public void buildErrorSummary(XMLNode node, Content packageSummaryContentTree) {
String errorTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Error_Summary"),
configuration.getText("doclet.errors"));
String[] errorTableHeader = new String[] {
configuration.getText("doclet.Error"),
configuration.getText("doclet.Description")
};
ClassDoc[] errors = pkg.errors();
if (errors.length > 0) {
profileWriter.addClassesSummary(
errors,
configuration.getText("doclet.Error_Summary"),
errorTableSummary, errorTableHeader, packageSummaryContentTree);
}
} | java | {
"resource": ""
} |
q19815 | ProfileSummaryBuilder.buildAnnotationTypeSummary | train | public void buildAnnotationTypeSummary(XMLNode node, Content packageSummaryContentTree) {
String annotationtypeTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Annotation_Types_Summary"),
configuration.getText("doclet.annotationtypes"));
String[] annotationtypeTableHeader = new String[] {
configuration.getText("doclet.AnnotationType"),
configuration.getText("doclet.Description")
};
ClassDoc[] annotationTypes = pkg.annotationTypes();
if (annotationTypes.length > 0) {
profileWriter.addClassesSummary(
annotationTypes,
configuration.getText("doclet.Annotation_Types_Summary"),
annotationtypeTableSummary, annotationtypeTableHeader,
packageSummaryContentTree);
}
} | java | {
"resource": ""
} |
q19816 | BooleanExtensions.trueOrFalse | train | public static <T> T trueOrFalse(final T trueCase, final T falseCase, final boolean... flags)
{
boolean interlink = true;
if (flags != null && 0 < flags.length)
{
interlink = false;
}
for (int i = 0; i < flags.length; i++)
{
if (i == 0)
{
interlink = !flags[i];
continue;
}
interlink &= !flags[i];
}
if (interlink)
{
return falseCase;
}
return trueCase;
} | java | {
"resource": ""
} |
q19817 | AlertChannelCache.add | train | public void add(Collection<AlertChannel> channels)
{
for(AlertChannel channel : channels)
this.channels.put(channel.getId(), channel);
} | java | {
"resource": ""
} |
q19818 | ClassDocImpl.addAllClasses | train | void addAllClasses(ListBuffer<ClassDocImpl> l, boolean filtered) {
try {
if (isSynthetic()) return;
// sometimes synthetic classes are not marked synthetic
if (!JavadocTool.isValidClassName(tsym.name.toString())) return;
if (filtered && !env.shouldDocument(tsym)) return;
if (l.contains(this)) return;
l.append(this);
List<ClassDocImpl> more = List.nil();
for (Scope.Entry e = tsym.members().elems; e != null;
e = e.sibling) {
if (e.sym != null && e.sym.kind == Kinds.TYP) {
ClassSymbol s = (ClassSymbol)e.sym;
ClassDocImpl c = env.getClassDoc(s);
if (c.isSynthetic()) continue;
if (c != null) more = more.prepend(c);
}
}
// this extra step preserves the ordering from oldjavadoc
for (; more.nonEmpty(); more=more.tail) {
more.head.addAllClasses(l, filtered);
}
} catch (CompletionFailure e) {
// quietly ignore completion failures
}
} | java | {
"resource": ""
} |
q19819 | MathUtils.randomLong | train | public static long randomLong(final long min, final long max) {
return Math.round(Math.random() * (max - min) + min);
} | java | {
"resource": ""
} |
q19820 | AnnotationExtensions.getAllAnnotatedClasses | train | public static Set<Class<?>> getAllAnnotatedClasses(final String packagePath,
final Class<? extends Annotation> annotationClass)
throws ClassNotFoundException, IOException, URISyntaxException
{
final List<File> directories = ClassExtensions.getDirectoriesFromResources(packagePath,
true);
final Set<Class<?>> classes = new HashSet<>();
for (final File directory : directories)
{
classes.addAll(scanForAnnotatedClasses(directory, packagePath, annotationClass));
}
return classes;
} | java | {
"resource": ""
} |
q19821 | AnnotationExtensions.getAllAnnotatedClassesFromSet | train | public static Set<Class<?>> getAllAnnotatedClassesFromSet(final String packagePath,
final Set<Class<? extends Annotation>> annotationClasses)
throws ClassNotFoundException, IOException, URISyntaxException
{
final List<File> directories = ClassExtensions.getDirectoriesFromResources(packagePath,
true);
final Set<Class<?>> classes = new HashSet<>();
for (final File directory : directories)
{
classes
.addAll(scanForAnnotatedClassesFromSet(directory, packagePath, annotationClasses));
}
return classes;
} | java | {
"resource": ""
} |
q19822 | AnnotationExtensions.getAnnotation | train | public static <T extends Annotation> T getAnnotation(final Class<?> componentClass,
final Class<T> annotationClass)
{
T annotation = componentClass.getAnnotation(annotationClass);
if (annotation != null)
{
return annotation;
}
for (final Class<?> ifc : componentClass.getInterfaces())
{
annotation = getAnnotation(ifc, annotationClass);
if (annotation != null)
{
return annotation;
}
}
if (!Annotation.class.isAssignableFrom(componentClass))
{
for (final Annotation ann : componentClass.getAnnotations())
{
annotation = getAnnotation(ann.annotationType(), annotationClass);
if (annotation != null)
{
return annotation;
}
}
}
final Class<?> superClass = componentClass.getSuperclass();
if (superClass == null || superClass.equals(Object.class))
{
return null;
}
return getAnnotation(superClass, annotationClass);
} | java | {
"resource": ""
} |
q19823 | AnnotationExtensions.scanForClasses | train | public static Set<Class<?>> scanForClasses(final File directory, final String packagePath)
throws ClassNotFoundException
{
return AnnotationExtensions.scanForAnnotatedClasses(directory, packagePath, null);
} | java | {
"resource": ""
} |
q19824 | AnnotationExtensions.setAnnotationValue | train | @SuppressWarnings("unchecked")
public static Object setAnnotationValue(final Annotation annotation, final String key,
final Object value) throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException
{
final Object invocationHandler = Proxy.getInvocationHandler(annotation);
final Field field = invocationHandler.getClass().getDeclaredField("memberValues");
field.setAccessible(true);
final Map<String, Object> memberValues = (Map<String, Object>)field.get(invocationHandler);
final Object oldValue = memberValues.get(key);
if (oldValue == null || oldValue.getClass() != value.getClass())
{
throw new IllegalArgumentException();
}
memberValues.put(key, value);
return oldValue;
} | java | {
"resource": ""
} |
q19825 | ServiceLoader.iterator | train | public Iterator<S> iterator() {
return new Iterator<S>() {
Iterator<Map.Entry<String,S>> knownProviders
= providers.entrySet().iterator();
public boolean hasNext() {
if (knownProviders.hasNext())
return true;
return lookupIterator.hasNext();
}
public S next() {
if (knownProviders.hasNext())
return knownProviders.next().getValue();
return lookupIterator.next();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
} | java | {
"resource": ""
} |
q19826 | Interface.getFunction | train | public Function getFunction(String name) {
for (Function f : functions) {
if (f.getName().equals(name))
return f;
}
return null;
} | java | {
"resource": ""
} |
q19827 | Interface.setContract | train | @Override
public void setContract(Contract c) {
super.setContract(c);
for (Function f : functions) {
f.setContract(c);
}
} | java | {
"resource": ""
} |
q19828 | RDFUtils.toGraph | train | public static Collector<Triple, ?, Graph> toGraph() {
return of(rdf::createGraph, Graph::add, (left, right) -> {
right.iterate().forEach(left::add);
return left;
}, UNORDERED);
} | java | {
"resource": ""
} |
q19829 | RDFUtils.toDataset | train | public static Collector<Quad, ?, Dataset> toDataset() {
return of(rdf::createDataset, Dataset::add, (left, right) -> {
right.iterate().forEach(left::add);
return left;
}, UNORDERED);
} | java | {
"resource": ""
} |
q19830 | ContextFactory.toCreate | train | public ContextFactory toCreate(BiFunction<Constructor, Object[], Object> function) {
return new ContextFactory(this.context, function);
} | java | {
"resource": ""
} |
q19831 | ContextFactory.create | train | public <E> Optional<E> create(Class<E> type) {
List<Constructor<?>> constructors = reflect().constructors()
.filter(declared(Modifier.PUBLIC))
.from(type);
Optional created;
for (Constructor<?> constructor : constructors) {
created = tryCreate(constructor);
if (created.isPresent()) {
return created;
}
}
return Optional.empty();
} | java | {
"resource": ""
} |
q19832 | ContextFactory.tryCreate | train | private Optional tryCreate(Constructor<?> constructor) {
Object[] args = new Object[constructor.getParameterCount()];
Object arg;
Optional<Object> resolved;
int i = 0;
for (Parameter parameter : constructor.getParameters()) {
resolved = context.resolve(parameter);
if (!resolved.isPresent()) {
return Optional.empty();
}
arg = resolved.value();
args[i++] = arg;
}
return Optional.of(createFunction.apply(constructor, args));
} | java | {
"resource": ""
} |
q19833 | JavaCompilerWithDeps.reportPublicApi | train | @Override
public void reportPublicApi(ClassSymbol sym) {
// The next test will catch when source files are located in the wrong directory!
// This ought to be moved into javac as a new warning, or perhaps as part
// of the auxiliary class warning.
// For example if sun.swing.BeanInfoUtils
// is in fact stored in: /mybuild/jdk/gensrc/javax/swing/beaninfo/BeanInfoUtils.java
// We do not need to test that BeanInfoUtils is stored in a file named BeanInfoUtils
// since this is checked earlier.
if (sym.sourcefile != null) {
// Rewrite sun.swing.BeanInfoUtils into /sun/swing/
StringBuilder pathb = new StringBuilder();
StringTokenizer qn = new StringTokenizer(sym.packge().toString(), ".");
boolean first = true;
while (qn.hasMoreTokens()) {
String o = qn.nextToken();
pathb.append("/");
pathb.append(o);
first = false;
}
pathb.append("/");
String path = pathb.toString();
// Now cut the uri to be: file:///mybuild/jdk/gensrc/javax/swing/beaninfo/
String p = sym.sourcefile.toUri().getPath();
// Do not use File.separatorChar here, a URI always uses slashes /.
int i = p.lastIndexOf("/");
String pp = p.substring(0,i+1);
// Now check if the truncated uri ends with the path. (It does not == failure!)
if (path.length() > 0 && !path.equals("/unnamed package/") && !pp.endsWith(path)) {
compilerThread.logError("Error: The source file "+sym.sourcefile.getName()+
" is located in the wrong package directory, because it contains the class "+
sym.getQualifiedName());
}
}
deps.visitPubapi(sym);
} | java | {
"resource": ""
} |
q19834 | JADMojo.execute | train | public void execute() throws MojoExecutionException {
getLog().debug("starting packaging");
AbstractConfiguration[] configurations= (AbstractConfiguration[]) getPluginContext().get(ConfiguratorMojo.GENERATED_CONFIGURATIONS_KEY);
try {
for(AbstractConfiguration configuration : configurations) {
if(!(configuration instanceof NodeConfiguration)) {
continue;
}
String classifier= configuration.className.substring(configuration.className.lastIndexOf('.') + 1);
File jarFile= checkJarFile(classifier);
JavaApplicationDescriptor descriptor= getDescriptor();
descriptor.setNodeConfiguration(configuration.className);
descriptor.setJarFile(jarFile);
File jadFile= getJadFile(classifier);
getDescriptor().writeDescriptor(jadFile);
getProjectHelper().attachArtifact(getProject(), "jad", classifier, jadFile);
}
} catch (IOException ioe) {
throw new MojoExecutionException("could not create .jad file", ioe);
} catch (RuntimeException e) {
throw new MojoExecutionException("could not create .jad file", e);
}
getLog().debug("finished packaging");
} | java | {
"resource": ""
} |
q19835 | FreemarkerSQLDataReportConnector.resultSetToMap | train | public List<Map<String,Object>> resultSetToMap(ResultSet rows) {
try {
List<Map<String,Object>> beans = new ArrayList<Map<String,Object>>();
int columnCount = rows.getMetaData().getColumnCount();
while (rows.next()) {
LinkedHashMap<String,Object> bean = new LinkedHashMap<String, Object>();
beans.add(bean);
for (int i = 0; i < columnCount; i++) {
Object object = rows.getObject(i + 1);
String columnLabel = rows.getMetaData().getColumnLabel(i + 1);
String columnName = rows.getMetaData().getColumnName(i + 1);
bean.put(StringUtils.defaultIfEmpty(columnLabel, columnName), object != null ? object.toString() : "");
}
}
return beans;
} catch (Exception ex) {
errors.add(ex.getMessage());
throw new RuntimeException(ex);
}
} | java | {
"resource": ""
} |
q19836 | LambdaToMethod.makeMetafactoryIndyCall | train | private JCExpression makeMetafactoryIndyCall(TranslationContext<?> context,
int refKind, Symbol refSym, List<JCExpression> indy_args) {
JCFunctionalExpression tree = context.tree;
//determine the static bsm args
MethodSymbol samSym = (MethodSymbol) types.findDescriptorSymbol(tree.type.tsym);
List<Object> staticArgs = List.<Object>of(
typeToMethodType(samSym.type),
new Pool.MethodHandle(refKind, refSym, types),
typeToMethodType(tree.getDescriptorType(types)));
//computed indy arg types
ListBuffer<Type> indy_args_types = new ListBuffer<>();
for (JCExpression arg : indy_args) {
indy_args_types.append(arg.type);
}
//finally, compute the type of the indy call
MethodType indyType = new MethodType(indy_args_types.toList(),
tree.type,
List.<Type>nil(),
syms.methodClass);
Name metafactoryName = context.needsAltMetafactory() ?
names.altMetafactory : names.metafactory;
if (context.needsAltMetafactory()) {
ListBuffer<Object> markers = new ListBuffer<>();
for (Type t : tree.targets.tail) {
if (t.tsym != syms.serializableType.tsym) {
markers.append(t.tsym);
}
}
int flags = context.isSerializable() ? FLAG_SERIALIZABLE : 0;
boolean hasMarkers = markers.nonEmpty();
boolean hasBridges = context.bridges.nonEmpty();
if (hasMarkers) {
flags |= FLAG_MARKERS;
}
if (hasBridges) {
flags |= FLAG_BRIDGES;
}
staticArgs = staticArgs.append(flags);
if (hasMarkers) {
staticArgs = staticArgs.append(markers.length());
staticArgs = staticArgs.appendList(markers.toList());
}
if (hasBridges) {
staticArgs = staticArgs.append(context.bridges.length() - 1);
for (Symbol s : context.bridges) {
Type s_erasure = s.erasure(types);
if (!types.isSameType(s_erasure, samSym.erasure(types))) {
staticArgs = staticArgs.append(s.erasure(types));
}
}
}
if (context.isSerializable()) {
int prevPos = make.pos;
try {
make.at(kInfo.clazz);
addDeserializationCase(refKind, refSym, tree.type, samSym,
tree, staticArgs, indyType);
} finally {
make.at(prevPos);
}
}
}
return makeIndyCall(tree, syms.lambdaMetafactory, metafactoryName, staticArgs, indyType, indy_args, samSym.name);
} | java | {
"resource": ""
} |
q19837 | LambdaToMethod.makeIndyCall | train | private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName,
List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs,
Name methName) {
int prevPos = make.pos;
try {
make.at(pos);
List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
syms.stringType,
syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs));
Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site,
bsmName, bsm_staticArgs, List.<Type>nil());
DynamicMethodSymbol dynSym =
new DynamicMethodSymbol(methName,
syms.noSymbol,
bsm.isStatic() ?
ClassFile.REF_invokeStatic :
ClassFile.REF_invokeVirtual,
(MethodSymbol)bsm,
indyType,
staticArgs.toArray());
JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
qualifier.sym = dynSym;
qualifier.type = indyType.getReturnType();
JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs);
proxyCall.type = indyType.getReturnType();
return proxyCall;
} finally {
make.at(prevPos);
}
} | java | {
"resource": ""
} |
q19838 | ProxyService.lookupServerURL | train | protected String lookupServerURL(DataBinder binder) {
_logger.info("STANDARD lookupServerURL: servers=" + _servers + ", selector='" + _selector + '\'');
if (_servers != null) {
if (_selector != null) {
return _servers.get(binder.get(_selector));
} else if (_servers.size() == 1) {
return _servers.values().iterator().next();
} else {
return null;
}
} else {
return null;
}
} | java | {
"resource": ""
} |
q19839 | World.clean | train | public void clean() {
log.debug("[clean] Cleaning world");
for (Robot bot : robotsPosition.keySet()) {
bot.die("World cleanup");
if (robotsPosition.containsKey(bot)) {
log.warn("[clean] Robot did not unregister itself. Removing it");
remove(bot);
}
}
} | java | {
"resource": ""
} |
q19840 | World.move | train | public void move(Robot robot) {
if (!robotsPosition.containsKey(robot)) {
throw new IllegalArgumentException("Robot doesn't exist");
}
if (!robot.getData().isMobile()) {
throw new IllegalArgumentException("Robot can't move");
}
Point newPosition = getReferenceField(robot, 1);
if (!isOccupied(newPosition)) {
Point oldPosition = robotsPosition.get(robot);
robotsPosition.put(robot, newPosition);
eventDispatcher.fireEvent(new RobotMovedEvent(robot, oldPosition, newPosition));
}
} | java | {
"resource": ""
} |
q19841 | World.getNeighbour | train | public Robot getNeighbour(Robot robot) {
Point neighbourPos = getReferenceField(robot, 1);
return getRobotAt(neighbourPos);
} | java | {
"resource": ""
} |
q19842 | World.scan | train | public ScanResult scan(Robot robot, int dist) {
Point space = getReferenceField(robot, dist);
Robot inPosition = getRobotAt(space);
ScanResult ret = null;
if (inPosition == null) {
ret = new ScanResult(Found.EMPTY, dist);
} else {
if (robot.getData().getTeamId() == inPosition.getData().getTeamId()) {
ret = new ScanResult(Found.FRIEND, dist);
} else {
ret = new ScanResult(Found.ENEMY, dist);
}
}
return ret;
} | java | {
"resource": ""
} |
q19843 | World.getBotsCount | train | public int getBotsCount(int teamId, boolean invert) {
int total = 0;
for (Robot bot : robotsPosition.keySet()) {
if (bot.getData().getTeamId() == teamId) {
if (!invert) {
total++;
}
} else {
if (invert) {
total++;
}
}
}
return total;
} | java | {
"resource": ""
} |
q19844 | CompilerPool.grabCompilerThread | train | public CompilerThread grabCompilerThread() throws InterruptedException {
available.acquire();
if (compilers.empty()) {
return new CompilerThread(this);
}
return compilers.pop();
} | java | {
"resource": ""
} |
q19845 | ServerCache.add | train | public void add(Collection<Server> servers)
{
for(Server server : servers)
this.servers.put(server.getId(), server);
} | java | {
"resource": ""
} |
q19846 | JavaCompiler.resolveIdent | train | public Symbol resolveIdent(String name) {
if (name.equals(""))
return syms.errSymbol;
JavaFileObject prev = log.useSource(null);
try {
JCExpression tree = null;
for (String s : name.split("\\.", -1)) {
if (!SourceVersion.isIdentifier(s)) // TODO: check for keywords
return syms.errSymbol;
tree = (tree == null) ? make.Ident(names.fromString(s))
: make.Select(tree, names.fromString(s));
}
JCCompilationUnit toplevel =
make.TopLevel(List.<JCTree.JCAnnotation>nil(), null, List.<JCTree>nil());
toplevel.packge = syms.unnamedPackage;
return attr.attribIdent(tree, toplevel);
} finally {
log.useSource(prev);
}
} | java | {
"resource": ""
} |
q19847 | JavaCompiler.printSource | train | JavaFileObject printSource(Env<AttrContext> env, JCClassDecl cdef) throws IOException {
JavaFileObject outFile
= fileManager.getJavaFileForOutput(CLASS_OUTPUT,
cdef.sym.flatname.toString(),
JavaFileObject.Kind.SOURCE,
null);
if (inputFiles.contains(outFile)) {
log.error(cdef.pos(), "source.cant.overwrite.input.file", outFile);
return null;
} else {
BufferedWriter out = new BufferedWriter(outFile.openWriter());
try {
new Pretty(out, true).printUnit(env.toplevel, cdef);
if (verbose)
log.printVerbose("wrote.file", outFile);
} finally {
out.close();
}
return outFile;
}
} | java | {
"resource": ""
} |
q19848 | JavaCompiler.enterTreesIfNeeded | train | public List<JCCompilationUnit> enterTreesIfNeeded(List<JCCompilationUnit> roots) {
if (shouldStop(CompileState.ATTR))
return List.nil();
return enterTrees(roots);
} | java | {
"resource": ""
} |
q19849 | JavaCompiler.enterTrees | train | public List<JCCompilationUnit> enterTrees(List<JCCompilationUnit> roots) {
//enter symbols for all files
if (!taskListener.isEmpty()) {
for (JCCompilationUnit unit: roots) {
TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
taskListener.started(e);
}
}
enter.main(roots);
if (!taskListener.isEmpty()) {
for (JCCompilationUnit unit: roots) {
TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
taskListener.finished(e);
}
}
// If generating source, or if tracking public apis,
// then remember the classes declared in
// the original compilation units listed on the command line.
if (needRootClasses || sourceOutput || stubOutput) {
ListBuffer<JCClassDecl> cdefs = new ListBuffer<>();
for (JCCompilationUnit unit : roots) {
for (List<JCTree> defs = unit.defs;
defs.nonEmpty();
defs = defs.tail) {
if (defs.head instanceof JCClassDecl)
cdefs.append((JCClassDecl)defs.head);
}
}
rootClasses = cdefs.toList();
}
// Ensure the input files have been recorded. Although this is normally
// done by readSource, it may not have been done if the trees were read
// in a prior round of annotation processing, and the trees have been
// cleaned and are being reused.
for (JCCompilationUnit unit : roots) {
inputFiles.add(unit.sourcefile);
}
return roots;
} | java | {
"resource": ""
} |
q19850 | JavaCompiler.flow | train | protected void flow(Env<AttrContext> env, Queue<Env<AttrContext>> results) {
if (compileStates.isDone(env, CompileState.FLOW)) {
results.add(env);
return;
}
try {
if (shouldStop(CompileState.FLOW))
return;
if (relax) {
results.add(env);
return;
}
if (verboseCompilePolicy)
printNote("[flow " + env.enclClass.sym + "]");
JavaFileObject prev = log.useSource(
env.enclClass.sym.sourcefile != null ?
env.enclClass.sym.sourcefile :
env.toplevel.sourcefile);
try {
make.at(Position.FIRSTPOS);
TreeMaker localMake = make.forToplevel(env.toplevel);
flow.analyzeTree(env, localMake);
compileStates.put(env, CompileState.FLOW);
if (shouldStop(CompileState.FLOW))
return;
results.add(env);
}
finally {
log.useSource(prev);
}
}
finally {
if (!taskListener.isEmpty()) {
TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
taskListener.finished(e);
}
}
} | java | {
"resource": ""
} |
q19851 | JavaCompiler.desugar | train | public Queue<Pair<Env<AttrContext>, JCClassDecl>> desugar(Queue<Env<AttrContext>> envs) {
ListBuffer<Pair<Env<AttrContext>, JCClassDecl>> results = new ListBuffer<>();
for (Env<AttrContext> env: envs)
desugar(env, results);
return stopIfError(CompileState.FLOW, results);
}
HashMap<Env<AttrContext>, Queue<Pair<Env<AttrContext>, JCClassDecl>>> desugaredEnvs =
new HashMap<Env<AttrContext>, Queue<Pair<Env<AttrContext>, JCClassDecl>>>();
/**
* Prepare attributed parse trees, in conjunction with their attribution contexts,
* for source or code generation. If the file was not listed on the command line,
* the current implicitSourcePolicy is taken into account.
* The preparation stops as soon as an error is found.
*/
protected void desugar(final Env<AttrContext> env, Queue<Pair<Env<AttrContext>, JCClassDecl>> results) {
if (shouldStop(CompileState.TRANSTYPES))
return;
if (implicitSourcePolicy == ImplicitSourcePolicy.NONE
&& !inputFiles.contains(env.toplevel.sourcefile)) {
return;
}
if (compileStates.isDone(env, CompileState.LOWER)) {
results.addAll(desugaredEnvs.get(env));
return;
}
/**
* Ensure that superclasses of C are desugared before C itself. This is
* required for two reasons: (i) as erasure (TransTypes) destroys
* information needed in flow analysis and (ii) as some checks carried
* out during lowering require that all synthetic fields/methods have
* already been added to C and its superclasses.
*/
class ScanNested extends TreeScanner {
Set<Env<AttrContext>> dependencies = new LinkedHashSet<Env<AttrContext>>();
protected boolean hasLambdas;
@Override
public void visitClassDef(JCClassDecl node) {
Type st = types.supertype(node.sym.type);
boolean envForSuperTypeFound = false;
while (!envForSuperTypeFound && st.hasTag(CLASS)) {
ClassSymbol c = st.tsym.outermostClass();
Env<AttrContext> stEnv = enter.getEnv(c);
if (stEnv != null && env != stEnv) {
if (dependencies.add(stEnv)) {
boolean prevHasLambdas = hasLambdas;
try {
scan(stEnv.tree);
} finally {
/*
* ignore any updates to hasLambdas made during
* the nested scan, this ensures an initalized
* LambdaToMethod is available only to those
* classes that contain lambdas
*/
hasLambdas = prevHasLambdas;
}
}
envForSuperTypeFound = true;
}
st = types.supertype(st);
}
super.visitClassDef(node);
}
@Override
public void visitLambda(JCLambda tree) {
hasLambdas = true;
super.visitLambda(tree);
}
@Override
public void visitReference(JCMemberReference tree) {
hasLambdas = true;
super.visitReference(tree);
}
}
ScanNested scanner = new ScanNested();
scanner.scan(env.tree);
for (Env<AttrContext> dep: scanner.dependencies) {
if (!compileStates.isDone(dep, CompileState.FLOW))
desugaredEnvs.put(dep, desugar(flow(attribute(dep))));
}
//We need to check for error another time as more classes might
//have been attributed and analyzed at this stage
if (shouldStop(CompileState.TRANSTYPES))
return;
if (verboseCompilePolicy)
printNote("[desugar " + env.enclClass.sym + "]");
JavaFileObject prev = log.useSource(env.enclClass.sym.sourcefile != null ?
env.enclClass.sym.sourcefile :
env.toplevel.sourcefile);
try {
//save tree prior to rewriting
JCTree untranslated = env.tree;
make.at(Position.FIRSTPOS);
TreeMaker localMake = make.forToplevel(env.toplevel);
if (env.tree instanceof JCCompilationUnit) {
if (!(stubOutput || sourceOutput || printFlat)) {
if (shouldStop(CompileState.LOWER))
return;
List<JCTree> pdef = lower.translateTopLevelClass(env, env.tree, localMake);
if (pdef.head != null) {
Assert.check(pdef.tail.isEmpty());
results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, (JCClassDecl)pdef.head));
}
}
return;
}
if (stubOutput) {
//emit stub Java source file, only for compilation
//units enumerated explicitly on the command line
JCClassDecl cdef = (JCClassDecl)env.tree;
if (untranslated instanceof JCClassDecl &&
rootClasses.contains((JCClassDecl)untranslated) &&
((cdef.mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
cdef.sym.packge().getQualifiedName() == names.java_lang)) {
results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, removeMethodBodies(cdef)));
}
return;
}
if (shouldStop(CompileState.TRANSTYPES))
return;
env.tree = transTypes.translateTopLevelClass(env.tree, localMake);
compileStates.put(env, CompileState.TRANSTYPES);
if (source.allowLambda() && scanner.hasLambdas) {
if (shouldStop(CompileState.UNLAMBDA))
return;
env.tree = LambdaToMethod.instance(context).translateTopLevelClass(env, env.tree, localMake);
compileStates.put(env, CompileState.UNLAMBDA);
}
if (shouldStop(CompileState.LOWER))
return;
if (sourceOutput) {
//emit standard Java source file, only for compilation
//units enumerated explicitly on the command line
JCClassDecl cdef = (JCClassDecl)env.tree;
if (untranslated instanceof JCClassDecl &&
rootClasses.contains((JCClassDecl)untranslated)) {
results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, cdef));
}
return;
}
//translate out inner classes
List<JCTree> cdefs = lower.translateTopLevelClass(env, env.tree, localMake);
compileStates.put(env, CompileState.LOWER);
if (shouldStop(CompileState.LOWER))
return;
//generate code for each class
for (List<JCTree> l = cdefs; l.nonEmpty(); l = l.tail) {
JCClassDecl cdef = (JCClassDecl)l.head;
results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, cdef));
}
}
finally {
log.useSource(prev);
}
} | java | {
"resource": ""
} |
q19852 | RootDocImpl.setPackages | train | private void setPackages(DocEnv env, List<String> packages) {
ListBuffer<PackageDocImpl> packlist = new ListBuffer<PackageDocImpl>();
for (String name : packages) {
PackageDocImpl pkg = env.lookupPackage(name);
if (pkg != null) {
pkg.isIncluded = true;
packlist.append(pkg);
} else {
env.warning(null, "main.no_source_files_for_package", name);
}
}
cmdLinePackages = packlist.toList();
} | java | {
"resource": ""
} |
q19853 | RootDocImpl.specifiedClasses | train | public ClassDoc[] specifiedClasses() {
ListBuffer<ClassDocImpl> classesToDocument = new ListBuffer<ClassDocImpl>();
for (ClassDocImpl cd : cmdLineClasses) {
cd.addAllClasses(classesToDocument, true);
}
return (ClassDoc[])classesToDocument.toArray(new ClassDocImpl[classesToDocument.length()]);
} | java | {
"resource": ""
} |
q19854 | EnumTypeConverter.unmarshal | train | @SuppressWarnings("unchecked")
public Object unmarshal(Object obj) throws RpcException {
if (obj == null) {
return returnNullIfOptional();
}
else if (obj.getClass() != String.class) {
String msg = "'" + obj + "' enum must be String, got: " +
obj.getClass().getSimpleName();
throw RpcException.Error.INVALID_PARAMS.exc(msg);
}
else if (e.getValues().contains((String)obj)) {
try {
Class clz = getTypeClass();
return java.lang.Enum.valueOf(clz, (String)obj);
}
catch (Exception e) {
String msg = "Could not set enum value '" + obj + "' - " +
e.getClass().getSimpleName() + " - " + e.getMessage();
throw RpcException.Error.INTERNAL.exc(msg);
}
}
else {
String msg = "'" + obj + "' is not in enum: " + e.getValues();
throw RpcException.Error.INVALID_PARAMS.exc(msg);
}
} | java | {
"resource": ""
} |
q19855 | ReportsProvider.loadReport | train | protected boolean loadReport(ReportsConfig result, InputStream report, String reportName) {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
ReportConfig reportConfig = null;
try {
reportConfig = mapper.readValue(report, ReportConfig.class);
} catch (IOException e) {
e.printStackTrace();
errors.add("Error parsing " + reportName + " " + e.getMessage());
return false;
}
reportConfig.setReportId(reportName);
result.getReports().put(reportName, reportConfig);
return true;
} | java | {
"resource": ""
} |
q19856 | ReportsProvider.getReportsConfig | train | public ReportsConfig getReportsConfig(Collection<String> restrictToNamed) {
resetErrors();
ReportsConfig result = new ReportsConfig();
InternalType[] reports = getReportList();
if (reports == null)
{
errors.add("No reports found.");
return result;
}
for (InternalType report : reports)
{
String name = "Unknown";
final String named = reportToName(report);
if (restrictToNamed != null && !restrictToNamed.contains(named)) continue;
try {
name = loadReport(result, report);
} catch (Exception e) {
errors.add("Error in report " + named + ": " + e.getMessage());
e.printStackTrace();
continue;
}
}
return result;
} | java | {
"resource": ""
} |
q19857 | SubscriptionAdjustment.get | train | public static ApruveResponse<SubscriptionAdjustment> get(
String subscriptionId, String adjustmentId) {
return ApruveClient.getInstance().get(
getSubscriptionAdjustmentsPath(subscriptionId) + adjustmentId,
SubscriptionAdjustment.class);
} | java | {
"resource": ""
} |
q19858 | SubscriptionAdjustment.getAllAdjustments | train | public static ApruveResponse<List<SubscriptionAdjustment>> getAllAdjustments(
String subscriptionId) {
return ApruveClient.getInstance().index(
getSubscriptionAdjustmentsPath(subscriptionId),
new GenericType<List<SubscriptionAdjustment>>() {
});
} | java | {
"resource": ""
} |
q19859 | SubscriptionAdjustment.create | train | public ApruveResponse<SubscriptionAdjustmentCreateResponse> create(
String subscriptionId) {
return ApruveClient.getInstance().post(
getSubscriptionAdjustmentsPath(subscriptionId), this,
SubscriptionAdjustmentCreateResponse.class);
} | java | {
"resource": ""
} |
q19860 | SubscriptionAdjustment.delete | train | public static ApruveResponse<SubscriptionAdjustmentDeleteResponse> delete(
String subscriptionId, String adjustmentId) {
return ApruveClient.getInstance().delete(
getSubscriptionAdjustmentsPath(subscriptionId) + adjustmentId,
SubscriptionAdjustmentDeleteResponse.class);
} | java | {
"resource": ""
} |
q19861 | TextWrapper.wrap | train | public String wrap(String text) {
StringBuilder sb = new StringBuilder();
int continuationLength = continuation.length();
int currentPosition = 0;
for (String word : text.split(" ")) {
String lastWord;
int wordLength = word.length();
if (currentPosition + wordLength <= width) {
if (currentPosition != 0) {
sb.append(" ");
currentPosition += 1;
}
sb.append(lastWord = word);
currentPosition += wordLength;
} else {
if (currentPosition > 0) {
sb.append(LINE_SEPARATOR);
currentPosition = 0;
}
if (wordLength > width && strict) {
int i = 0;
while (i + width < wordLength) {
sb.append(word.substring(i, width - continuationLength)).append(continuation)
.append(LINE_SEPARATOR);
i += width - continuationLength;
}
String endOfWord = word.substring(i);
sb.append(lastWord = endOfWord);
currentPosition = endOfWord.length();
} else {
sb.append(lastWord = word);
currentPosition += wordLength;
}
}
int lastNewLine = lastWord.lastIndexOf("\n");
if (lastNewLine != -1) {
currentPosition = lastWord.length() - lastNewLine;
}
}
return sb.toString();
} | java | {
"resource": ""
} |
q19862 | JavacMessager.printMessage | train | public void printMessage(Diagnostic.Kind kind, CharSequence msg,
Element e, AnnotationMirror a, AnnotationValue v) {
JavaFileObject oldSource = null;
JavaFileObject newSource = null;
JCDiagnostic.DiagnosticPosition pos = null;
JavacElements elemUtils = processingEnv.getElementUtils();
Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v);
if (treeTop != null) {
newSource = treeTop.snd.sourcefile;
if (newSource != null) {
// save the old version and reinstate it later
oldSource = log.useSource(newSource);
pos = treeTop.fst.pos();
}
}
try {
switch (kind) {
case ERROR:
errorCount++;
boolean prev = log.multipleErrors;
log.multipleErrors = true;
try {
log.error(pos, "proc.messager", msg.toString());
} finally {
log.multipleErrors = prev;
}
break;
case WARNING:
warningCount++;
log.warning(pos, "proc.messager", msg.toString());
break;
case MANDATORY_WARNING:
warningCount++;
log.mandatoryWarning(pos, "proc.messager", msg.toString());
break;
default:
log.note(pos, "proc.messager", msg.toString());
break;
}
} finally {
// reinstate the saved version, only if it was saved earlier
if (newSource != null)
log.useSource(oldSource);
}
} | java | {
"resource": ""
} |
q19863 | WhereContext.addWhereClause | train | public void addWhereClause(FreemarkerWhereClause freemarkerWhereClause) {
String outputBody = freemarkerWhereClause.getOutputBody();
if (StringUtils.isNotBlank(outputBody))
freemarkerWhereClauses.add(outputBody);
} | java | {
"resource": ""
} |
q19864 | ReflectionUtils.invoke | train | public static Object invoke(Object object, String methodName, Object ... parameters) {
Method method = getMethodThatMatchesParameters(object.getClass(), methodName, parameters);
if (method != null) {
try {
return method.invoke(object, parameters);
} catch (IllegalAccessException e) {
throw new RuntimeException("Unable to invoke method", e);
} catch (IllegalArgumentException e) {
throw new RuntimeException("Unable to invoke method", e);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException)e.getCause();
}
throw new RuntimeException(e.getCause());
}
} else {
throw new RuntimeException("No method that matches [" + methodName + "] for class " + object.getClass().getSimpleName());
}
} | java | {
"resource": ""
} |
q19865 | OutputFileWriter.getContents | train | public byte[] getContents(FileColumn[] columns, List<String[]> lines)
throws IOException
{
byte[] ret;
// Excel spreadsheet
if(format.isExcel())
{
ret = getExcelOutput(columns, lines);
}
else // Assume it's a CSV file
{
ret = getCSVOutput(lines);
}
return ret;
} | java | {
"resource": ""
} |
q19866 | OutputFileWriter.getCSVOutput | train | private byte[] getCSVOutput(List<String[]> lines)
{
StringWriter writer = new StringWriter();
csv = new CSVWriter(writer, delimiter.separator().charAt(0));
for(int i = 0; i < lines.size(); i++)
{
csv.writeNext((String[])lines.get(i), quotes);
}
// The contents returned is the CSV string
return writer.toString().getBytes();
} | java | {
"resource": ""
} |
q19867 | OutputFileWriter.getExcelOutput | train | private byte[] getExcelOutput(FileColumn[] columns, List<String[]> lines) throws IOException
{
// Create the workbook
baos = new ByteArrayOutputStream(1024);
if(existing != null)
workbook = Workbook.createWorkbook(format, baos, existing);
else
workbook = Workbook.createWorkbook(format, baos);
workbook.setHeaders(hasHeaders());
if(append && workbook.getSheet(worksheet) != null)
workbook.appendToSheet(columns, lines, worksheet);
else
workbook.createSheet(columns, lines, worksheet);
// Write out the workbook to the stream
workbook.write();
workbook.close();
// The contents returned is the byte array
return baos.toByteArray();
} | java | {
"resource": ""
} |
q19868 | MainFrame.put | train | public MainFrame put(Widget widget) {
widget.addTo(user);
content = widget != null ? widget.getID() : -1;
this.sendElement();
return this;
} | java | {
"resource": ""
} |
q19869 | SortUtils.greaterThanOrEquals | train | public static <T extends Comparable<? super T>> boolean greaterThanOrEquals(final T object,
final T other) {
return JudgeUtils.greaterThanOrEquals(object, other);
} | java | {
"resource": ""
} |
q19870 | SortUtils.greaterThan | train | public static <T extends Comparable<? super T>> boolean greaterThan(final T object,
final T other) {
return JudgeUtils.greaterThan(object, other);
} | java | {
"resource": ""
} |
q19871 | SortUtils.lessThanOrEquals | train | public static <T extends Comparable<? super T>> boolean lessThanOrEquals(final T object,
final T other) {
return JudgeUtils.lessThanOrEquals(object, other);
} | java | {
"resource": ""
} |
q19872 | SortUtils.lessThan | train | public static <T extends Comparable<? super T>> boolean lessThan(final T object, final T other) {
return JudgeUtils.lessThan(object, other);
} | java | {
"resource": ""
} |
q19873 | SortUtils.ascDeep | train | public static <T extends Comparable<? super T>> void ascDeep(final T[] comparableArray) {
if (ArrayUtils.isEmpty(comparableArray)) {
return;
}
ascByReflex(comparableArray);
} | java | {
"resource": ""
} |
q19874 | SortUtils.descDeep | train | public static <T extends Comparable<? super T>> void descDeep(final T[] comparableArray) {
if (ArrayUtils.isEmpty(comparableArray)) {
return;
}
descByReflex(comparableArray);
} | java | {
"resource": ""
} |
q19875 | SortUtils.reverse | train | public static <T> void reverse(final T array) {
if (ArrayUtils.isArray(array)) {
int mlength = Array.getLength(array) - 1;
Object temp = null;
for (int i = 0, j = mlength; i < mlength; i++, j--) {
Object arg0 = Array.get(array, i);
Object arg1 = Array.get(array, j);
temp = arg0;
Array.set(array, i, arg1);
Array.set(array, j, temp);
}
}
} | java | {
"resource": ""
} |
q19876 | ManagedPlatform.contextInitialized | train | @Override
public void contextInitialized(ServletContextEvent event) {
_registry.put(INSTANCE, new Pair<Service, Persistence>(this, null));
_context = event.getServletContext();
_application = _context.getContextPath();
_logger.config("application: " + _application);
if (_application.charAt(0) == '/') _application = _application.substring(1);
try { ManagementFactory.getPlatformMBeanServer().setAttribute(
new ObjectName("Catalina:host=localhost,name=AccessLogValve,type=Valve"), new Attribute("condition", "intrinsic")
); } catch (Exception x) {}
} | java | {
"resource": ""
} |
q19877 | Bank.plugInterfaces | train | final public void plugInterfaces(RobotAction newControl, RobotStatus newStatus, WorldInfo newWorld) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new GamePermission("connectBank"));
}
control = newControl;
info = newStatus;
world = newWorld;
} | java | {
"resource": ""
} |
q19878 | Bank.setTeamId | train | final public void setTeamId(int newId) {
if (teamId != -1) {
throw new IllegalStateException("Team Id cannot be modified");
}
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new GamePermission("setTeamId"));
}
teamId = newId;
} | java | {
"resource": ""
} |
q19879 | cufftCompatibility.stringFor | train | public static String stringFor(int m)
{
if (m == CUFFT_COMPATIBILITY_NATIVE)
{
return "CUFFT_COMPATIBILITY_NATIVE";
}
if ((m & CUFFT_COMPATIBILITY_FFTW_ALL) == CUFFT_COMPATIBILITY_FFTW_ALL)
{
return "CUFFT_COMPATIBILITY_FFTW_ALL";
}
StringBuilder sb = new StringBuilder();
if ((m & CUFFT_COMPATIBILITY_FFTW_PADDING) != 0)
{
sb.append("CUFFT_COMPATIBILITY_FFTW_PADDING ");
}
if ((m & CUFFT_COMPATIBILITY_FFTW_ASYMMETRIC) != 0)
{
sb.append("CUFFT_COMPATIBILITY_FFTW_ASYMMETRIC ");
}
return sb.toString();
} | java | {
"resource": ""
} |
q19880 | FormatUtilities.getFormattedBytes | train | static public String getFormattedBytes(long bytes, String units, String format)
{
double num = bytes;
String[] prefix = {"", "K", "M", "G", "T"};
int count = 0;
while(num >= 1024.0)
{
num = num/1024.0;
++count;
}
DecimalFormat f = new DecimalFormat(format);
return f.format(num)+" "+prefix[count]+units;
} | java | {
"resource": ""
} |
q19881 | FormatUtilities.getFormattedDate | train | static public String getFormattedDate(long dt)
{
String ret = "";
SimpleDateFormat df = null;
try
{
if(dt > 0)
{
df = formatPool.getFormat(DATE_FORMAT);
df.setTimeZone(DateUtilities.getCurrentTimeZone());
ret = df.format(new Date(dt));
}
}
catch(Exception e)
{
}
if(df != null)
formatPool.release(df);
return ret;
} | java | {
"resource": ""
} |
q19882 | FormatUtilities.getLongFormattedDays | train | static public String getLongFormattedDays(long dt)
{
StringBuffer ret = new StringBuffer();
long days = dt/86400000L;
long millis = dt-(days*86400000L);
if(days > 0)
{
ret.append(Long.toString(days));
ret.append(" day");
if(days > 1)
ret.append("s");
}
long hours = millis/3600000L;
millis = millis-(hours*3600000L);
if(hours > 0)
{
if(ret.length() > 0)
ret.append(" ");
ret.append(Long.toString(hours));
ret.append(" hour");
if(hours > 1)
ret.append("s");
}
long minutes = millis/60000L;
millis = millis-(minutes*60000L);
if(minutes > 0)
{
if(ret.length() > 0)
ret.append(" ");
ret.append(Long.toString(minutes));
ret.append(" minute");
if(minutes > 1)
ret.append("s");
}
long seconds = millis/1000L;
if(seconds > 0)
{
if(ret.length() > 0)
ret.append(" ");
ret.append(Long.toString(seconds));
ret.append(" second");
if(seconds > 1)
ret.append("s");
}
return ret.toString();
} | java | {
"resource": ""
} |
q19883 | DocEnv.loadClass | train | public ClassDocImpl loadClass(String name) {
try {
ClassSymbol c = reader.loadClass(names.fromString(name));
return getClassDoc(c);
} catch (CompletionFailure ex) {
chk.completionError(null, ex);
return null;
}
} | java | {
"resource": ""
} |
q19884 | AbstractProfileIndexWriter.buildProfileIndexFile | train | protected void buildProfileIndexFile(String title, boolean includeScript) throws IOException {
String windowOverview = configuration.getText(title);
Content body = getBody(includeScript, getWindowTitle(windowOverview));
addNavigationBarHeader(body);
addOverviewHeader(body);
addIndex(body);
addOverview(body);
addNavigationBarFooter(body);
printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
configuration.doctitle), includeScript, body);
} | java | {
"resource": ""
} |
q19885 | AbstractProfileIndexWriter.buildProfilePackagesIndexFile | train | protected void buildProfilePackagesIndexFile(String title,
boolean includeScript, String profileName) throws IOException {
String windowOverview = configuration.getText(title);
Content body = getBody(includeScript, getWindowTitle(windowOverview));
addNavigationBarHeader(body);
addOverviewHeader(body);
addProfilePackagesIndex(body, profileName);
addOverview(body);
addNavigationBarFooter(body);
printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
configuration.doctitle), includeScript, body);
} | java | {
"resource": ""
} |
q19886 | AbstractProfileIndexWriter.addIndex | train | protected void addIndex(Content body) {
addIndexContents(profiles, "doclet.Profile_Summary",
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Profile_Summary"),
configuration.getText("doclet.profiles")), body);
} | java | {
"resource": ""
} |
q19887 | AbstractProfileIndexWriter.addProfilePackagesIndex | train | protected void addProfilePackagesIndex(Content body, String profileName) {
addProfilePackagesIndexContents(profiles, "doclet.Profile_Summary",
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Profile_Summary"),
configuration.getText("doclet.profiles")), body, profileName);
} | java | {
"resource": ""
} |
q19888 | AbstractProfileIndexWriter.addIndexContents | train | protected void addIndexContents(Profiles profiles, String text,
String tableSummary, Content body) {
if (profiles.getProfileCount() > 0) {
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.addStyle(HtmlStyle.indexHeader);
addAllClassesLink(div);
addAllPackagesLink(div);
body.addContent(div);
addProfilesList(profiles, text, tableSummary, body);
}
} | java | {
"resource": ""
} |
q19889 | AbstractProfileIndexWriter.addProfilePackagesIndexContents | train | protected void addProfilePackagesIndexContents(Profiles profiles, String text,
String tableSummary, Content body, String profileName) {
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.addStyle(HtmlStyle.indexHeader);
addAllClassesLink(div);
addAllPackagesLink(div);
addAllProfilesLink(div);
body.addContent(div);
addProfilePackagesList(profiles, text, tableSummary, body, profileName);
} | java | {
"resource": ""
} |
q19890 | GeneratedDContactDaoImpl.queryByBirthday | train | public Iterable<DContact> queryByBirthday(Object parent, java.util.Date birthday) {
return queryByField(parent, DContactMapper.Field.BIRTHDAY.getFieldName(), birthday);
} | java | {
"resource": ""
} |
q19891 | GeneratedDContactDaoImpl.queryByCompanyName | train | public Iterable<DContact> queryByCompanyName(Object parent, java.lang.String companyName) {
return queryByField(parent, DContactMapper.Field.COMPANYNAME.getFieldName(), companyName);
} | java | {
"resource": ""
} |
q19892 | GeneratedDContactDaoImpl.queryByEmail | train | public Iterable<DContact> queryByEmail(Object parent, java.lang.String email) {
return queryByField(parent, DContactMapper.Field.EMAIL.getFieldName(), email);
} | java | {
"resource": ""
} |
q19893 | GeneratedDContactDaoImpl.queryByFacebook | train | public Iterable<DContact> queryByFacebook(Object parent, java.lang.String facebook) {
return queryByField(parent, DContactMapper.Field.FACEBOOK.getFieldName(), facebook);
} | java | {
"resource": ""
} |
q19894 | GeneratedDContactDaoImpl.queryByHomePhone | train | public Iterable<DContact> queryByHomePhone(Object parent, java.lang.String homePhone) {
return queryByField(parent, DContactMapper.Field.HOMEPHONE.getFieldName(), homePhone);
} | java | {
"resource": ""
} |
q19895 | GeneratedDContactDaoImpl.queryByLatitude | train | public Iterable<DContact> queryByLatitude(Object parent, java.lang.Float latitude) {
return queryByField(parent, DContactMapper.Field.LATITUDE.getFieldName(), latitude);
} | java | {
"resource": ""
} |
q19896 | GeneratedDContactDaoImpl.queryByLinkedIn | train | public Iterable<DContact> queryByLinkedIn(Object parent, java.lang.String linkedIn) {
return queryByField(parent, DContactMapper.Field.LINKEDIN.getFieldName(), linkedIn);
} | java | {
"resource": ""
} |
q19897 | GeneratedDContactDaoImpl.queryByLongitude | train | public Iterable<DContact> queryByLongitude(Object parent, java.lang.Float longitude) {
return queryByField(parent, DContactMapper.Field.LONGITUDE.getFieldName(), longitude);
} | java | {
"resource": ""
} |
q19898 | GeneratedDContactDaoImpl.queryByMobilePhone | train | public Iterable<DContact> queryByMobilePhone(Object parent, java.lang.String mobilePhone) {
return queryByField(parent, DContactMapper.Field.MOBILEPHONE.getFieldName(), mobilePhone);
} | java | {
"resource": ""
} |
q19899 | GeneratedDContactDaoImpl.queryByOtherEmail | train | public Iterable<DContact> queryByOtherEmail(Object parent, java.lang.String otherEmail) {
return queryByField(parent, DContactMapper.Field.OTHEREMAIL.getFieldName(), otherEmail);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.