_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q19500
PersistenceXMLProcessor.process
train
public void process() { try { Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources("META-INF/persistence.xml"); XMLInputFactory factory = XMLInputFactory.newInstance(); List<String> persistenceUnits = new ArrayList<String>(); while (urls.hasMoreElements()) { URL url = urls.nextElement(); XMLStreamReader reader = factory.createXMLStreamReader(url.openStream()); while (reader.hasNext()) { if (reader.next() == XMLStreamConstants.START_ELEMENT && reader.getName().getLocalPart().equals("persistence-unit")) { for (int i = 0; i < reader.getAttributeCount(); i++) { if (reader.getAttributeLocalName(i).equals("name")) { persistenceUnits.add(reader.getAttributeValue(i)); break; } } } } } this.persistenceUnits = persistenceUnits; } catch (Exception e) { logger.error("Failed to parse persistence.xml", e); } }
java
{ "resource": "" }
q19501
DownloadUtils.getInputStreamFromHttp
train
public static InputStream getInputStreamFromHttp(String httpFileURL) throws IOException { URLConnection urlConnection = null; urlConnection = new URL(httpFileURL).openConnection(); urlConnection.connect(); return urlConnection.getInputStream(); }
java
{ "resource": "" }
q19502
DownloadUtils.getBytesFromHttp
train
public static byte[] getBytesFromHttp(String httpFileURL) throws IOException { InputStream bufferedInputStream = null; try { bufferedInputStream = getInputStreamFromHttp(httpFileURL); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byte[] buffer = new byte[BUFFER_SIZE]; for (int len = 0; (len = bufferedInputStream.read(buffer)) != -1;) { byteArrayOutputStream.write(buffer, 0, len); } byte[] arrayOfByte1 = byteArrayOutputStream.toByteArray(); return arrayOfByte1; } finally { if (bufferedInputStream != null) bufferedInputStream.close(); } }
java
{ "resource": "" }
q19503
Link.make
train
public static <T> Link<T> make(Link<T> root, T object) { Link<T> link = new Link<>(object); if (root == null) { root = link; } else if (root.last == null) { root.next = link; } else { root.last.next = link; } root.last = link; return root; }
java
{ "resource": "" }
q19504
Group.foundGroupFormat
train
boolean foundGroupFormat(Map<String,?> map, String pkgFormat) { if (map.containsKey(pkgFormat)) { configuration.message.error("doclet.Same_package_name_used", pkgFormat); return true; } return false; }
java
{ "resource": "" }
q19505
Group.groupPackages
train
public Map<String,List<PackageDoc>> groupPackages(PackageDoc[] packages) { Map<String,List<PackageDoc>> groupPackageMap = new HashMap<String,List<PackageDoc>>(); String defaultGroupName = (pkgNameGroupMap.isEmpty() && regExpGroupMap.isEmpty())? configuration.message.getText("doclet.Packages") : configuration.message.getText("doclet.Other_Packages"); // if the user has not used the default group name, add it if (!groupList.contains(defaultGroupName)) { groupList.add(defaultGroupName); } for (int i = 0; i < packages.length; i++) { PackageDoc pkg = packages[i]; String pkgName = pkg.name(); String groupName = pkgNameGroupMap.get(pkgName); // if this package is not explicitly assigned to a group, // try matching it to group specified by regular expression if (groupName == null) { groupName = regExpGroupName(pkgName); } // if it is in neither group map, put it in the default // group if (groupName == null) { groupName = defaultGroupName; } getPkgList(groupPackageMap, groupName).add(pkg); } return groupPackageMap; }
java
{ "resource": "" }
q19506
Group.regExpGroupName
train
String regExpGroupName(String pkgName) { for (int j = 0; j < sortedRegExpList.size(); j++) { String regexp = sortedRegExpList.get(j); if (pkgName.startsWith(regexp)) { return regExpGroupMap.get(regexp); } } return null; }
java
{ "resource": "" }
q19507
RpcRequest.marshal
train
@SuppressWarnings("unchecked") public Map marshal(Contract contract) throws RpcException { Map map = new HashMap(); map.put("jsonrpc", "2.0"); if (id != null) map.put("id", id); map.put("method", method.getMethod()); if (params != null && params.length > 0) { Function f = contract.getFunction(getIface(), getFunc()); map.put("params", f.marshalParams(this)); } return map; }
java
{ "resource": "" }
q19508
RedisClientFactory.init
train
public void init() { int numProcessors = Runtime.getRuntime().availableProcessors(); cacheRedisClientPools = CacheBuilder.newBuilder().concurrencyLevel(numProcessors) .expireAfterAccess(3600, TimeUnit.SECONDS) .removalListener(new RemovalListener<String, JedisClientPool>() { @Override public void onRemoval(RemovalNotification<String, JedisClientPool> notification) { JedisClientPool pool = notification.getValue(); pool.destroy(); } }).build(); }
java
{ "resource": "" }
q19509
RedisClientFactory.calcRedisPoolName
train
protected static String calcRedisPoolName(String host, int port, String username, String password, PoolConfig poolConfig) { StringBuilder sb = new StringBuilder(); sb.append(host != null ? host : "NULL"); sb.append("."); sb.append(port); sb.append("."); sb.append(username != null ? username : "NULL"); sb.append("."); int passwordHashcode = password != null ? password.hashCode() : "NULL".hashCode(); int poolHashcode = poolConfig != null ? poolConfig.hashCode() : "NULL".hashCode(); return sb.append(passwordHashcode).append(".").append(poolHashcode).toString(); }
java
{ "resource": "" }
q19510
JavacProcessingEnvironment.importStringToPattern
train
private static Pattern importStringToPattern(String s, Processor p, Log log) { if (isValidImportString(s)) { return validImportStringToPattern(s); } else { log.warning("proc.malformed.supported.string", s, p.getClass().getName()); return noMatches; // won't match any valid identifier } }
java
{ "resource": "" }
q19511
BuilderFactory.getProfileSummaryBuilder
train
public AbstractBuilder getProfileSummaryBuilder(Profile profile, Profile prevProfile, Profile nextProfile) throws Exception { return ProfileSummaryBuilder.getInstance(context, profile, writerFactory.getProfileSummaryWriter(profile, prevProfile, nextProfile)); }
java
{ "resource": "" }
q19512
BuilderFactory.getProfilePackageSummaryBuilder
train
public AbstractBuilder getProfilePackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg, PackageDoc nextPkg, Profile profile) throws Exception { return ProfilePackageSummaryBuilder.getInstance(context, pkg, writerFactory.getProfilePackageSummaryWriter(pkg, prevPkg, nextPkg, profile), profile); }
java
{ "resource": "" }
q19513
ParamTaglet.getInheritedTagletOutput
train
private Content getInheritedTagletOutput(boolean isNonTypeParams, Doc holder, TagletWriter writer, Object[] formalParameters, Set<String> alreadyDocumented) { Content result = writer.getOutputInstance(); if ((! alreadyDocumented.contains(null)) && holder instanceof MethodDoc) { for (int i = 0; i < formalParameters.length; i++) { if (alreadyDocumented.contains(String.valueOf(i))) { continue; } //This parameter does not have any @param documentation. //Try to inherit it. DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) holder, this, String.valueOf(i), ! isNonTypeParams)); if (inheritedDoc.inlineTags != null && inheritedDoc.inlineTags.length > 0) { result.addContent( processParamTag(isNonTypeParams, writer, (ParamTag) inheritedDoc.holderTag, isNonTypeParams ? ((Parameter) formalParameters[i]).name(): ((TypeVariable) formalParameters[i]).typeName(), alreadyDocumented.size() == 0)); } alreadyDocumented.add(String.valueOf(i)); } } return result; }
java
{ "resource": "" }
q19514
TimeLimitedStrategy.observe
train
@Override public void observe(int age) throws InterruptedException { if (System.currentTimeMillis() >= _limit) { throw new InterruptedException("Time{" + System.currentTimeMillis() + "}HasPassed{" + _limit + '}'); } }
java
{ "resource": "" }
q19515
JavacElements.nameToSymbol
train
private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.classes.get(name) : syms.packages.get(name); try { if (sym == null) sym = javaCompiler.resolveIdent(nameStr); sym.complete(); return (sym.kind != Kinds.ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
java
{ "resource": "" }
q19516
TextUtils.leftPad
train
public static String leftPad(String text, String padding, int linesToIgnore) { StringBuilder result = new StringBuilder(); Matcher matcher = LINE_START_PATTERN.matcher(text); while (matcher.find()) { if (linesToIgnore > 0) { linesToIgnore--; } else { result.append(padding); } result.append(matcher.group()).append("\n"); } return result.toString(); }
java
{ "resource": "" }
q19517
AnnotationPredicates.classOrAncestorAnnotatedWith
train
public static Predicate<Class<?>> classOrAncestorAnnotatedWith(final Class<? extends Annotation> annotationClass, boolean includeMetaAnnotations) { return candidate -> candidate != null && Classes.from(candidate) .traversingSuperclasses() .traversingInterfaces() .classes() .anyMatch(elementAnnotatedWith(annotationClass, includeMetaAnnotations)); }
java
{ "resource": "" }
q19518
AnnotationPredicates.annotationIsOfClass
train
public static Predicate<Annotation> annotationIsOfClass(final Class<? extends Annotation> annotationClass) { return candidate -> candidate != null && candidate.annotationType().equals(annotationClass); }
java
{ "resource": "" }
q19519
AnnotationPredicates.atLeastOneFieldAnnotatedWith
train
public static Predicate<Class<?>> atLeastOneFieldAnnotatedWith(final Class<? extends Annotation> annotationClass, boolean includeMetaAnnotations) { return candidate -> candidate != null && Classes.from(candidate) .traversingSuperclasses() .fields() .anyMatch(elementAnnotatedWith(annotationClass, includeMetaAnnotations)); }
java
{ "resource": "" }
q19520
AnnotationPredicates.atLeastOneMethodAnnotatedWith
train
public static Predicate<Class<?>> atLeastOneMethodAnnotatedWith(final Class<? extends Annotation> annotationClass, boolean includeMetaAnnotations) { return candidate -> Classes.from(candidate) .traversingInterfaces() .traversingSuperclasses() .methods() .anyMatch(elementAnnotatedWith(annotationClass, includeMetaAnnotations)); }
java
{ "resource": "" }
q19521
VATINSyntaxChecker.isValidVATIN
train
public static boolean isValidVATIN (@Nonnull final String sVATIN, final boolean bIfNoValidator) { ValueEnforcer.notNull (sVATIN, "VATIN"); if (sVATIN.length () > 2) { final String sCountryCode = sVATIN.substring (0, 2).toUpperCase (Locale.US); final IToBooleanFunction <String> aValidator = s_aMap.get (sCountryCode); if (aValidator != null) return aValidator.applyAsBoolean (sVATIN.substring (2)); } // No validator return bIfNoValidator; }
java
{ "resource": "" }
q19522
VATINSyntaxChecker.isValidatorPresent
train
public static boolean isValidatorPresent (@Nonnull final String sVATIN) { ValueEnforcer.notNull (sVATIN, "VATIN"); if (sVATIN.length () <= 2) return false; final String sCountryCode = sVATIN.substring (0, 2).toUpperCase (Locale.US); return s_aMap.containsKey (sCountryCode); }
java
{ "resource": "" }
q19523
HtmlDocWriter.printFramesetDocument
train
public void printFramesetDocument(String title, boolean noTimeStamp, Content frameset) throws IOException { Content htmlDocType = DocType.FRAMESET; Content htmlComment = new Comment(configuration.getText("doclet.New_Page")); Content head = new HtmlTree(HtmlTag.HEAD); head.addContent(getGeneratedBy(!noTimeStamp)); if (configuration.charset.length() > 0) { Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE, configuration.charset); head.addContent(meta); } Content windowTitle = HtmlTree.TITLE(new StringContent(title)); head.addContent(windowTitle); head.addContent(getFramesetJavaScript()); Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), head, frameset); Content htmlDocument = new HtmlDocument(htmlDocType, htmlComment, htmlTree); write(htmlDocument); }
java
{ "resource": "" }
q19524
JavacParser.skip
train
private void skip(boolean stopAtImport, boolean stopAtMemberDecl, boolean stopAtIdentifier, boolean stopAtStatement) { while (true) { switch (token.kind) { case SEMI: nextToken(); return; case PUBLIC: case FINAL: case ABSTRACT: case MONKEYS_AT: case EOF: case CLASS: case INTERFACE: case ENUM: return; case IMPORT: if (stopAtImport) return; break; case LBRACE: case RBRACE: case PRIVATE: case PROTECTED: case STATIC: case TRANSIENT: case NATIVE: case VOLATILE: case SYNCHRONIZED: case STRICTFP: case LT: case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case VOID: if (stopAtMemberDecl) return; break; case UNDERSCORE: case IDENTIFIER: if (stopAtIdentifier) return; break; case CASE: case DEFAULT: case IF: case FOR: case WHILE: case DO: case TRY: case SWITCH: case RETURN: case THROW: case BREAK: case CONTINUE: case ELSE: case FINALLY: case CATCH: if (stopAtStatement) return; break; } nextToken(); } }
java
{ "resource": "" }
q19525
JavacParser.checkNoMods
train
void checkNoMods(long mods) { if (mods != 0) { long lowestMod = mods & -mods; error(token.pos, "mod.not.allowed.here", Flags.asFlagSet(lowestMod)); } }
java
{ "resource": "" }
q19526
JavacParser.attach
train
void attach(JCTree tree, Comment dc) { if (keepDocComments && dc != null) { // System.out.println("doc comment = ");System.out.println(dc);//DEBUG docComments.putComment(tree, dc); } }
java
{ "resource": "" }
q19527
JavacParser.forInit
train
List<JCStatement> forInit() { ListBuffer<JCStatement> stats = new ListBuffer<>(); int pos = token.pos; if (token.kind == FINAL || token.kind == MONKEYS_AT) { return variableDeclarators(optFinal(0), parseType(), stats).toList(); } else { JCExpression t = term(EXPR | TYPE); if ((lastmode & TYPE) != 0 && LAX_IDENTIFIER.accepts(token.kind)) { return variableDeclarators(mods(pos, 0, List.<JCAnnotation>nil()), t, stats).toList(); } else if ((lastmode & TYPE) != 0 && token.kind == COLON) { error(pos, "bad.initializer", "for-loop"); return List.of((JCStatement)F.at(pos).VarDef(null, null, t, null)); } else { return moreStatementExpressions(pos, t, stats).toList(); } } }
java
{ "resource": "" }
q19528
JavacParser.resource
train
protected JCTree resource() { JCModifiers optFinal = optFinal(Flags.FINAL); JCExpression type = parseType(); int pos = token.pos; Name ident = ident(); return variableDeclaratorRest(pos, optFinal, type, ident, true, null); }
java
{ "resource": "" }
q19529
VitalTask.run
train
public final void run() { _interrupted = null; _age = 0; while (true) { try { _strategy.observe(_age); if (_preparation != null) _preparation.run(); _result = execute(); if (_age > 0) { _reporting.emit(Level.INFO, "Failure recovered: " + toString(), _age, _logger); } break; } catch (InterruptedException x) { _logger.log(Level.WARNING, "Interrupted, age = " + _age, x); _interrupted = x; break; } catch (Exception x) { _reporting.emit(x, "Failure detected, age = " + _age, _age, _logger); try { _strategy.backoff(_age); } catch (InterruptedException i) { _logger.log(Level.WARNING, "Interrupted, age = " + _age, x); _interrupted = i; break; } ++_age; } } }
java
{ "resource": "" }
q19530
FileReportsProvider.loadReport
train
protected void loadReport(ReportsConfig result, File report, String reportId) throws IOException { if (report.isDirectory()) { FilenameFilter configYamlFilter = new PatternFilenameFilter("^reportconf.(yaml|json)$"); File[] selectYaml = report.listFiles(configYamlFilter); if (selectYaml != null && selectYaml.length == 1) { File selectedYaml = selectYaml[0]; loadReport(result, FileUtils.openInputStream(selectedYaml), reportId); } } }
java
{ "resource": "" }
q19531
RpcException.toMap
train
@SuppressWarnings("unchecked") public Map toMap() { HashMap map = new HashMap(); map.put("code", code); map.put("message", message); if (data != null) map.put("data", data); return map; }
java
{ "resource": "" }
q19532
Options.lint
train
public boolean lint(String s) { // return true if either the specific option is enabled, or // they are all enabled without the specific one being // disabled return isSet(XLINT_CUSTOM, s) || (isSet(XLINT) || isSet(XLINT_CUSTOM, "all")) && isUnset(XLINT_CUSTOM, "-" + s); }
java
{ "resource": "" }
q19533
OAuth2AuthorizationResource.refreshAccessToken
train
@POST @Path("refresh") @Consumes(MediaType.APPLICATION_JSON) public Response refreshAccessToken(RefreshTokenRequest refreshToken) { // Perform all validation here to control the exact error message returned to comply with the Oauth2 standard if (null == refreshToken.getRefresh_token() || null == refreshToken.getGrant_type()) { throw new BadRequestRestException(ImmutableMap.of("error", "invalid_request")); } if (!REFRESH_TOKEN_GRANT_TYPE.equals(refreshToken.getGrant_type())) { // Unsupported grant type throw new BadRequestRestException(ImmutableMap.of("error", "unsupported_grant_type")); } DConnection connection = connectionDao.findByRefreshToken(refreshToken.getRefresh_token()); if (null == connection) { throw new BadRequestRestException(ImmutableMap.of("error", "invalid_grant")); } // Invalidate the old cache key connectionDao.invalidateCacheKey(connection.getAccessToken()); connection.setAccessToken(accessTokenGenerator.generate()); connection.setExpireTime(calculateExpirationDate(tokenExpiresIn)); connectionDao.putWithCacheKey(connection.getAccessToken(), connection); return Response.ok(ImmutableMap.builder() .put("access_token", connection.getAccessToken()) .put("refresh_token", connection.getRefreshToken()) .put("expires_in", tokenExpiresIn) .build()) .cookie(createCookie(connection.getAccessToken(), tokenExpiresIn)) .build(); }
java
{ "resource": "" }
q19534
OAuth2AuthorizationResource.validate
train
@GET @Path("tokeninfo") public Response validate(@QueryParam("access_token") String access_token) { checkNotNull(access_token); DConnection connection = connectionDao.findByAccessToken(access_token); LOGGER.debug("Connection {}", connection); if (null == connection || hasAccessTokenExpired(connection)) { throw new BadRequestRestException("Invalid access_token"); } return Response.ok(ImmutableMap.builder() .put("user_id", connection.getUserId()) .put("expires_in", Seconds.secondsBetween(DateTime.now(), new DateTime(connection.getExpireTime())).getSeconds()) .build()) .build(); }
java
{ "resource": "" }
q19535
OAuth2AuthorizationResource.logout
train
@GET @Path("logout") public Response logout() throws URISyntaxException { return Response .temporaryRedirect(new URI("/")) .cookie(createCookie(null, 0)) .build(); }
java
{ "resource": "" }
q19536
DocFinder.search
train
public static Output search(Input input) { Output output = new Output(); if (input.isInheritDocTag) { //Do nothing because "element" does not have any documentation. //All it has it {@inheritDoc}. } else if (input.taglet == null) { //We want overall documentation. output.inlineTags = input.isFirstSentence ? input.element.firstSentenceTags() : input.element.inlineTags(); output.holder = input.element; } else { input.taglet.inherit(input, output); } if (output.inlineTags != null && output.inlineTags.length > 0) { return output; } output.isValidInheritDocTag = false; Input inheritedSearchInput = input.copy(); inheritedSearchInput.isInheritDocTag = false; if (input.element instanceof MethodDoc) { MethodDoc overriddenMethod = ((MethodDoc) input.element).overriddenMethod(); if (overriddenMethod != null) { inheritedSearchInput.element = overriddenMethod; output = search(inheritedSearchInput); output.isValidInheritDocTag = true; if (output.inlineTags.length > 0) { return output; } } //NOTE: When we fix the bug where ClassDoc.interfaceTypes() does // not pass all implemented interfaces, we will use the // appropriate element here. MethodDoc[] implementedMethods = (new ImplementedMethods((MethodDoc) input.element, null)).build(false); for (int i = 0; i < implementedMethods.length; i++) { inheritedSearchInput.element = implementedMethods[i]; output = search(inheritedSearchInput); output.isValidInheritDocTag = true; if (output.inlineTags.length > 0) { return output; } } } else if (input.element instanceof ClassDoc) { ProgramElementDoc superclass = ((ClassDoc) input.element).superclass(); if (superclass != null) { inheritedSearchInput.element = superclass; output = search(inheritedSearchInput); output.isValidInheritDocTag = true; if (output.inlineTags.length > 0) { return output; } } } return output; }
java
{ "resource": "" }
q19537
BarristerServlet.init
train
public void init(ServletConfig config) throws ServletException { try { String idlPath = config.getInitParameter("idl"); if (idlPath == null) { throw new ServletException("idl init param is required. Set to path to .json file, or classpath:/mycontract.json"); } if (idlPath.startsWith("classpath:")) { idlPath = idlPath.substring(10); contract = Contract.load(getClass().getResourceAsStream(idlPath)); } else { contract = Contract.load(new File(idlPath)); } server = new Server(contract); int handlerCount = 0; Enumeration params = config.getInitParameterNames(); while (params.hasMoreElements()) { String key = params.nextElement().toString(); if (key.indexOf("handler.") == 0) { String val = config.getInitParameter(key); int pos = val.indexOf("="); if (pos == -1) { throw new ServletException("Invalid init param: key=" + key + " value=" + val + " -- should be: interfaceClass=implClass"); } String ifaceCname = val.substring(0, pos); String implCname = val.substring(pos+1); Class ifaceClazz = Class.forName(ifaceCname); Class implClazz = Class.forName(implCname); server.addHandler(ifaceClazz, implClazz.newInstance()); handlerCount++; } } if (handlerCount == 0) { throw new ServletException("At least one handler.x init property is required"); } } catch (ServletException e) { throw e; } catch (Exception e) { throw new ServletException(e); } }
java
{ "resource": "" }
q19538
HtmlDocletWriter.getTargetProfilePackageLink
train
public Content getTargetProfilePackageLink(PackageDoc pd, String target, Content label, String profileName) { return getHyperLink(pathString(pd, DocPaths.profilePackageSummary(profileName)), label, "", target); }
java
{ "resource": "" }
q19539
HtmlDocletWriter.getTargetProfileLink
train
public Content getTargetProfileLink(String target, Content label, String profileName) { return getHyperLink(pathToRoot.resolve( DocPaths.profileSummary(profileName)), label, "", target); }
java
{ "resource": "" }
q19540
HtmlDocletWriter.getTypeNameForProfile
train
public String getTypeNameForProfile(ClassDoc cd) { StringBuilder typeName = new StringBuilder((cd.containingPackage()).name().replace(".", "/")); typeName.append("/") .append(cd.name().replace(".", "$")); return typeName.toString(); }
java
{ "resource": "" }
q19541
HtmlDocletWriter.isTypeInProfile
train
public boolean isTypeInProfile(ClassDoc cd, int profileValue) { return (configuration.profiles.getProfile(getTypeNameForProfile(cd)) <= profileValue); }
java
{ "resource": "" }
q19542
HtmlDocletWriter.addBottom
train
public void addBottom(Content body) { Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom)); Content small = HtmlTree.SMALL(bottom); Content p = HtmlTree.P(HtmlStyle.legalCopy, small); body.addContent(p); }
java
{ "resource": "" }
q19543
HtmlDocletWriter.addPackageDeprecatedAPI
train
protected void addPackageDeprecatedAPI(List<Doc> deprPkgs, String headingKey, String tableSummary, String[] tableHeader, Content contentTree) { if (deprPkgs.size() > 0) { Content table = HtmlTree.TABLE(HtmlStyle.deprecatedSummary, 0, 3, 0, tableSummary, getTableCaption(configuration.getResource(headingKey))); table.addContent(getSummaryTableHeader(tableHeader, "col")); Content tbody = new HtmlTree(HtmlTag.TBODY); for (int i = 0; i < deprPkgs.size(); i++) { PackageDoc pkg = (PackageDoc) deprPkgs.get(i); HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, getPackageLink(pkg, getPackageName(pkg))); if (pkg.tags("deprecated").length > 0) { addInlineDeprecatedComment(pkg, pkg.tags("deprecated")[0], td); } HtmlTree tr = HtmlTree.TR(td); if (i % 2 == 0) { tr.addStyle(HtmlStyle.altColor); } else { tr.addStyle(HtmlStyle.rowColor); } tbody.addContent(tr); } table.addContent(tbody); Content li = HtmlTree.LI(HtmlStyle.blockList, table); Content ul = HtmlTree.UL(HtmlStyle.blockList, li); contentTree.addContent(ul); } }
java
{ "resource": "" }
q19544
HtmlDocletWriter.getScriptProperties
train
public HtmlTree getScriptProperties() { HtmlTree script = HtmlTree.SCRIPT("text/javascript", pathToRoot.resolve(DocPaths.JAVASCRIPT).getPath()); return script; }
java
{ "resource": "" }
q19545
HtmlDocletWriter.addAnnotationInfo
train
private boolean addAnnotationInfo(int indent, Doc doc, AnnotationDesc[] descList, boolean lineBreak, Content htmltree) { List<Content> annotations = getAnnotations(indent, descList, lineBreak); String sep =""; if (annotations.isEmpty()) { return false; } for (Content annotation: annotations) { htmltree.addContent(sep); htmltree.addContent(annotation); sep = " "; } return true; }
java
{ "resource": "" }
q19546
Payment.get
train
public static ApruveResponse<Payment> get(String paymentRequestId, String paymentId) { return ApruveClient.getInstance().get( getPaymentsPath(paymentRequestId) + paymentId, Payment.class); }
java
{ "resource": "" }
q19547
Payment.getAll
train
public static ApruveResponse<List<Payment>> getAll(String paymentRequestId) { return ApruveClient.getInstance().index( getPaymentsPath(paymentRequestId), new GenericType<List<Payment>>() { }); }
java
{ "resource": "" }
q19548
BaseBundleActivator.init
train
public void init() { Dictionary<String, String> properties = getConfigurationProperties(this.getProperties(), false); this.setProperties(properties); this.setProperty(BundleConstants.SERVICE_PID, getServicePid()); this.setProperty(BundleConstants.SERVICE_CLASS, getServiceClassName()); }
java
{ "resource": "" }
q19549
BaseBundleActivator.start
train
public void start(BundleContext context) throws Exception { ClassServiceUtility.log(context, LogService.LOG_INFO, "Starting " + this.getClass().getName() + " Bundle"); this.context = context; this.init(); // Setup the properties String interfaceClassName = getInterfaceClassName(); this.setProperty(BundleConstants.ACTIVATOR, this.getClass().getName()); // In case I have to find this service by activator class try { context.addServiceListener(this, ClassServiceUtility.addToFilter((String)null, Constants.OBJECTCLASS, interfaceClassName)); } catch (InvalidSyntaxException e) { e.printStackTrace(); } if (service == null) { boolean allStarted = this.checkDependentServices(context); if (allStarted) { service = this.startupService(context); this.registerService(service); } } }
java
{ "resource": "" }
q19550
BaseBundleActivator.stop
train
public void stop(BundleContext context) throws Exception { ClassServiceUtility.log(context, LogService.LOG_INFO, "Stopping " + this.getClass().getName() + " Bundle"); if (this.shutdownService(service, context)) service = null; // Unregisters automatically this.context = null; }
java
{ "resource": "" }
q19551
BaseBundleActivator.registerService
train
public void registerService(Object service) { this.setService(service); String serviceClass = getInterfaceClassName(); if (service != null) serviceRegistration = context.registerService(serviceClass, this.service, properties); }
java
{ "resource": "" }
q19552
BaseBundleActivator.getService
train
public Object getService(String interfaceClassName, String serviceClassName, String versionRange, Dictionary<String,String> filter) { return ClassServiceUtility.getClassService().getClassFinder(context).getClassBundleService(interfaceClassName, serviceClassName, versionRange, filter, -1); }
java
{ "resource": "" }
q19553
BaseBundleActivator.getServicePid
train
public String getServicePid() { String servicePid = context.getProperty(BundleConstants.SERVICE_PID); if (servicePid != null) return servicePid; servicePid = this.getServiceClassName(); if (servicePid == null) servicePid = this.getClass().getName(); return ClassFinderActivator.getPackageName(servicePid, false); }
java
{ "resource": "" }
q19554
BaseBundleActivator.putAll
train
public static Dictionary<String, String> putAll(Dictionary<String, String> sourceDictionary, Dictionary<String, String> destDictionary) { if (destDictionary == null) destDictionary = new Hashtable<String, String>(); if (sourceDictionary != null) { Enumeration<String> keys = sourceDictionary.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); destDictionary.put(key, sourceDictionary.get(key)); } } return destDictionary; }
java
{ "resource": "" }
q19555
CollectionUtils.getFirstNotNullValue
train
public static <T> T getFirstNotNullValue(final Collection<T> collection) { if (isNotEmpty(collection)) { for (T element : collection) { if (element != null) { return element; } } } return null; }
java
{ "resource": "" }
q19556
CollectionUtils.toList
train
public static <T> List<T> toList(final Collection<T> collection) { if (isEmpty(collection)) { return new ArrayList<T>(0); } else { return new ArrayList<T>(collection); } }
java
{ "resource": "" }
q19557
CollectionUtils.toSet
train
public static <T> Set<T> toSet(final Collection<T> collection) { if (isEmpty(collection)) { return new HashSet<T>(0); } else { return new HashSet<T>(collection); } }
java
{ "resource": "" }
q19558
CollectionUtils.toArray
train
public static <T> T[] toArray(final Collection<T> collection) { T next = getFirstNotNullValue(collection); if (next != null) { Object[] objects = collection.toArray(); @SuppressWarnings("unchecked") T[] convertedObjects = (T[]) Array.newInstance(next.getClass(), objects.length); System.arraycopy(objects, 0, convertedObjects, 0, objects.length); return convertedObjects; } else { return null; } }
java
{ "resource": "" }
q19559
DatabaseService.setMappings
train
public void setMappings(List<String> mappings) { if (mappings.size() > 0) { @SuppressWarnings("unchecked") Pair<String, String>[] renames = (Pair<String, String>[])Array.newInstance(Pair.class, mappings.size()); for (int i = 0; i < _renames.length; ++i) { String[] names = mappings.get(i).split("[ ,]+"); renames[i] = new Pair<String, String>(names[0], names[1]); } _renames = renames; } }
java
{ "resource": "" }
q19560
ContinentHelper.getContinentsOfCountry
train
@Nullable @ReturnsMutableCopy public static ICommonsNavigableSet <EContinent> getContinentsOfCountry (@Nullable final Locale aLocale) { final Locale aCountry = CountryCache.getInstance ().getCountry (aLocale); if (aCountry != null) { final ICommonsNavigableSet <EContinent> ret = s_aMap.get (aCountry); if (ret != null) return ret.getClone (); } return null; }
java
{ "resource": "" }
q19561
Cargo.isLoadable
train
public boolean isLoadable() { if (getPayload() instanceof NullPayload) { return false; } try { InputStream is = getInputStream(); try { is.read(); return true; } finally { is.close(); } } catch (IOException ex) { return false; } }
java
{ "resource": "" }
q19562
Cargo.loadString
train
public String loadString(String encoding) throws IOException { byte[] bytes = loadByteArray(); ByteOrderMask bom = ByteOrderMask.valueOf(bytes); if(bom != null){ int offset = (bom.getBytes()).length; return new String(bytes, offset, bytes.length - offset, bom.getEncoding()); } return new String(bytes, encoding); }
java
{ "resource": "" }
q19563
StreamTransfer.transfer
train
public Result transfer(long count) { if (count < 0L) throw new IllegalArgumentException("negative count"); return buffer == null ? transferNoBuffer(count) : transferBuffered(count); }
java
{ "resource": "" }
q19564
TreePath.getPath
train
public static TreePath getPath(TreePath path, Tree target) { path.getClass(); target.getClass(); class Result extends Error { static final long serialVersionUID = -5942088234594905625L; TreePath path; Result(TreePath path) { this.path = path; } } class PathFinder extends TreePathScanner<TreePath,Tree> { public TreePath scan(Tree tree, Tree target) { if (tree == target) { throw new Result(new TreePath(getCurrentPath(), target)); } return super.scan(tree, target); } } if (path.getLeaf() == target) { return path; } try { new PathFinder().scan(path, target); } catch (Result result) { return result.path; } return null; }
java
{ "resource": "" }
q19565
Reifier.addTypeSet
train
public Reifier addTypeSet(Class<?> spec) { for (Field field: spec.getDeclaredFields()) { if (Modifier.isPublic(field.getModifiers())) { String name = field.getName(); try { _named.put(name, new Validator(name, field.getType(), field)); } catch (IllegalArgumentException x) { Trace.g.std.note(Reifier.class, "Ignored " + name + ": " + x.getMessage()); } } else { Trace.g.std.note(Reifier.class, "Ignored non-public field: " + field.getName()); } } return this; }
java
{ "resource": "" }
q19566
Reifier.collect
train
public <T extends DataObject> T collect(T data, Map<String, String> binder) throws SecurityException, DataValidationException { return collect(data, binder, null); }
java
{ "resource": "" }
q19567
CurrencyHelper.localeSupportsCurrencyRetrieval
train
public static boolean localeSupportsCurrencyRetrieval (@Nullable final Locale aLocale) { return aLocale != null && aLocale.getCountry () != null && aLocale.getCountry ().length () == 2; }
java
{ "resource": "" }
q19568
CurrencyHelper.parseCurrency
train
@Nullable public static BigDecimal parseCurrency (@Nullable final String sStr, @Nonnull final DecimalFormat aFormat, @Nullable final BigDecimal aDefault, @Nonnull final RoundingMode eRoundingMode) { // Shortcut if (StringHelper.hasNoText (sStr)) return aDefault; // So that the call to "parse" returns a BigDecimal aFormat.setParseBigDecimal (true); aFormat.setRoundingMode (eRoundingMode); // Parse as double final BigDecimal aNum = LocaleParser.parseBigDecimal (sStr, aFormat); if (aNum == null) return aDefault; // And finally do the correct scaling, depending of the decimal format // fraction return aNum.setScale (aFormat.getMaximumFractionDigits (), eRoundingMode); }
java
{ "resource": "" }
q19569
CurrencyHelper._getTextValueForDecimalSeparator
train
@Nullable private static String _getTextValueForDecimalSeparator (@Nullable final String sTextValue, @Nonnull final EDecimalSeparator eDecimalSep, @Nonnull final EGroupingSeparator eGroupingSep) { ValueEnforcer.notNull (eDecimalSep, "DecimalSeparator"); ValueEnforcer.notNull (eGroupingSep, "GroupingSeparator"); final String ret = StringHelper.trim (sTextValue); // Replace only, if the desired decimal separator is not present if (ret != null && ret.indexOf (eDecimalSep.getChar ()) < 0) switch (eDecimalSep) { case COMMA: { // Decimal separator is a "," if (ret.indexOf ('.') > -1 && eGroupingSep.getChar () != '.') { // Currency expects "," but user passed "." return StringHelper.replaceAll (ret, '.', eDecimalSep.getChar ()); } break; } case POINT: { // Decimal separator is a "." if (ret.indexOf (',') > -1 && eGroupingSep.getChar () != ',') { // Pattern contains no "," but value contains "," return StringHelper.replaceAll (ret, ',', eDecimalSep.getChar ()); } break; } default: throw new IllegalStateException ("Unexpected decimal separator [" + eDecimalSep + "]"); } return ret; }
java
{ "resource": "" }
q19570
CurrencyHelper.setRoundingMode
train
public static void setRoundingMode (@Nullable final ECurrency eCurrency, @Nullable final RoundingMode eRoundingMode) { getSettings (eCurrency).setRoundingMode (eRoundingMode); }
java
{ "resource": "" }
q19571
Types.functionalInterfaceBridges
train
public List<Symbol> functionalInterfaceBridges(TypeSymbol origin) { Assert.check(isFunctionalInterface(origin)); Symbol descSym = findDescriptorSymbol(origin); CompoundScope members = membersClosure(origin.type, false); ListBuffer<Symbol> overridden = new ListBuffer<>(); outer: for (Symbol m2 : members.getElementsByName(descSym.name, bridgeFilter)) { if (m2 == descSym) continue; else if (descSym.overrides(m2, origin, Types.this, false)) { for (Symbol m3 : overridden) { if (isSameType(m3.erasure(Types.this), m2.erasure(Types.this)) || (m3.overrides(m2, origin, Types.this, false) && (pendingBridges((ClassSymbol)origin, m3.enclClass()) || (((MethodSymbol)m2).binaryImplementation((ClassSymbol)m3.owner, Types.this) != null)))) { continue outer; } } overridden.add(m2); } } return overridden.toList(); }
java
{ "resource": "" }
q19572
Types.isEqualityComparable
train
public boolean isEqualityComparable(Type s, Type t, Warner warn) { if (t.isNumeric() && s.isNumeric()) return true; boolean tPrimitive = t.isPrimitive(); boolean sPrimitive = s.isPrimitive(); if (!tPrimitive && !sPrimitive) { return isCastable(s, t, warn) || isCastable(t, s, warn); } else { return false; } }
java
{ "resource": "" }
q19573
Types.elemtype
train
public Type elemtype(Type t) { switch (t.getTag()) { case WILDCARD: return elemtype(wildUpperBound(t)); case ARRAY: t = t.unannotatedType(); return ((ArrayType)t).elemtype; case FORALL: return elemtype(((ForAll)t).qtype); case ERROR: return t; default: return null; } }
java
{ "resource": "" }
q19574
Types.rank
train
public int rank(Type t) { t = t.unannotatedType(); switch(t.getTag()) { case CLASS: { ClassType cls = (ClassType)t; if (cls.rank_field < 0) { Name fullname = cls.tsym.getQualifiedName(); if (fullname == names.java_lang_Object) cls.rank_field = 0; else { int r = rank(supertype(cls)); for (List<Type> l = interfaces(cls); l.nonEmpty(); l = l.tail) { if (rank(l.head) > r) r = rank(l.head); } cls.rank_field = r + 1; } } return cls.rank_field; } case TYPEVAR: { TypeVar tvar = (TypeVar)t; if (tvar.rank_field < 0) { int r = rank(supertype(tvar)); for (List<Type> l = interfaces(tvar); l.nonEmpty(); l = l.tail) { if (rank(l.head) > r) r = rank(l.head); } tvar.rank_field = r + 1; } return tvar.rank_field; } case ERROR: case NONE: return 0; default: throw new AssertionError(); } }
java
{ "resource": "" }
q19575
Types.covariantReturnType
train
public boolean covariantReturnType(Type t, Type s, Warner warner) { return isSameType(t, s) || allowCovariantReturns && !t.isPrimitive() && !s.isPrimitive() && isAssignable(t, s, warner); }
java
{ "resource": "" }
q19576
Types.boxedClass
train
public ClassSymbol boxedClass(Type t) { return reader.enterClass(syms.boxedName[t.getTag().ordinal()]); }
java
{ "resource": "" }
q19577
AbstractSpaceResource.getSpace
train
protected String getSpace(Request req) { String spaceToken = req.headers(SPACE_TOKEN_HEADER); if (StringUtils.isBlank(spaceToken)) { throw new MissingSpaceTokenException("Missing header '" + SPACE_TOKEN_HEADER + "'."); } String space = this.spacesService.getSpaceForAuthenticationToken(spaceToken); if (space == null) { throw new InvalidSpaceTokenException(spaceToken); } return space; }
java
{ "resource": "" }
q19578
LeastRecentlyUsedMap.getCacheState
train
public WithCache.CacheState getCacheState() { return new WithCache.CacheState(size(), _max, _get, _hit, _rep); }
java
{ "resource": "" }
q19579
TruggerGenericTypeResolver.resolveParameterName
train
static Class<?> resolveParameterName(String parameterName, Class<?> target) { Map<Type, Type> typeVariableMap = getTypeVariableMap(target); Set<Entry<Type, Type>> set = typeVariableMap.entrySet(); Type type = Object.class; for (Entry<Type, Type> entry : set) { if (entry.getKey().toString().equals(parameterName)) { type = entry.getKey(); break; } } return resolveType(type, typeVariableMap); }
java
{ "resource": "" }
q19580
AbstractPanel.putFactories
train
public List<Widget> putFactories(Iterable<? extends IWidgetFactory> factories) throws IndexOutOfBoundsException { List<Widget> instances = new LinkedList<Widget>(); for (IWidgetFactory factory : factories) { instances.add(put(factory)); } return instances; }
java
{ "resource": "" }
q19581
DiskSpoolEventWriter.getSpooledFileList
train
protected List<File> getSpooledFileList() { final List<File> spooledFileList = new ArrayList<File>(); for (final File file : spoolDirectory.listFiles()) { if (file.isFile()) { spooledFileList.add(file); } } return spooledFileList; }
java
{ "resource": "" }
q19582
ApplicationCache.add
train
public void add(Collection<Application> applications) { for(Application application : applications) this.applications.put(application.getId(), application); }
java
{ "resource": "" }
q19583
ApplicationCache.applicationHosts
train
public ApplicationHostCache applicationHosts(long applicationId) { ApplicationHostCache cache = applicationHosts.get(applicationId); if(cache == null) applicationHosts.put(applicationId, cache = new ApplicationHostCache(applicationId)); return cache; }
java
{ "resource": "" }
q19584
ApplicationCache.keyTransactions
train
public KeyTransactionCache keyTransactions(long applicationId) { KeyTransactionCache cache = keyTransactions.get(applicationId); if(cache == null) keyTransactions.put(applicationId, cache = new KeyTransactionCache(applicationId)); return cache; }
java
{ "resource": "" }
q19585
ApplicationCache.addKeyTransactions
train
public void addKeyTransactions(Collection<KeyTransaction> keyTransactions) { for(KeyTransaction keyTransaction : keyTransactions) { // Add the transaction to any applications it is associated with long applicationId = keyTransaction.getLinks().getApplication(); Application application = applications.get(applicationId); if(application != null) keyTransactions(applicationId).add(keyTransaction); else logger.severe(String.format("Unable to find application for key transaction '%s': %d", keyTransaction.getName(), applicationId)); } }
java
{ "resource": "" }
q19586
ApplicationCache.deployments
train
public DeploymentCache deployments(long applicationId) { DeploymentCache cache = deployments.get(applicationId); if(cache == null) deployments.put(applicationId, cache = new DeploymentCache(applicationId)); return cache; }
java
{ "resource": "" }
q19587
ApplicationCache.labels
train
public LabelCache labels(long applicationId) { LabelCache cache = labels.get(applicationId); if(cache == null) labels.put(applicationId, cache = new LabelCache(applicationId)); return cache; }
java
{ "resource": "" }
q19588
ApplicationCache.addLabel
train
public void addLabel(Label label) { // Add the label to any applications it is associated with List<Long> applicationIds = label.getLinks().getApplications(); for(long applicationId : applicationIds) { Application application = applications.get(applicationId); if(application != null) labels(applicationId).add(label); else logger.severe(String.format("Unable to find application for label '%s': %d", label.getKey(), applicationId)); } }
java
{ "resource": "" }
q19589
PredicateMappingFunctionImpl.doThrow
train
private static <T, R> Function<T, R> doThrow(Supplier<? extends RuntimeException> exceptionSupplier) { return t -> { throw exceptionSupplier.get(); }; }
java
{ "resource": "" }
q19590
BaseException.put
train
@SuppressWarnings("unchecked") public <E extends BaseException> E put(String name, Object value) { properties.put(name, value); return (E) this; }
java
{ "resource": "" }
q19591
ContactResource.findByUniqueTag
train
@GET @PermitAll @Path("uniquetag/{uniqueTag}") public Response findByUniqueTag(@PathParam("uniqueTag") String uniqueTag) { checkNotNull(uniqueTag); DContact contact = dao.findByUniqueTag(null, uniqueTag); return null != contact ? Response.ok(contact).build() : Response.status(Response.Status.NOT_FOUND).build(); }
java
{ "resource": "" }
q19592
ProfileIndexFrameWriter.generate
train
public static void generate(ConfigurationImpl configuration) { ProfileIndexFrameWriter profilegen; DocPath filename = DocPaths.PROFILE_OVERVIEW_FRAME; try { profilegen = new ProfileIndexFrameWriter(configuration, filename); profilegen.buildProfileIndexFile("doclet.Window_Overview", false); profilegen.close(); } catch (IOException exc) { configuration.standardmessage.error( "doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } }
java
{ "resource": "" }
q19593
ProfileIndexFrameWriter.getProfile
train
protected Content getProfile(String profileName) { Content profileLinkContent; Content profileLabel; profileLabel = new StringContent(profileName); profileLinkContent = getHyperLink(DocPaths.profileFrame(profileName), profileLabel, "", "packageListFrame"); Content li = HtmlTree.LI(profileLinkContent); return li; }
java
{ "resource": "" }
q19594
JavacFiler.newRound
train
public void newRound(Context context) { this.context = context; this.log = Log.instance(context); clearRoundState(); }
java
{ "resource": "" }
q19595
GameSettings.getInstance
train
public static GameSettings getInstance() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new GamePermission("readSettings")); } return INSTANCE; }
java
{ "resource": "" }
q19596
ClassFileReader.newInstance
train
public static ClassFileReader newInstance(Path path, JarFile jf) throws IOException { return new JarFileReader(path, jf); }
java
{ "resource": "" }
q19597
Resolve.rawInstantiate
train
Type rawInstantiate(Env<AttrContext> env, Type site, Symbol m, ResultInfo resultInfo, List<Type> argtypes, List<Type> typeargtypes, boolean allowBoxing, boolean useVarargs, Warner warn) throws Infer.InferenceException { Type mt = types.memberType(site, m); // tvars is the list of formal type variables for which type arguments // need to inferred. List<Type> tvars = List.nil(); if (typeargtypes == null) typeargtypes = List.nil(); if (!mt.hasTag(FORALL) && typeargtypes.nonEmpty()) { // This is not a polymorphic method, but typeargs are supplied // which is fine, see JLS 15.12.2.1 } else if (mt.hasTag(FORALL) && typeargtypes.nonEmpty()) { ForAll pmt = (ForAll) mt; if (typeargtypes.length() != pmt.tvars.length()) throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args // Check type arguments are within bounds List<Type> formals = pmt.tvars; List<Type> actuals = typeargtypes; while (formals.nonEmpty() && actuals.nonEmpty()) { List<Type> bounds = types.subst(types.getBounds((TypeVar)formals.head), pmt.tvars, typeargtypes); for (; bounds.nonEmpty(); bounds = bounds.tail) if (!types.isSubtypeUnchecked(actuals.head, bounds.head, warn)) throw inapplicableMethodException.setMessage("explicit.param.do.not.conform.to.bounds",actuals.head, bounds); formals = formals.tail; actuals = actuals.tail; } mt = types.subst(pmt.qtype, pmt.tvars, typeargtypes); } else if (mt.hasTag(FORALL)) { ForAll pmt = (ForAll) mt; List<Type> tvars1 = types.newInstances(pmt.tvars); tvars = tvars.appendList(tvars1); mt = types.subst(pmt.qtype, pmt.tvars, tvars1); } // find out whether we need to go the slow route via infer boolean instNeeded = tvars.tail != null; /*inlined: tvars.nonEmpty()*/ for (List<Type> l = argtypes; l.tail != null/*inlined: l.nonEmpty()*/ && !instNeeded; l = l.tail) { if (l.head.hasTag(FORALL)) instNeeded = true; } if (instNeeded) return infer.instantiateMethod(env, tvars, (MethodType)mt, resultInfo, (MethodSymbol)m, argtypes, allowBoxing, useVarargs, currentResolutionContext, warn); DeferredAttr.DeferredAttrContext dc = currentResolutionContext.deferredAttrContext(m, infer.emptyContext, resultInfo, warn); currentResolutionContext.methodCheck.argumentsAcceptable(env, dc, argtypes, mt.getParameterTypes(), warn); dc.complete(); return mt; }
java
{ "resource": "" }
q19598
Resolve.selectBest
train
@SuppressWarnings("fallthrough") Symbol selectBest(Env<AttrContext> env, Type site, List<Type> argtypes, List<Type> typeargtypes, Symbol sym, Symbol bestSoFar, boolean allowBoxing, boolean useVarargs, boolean operator) { if (sym.kind == ERR || !sym.isInheritedIn(site.tsym, types)) { return bestSoFar; } else if (useVarargs && (sym.flags() & VARARGS) == 0) { return bestSoFar.kind >= ERRONEOUS ? new BadVarargsMethod((ResolveError)bestSoFar.baseSymbol()) : bestSoFar; } Assert.check(sym.kind < AMBIGUOUS); try { Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes, allowBoxing, useVarargs, types.noWarnings); if (!operator || verboseResolutionMode.contains(VerboseResolutionMode.PREDEF)) currentResolutionContext.addApplicableCandidate(sym, mt); } catch (InapplicableMethodException ex) { if (!operator) currentResolutionContext.addInapplicableCandidate(sym, ex.getDiagnostic()); switch (bestSoFar.kind) { case ABSENT_MTH: return new InapplicableSymbolError(currentResolutionContext); case WRONG_MTH: if (operator) return bestSoFar; bestSoFar = new InapplicableSymbolsError(currentResolutionContext); default: return bestSoFar; } } if (!isAccessible(env, site, sym)) { return (bestSoFar.kind == ABSENT_MTH) ? new AccessError(env, site, sym) : bestSoFar; } return (bestSoFar.kind > AMBIGUOUS) ? sym : mostSpecific(argtypes, sym, bestSoFar, env, site, allowBoxing && operator, useVarargs); }
java
{ "resource": "" }
q19599
Resolve.findMethod
train
Symbol findMethod(Env<AttrContext> env, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes, boolean allowBoxing, boolean useVarargs, boolean operator) { Symbol bestSoFar = methodNotFound; bestSoFar = findMethod(env, site, name, argtypes, typeargtypes, site.tsym.type, bestSoFar, allowBoxing, useVarargs, operator); return bestSoFar; }
java
{ "resource": "" }