id
stringlengths
7
14
text
stringlengths
1
37.2k
10873724_103
@Override public JClass apply(String nodeName, JsonNode node, JsonNode parent, JPackage jpackage, Schema schema) { boolean uniqueItems = node.has("uniqueItems") && node.get("uniqueItems").asBoolean(); boolean rootSchemaIsArray = !schema.isGenerated(); JType itemType; if (node.has("items")) { i...
10899610_2
@Override public String generate(String givenNames, String surname) { Assert.hasText(givenNames, "Given name is required"); Assert.hasText(surname, "Surname is required"); int wordsSize = 0; wordsSize += givenNames.length(); wordsSize += surname.length(); if (wordsSize < DEFAULT_SIZE) { ...
10912209_41
@Factory public static Matcher<WebDriver> hasCookie(String name) { return new HasCookieMatcher(name); }
10932418_13
public long addComment(long app, long record, String text, List<MentionDto> mentions) throws DBException { JsonParser parser = new JsonParser(); String json; try { json = parser.generateForAddComment(app, record, text, mentions); } catch (IOException e) { throw new ParseException("failed to...
10937119_2
public long getId(final String agent) { try { return worker.getId(agent); } catch (final InvalidUserAgentError e) { LOGGER.error("Invalid user agent ({})", agent); throw new SnowizardException(Response.Status.BAD_REQUEST, "Invalid User-Agent header", e); } catch (fina...
10945339_20
@JniMethod ;
10953866_26
public void populate(Result result) { // process job-level stats and properties NavigableMap<byte[], byte[]> infoValues = result.getFamilyMap(Constants.INFO_FAM_BYTES); this.jobId = ByteUtil.getValueAsString(JobHistoryKeys.KEYS_TO_BYTES .get(JobHistoryKeys.JOBID), infoValues); this.user = ByteUtil.getV...
10974543_2
public int checkValue(final int amount) { if (amount == 0) { throw new IllegalArgumentException("value is 0"); } return 0; }
10983382_14
@Override public Sequence tail() { CircularArraySequence<T> tempSequence = new CircularArraySequence<T>(this); if (backingArray[front]!=null){ tempSequence.backingArray[front] = null; tempSequence.fillCount-=1; if (front == backingArray.length-1){ tempSequence.front = 0; } else{ tempSequence.front+=1;...
10989097_1
@Override final public boolean incrementToken() throws IOException { if (currentEntry == null) { currentEntry = currentIterator.next(); currentCount = 0; String result = String.format("%s_%d", currentEntry.getKey(), currentCount); termAtt.setEmpty().append(result); return tru...
11036770_0
public static URI create(String s) { return URI.create(s.replace(" ", "%20")); }
11074539_112
@Override public void remove() { throw new UnsupportedOperationException(); }
11125589_88
@Override public void saveAccountInfo(OidcKeycloakAccount account) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null) { throw new IllegalStateException(String.format("Went to save Keycloak account %s, but already have %s", account, aut...
11128472_1
@Programmatic public InvoiceItem findFirstItemWithCharge(final Charge charge) { for (InvoiceItem item : getItems()) { if (item.getCharge().equals(charge)) { return item; } } return null; }
11140459_23
public ParcelableDescriptor analyze(ASTType astType) { ASTAnnotation parcelASTAnnotation = astType.getASTAnnotation(Parcel.class); return analyze(astType, parcelASTAnnotation); }
11144122_0
public String say() { return hello; }
11152828_62
public List<AbbyyProcess> split(AbbyyProcess process, int splitSize) { if (process.getNumberOfImages() == 0) { throw new IllegalArgumentException("Cannot split the process, it has no images: " + process.getName()); } if (process.getNumberOfImages() <= splitSize) { List<AbbyyProcess> sp = new ArrayList<AbbyyProce...
11159652_55
@Override public void importRules(List<Rule> rules) { pushQuite(); try { if (rules.size() > 1) { LOGGER.warn("Importing a " + this.getClass().getSimpleName() + " with " + rules.size() + " rules"); } Rule rule = rules.get(0); // TODO Parse metainfostring?! RasterSymbolizer rs = (RasterSymbo...
11161563_1
@Override public Boolean fromString(String string, ConverterContext context) { if (string.equalsIgnoreCase(getTrue())) { return Boolean.TRUE; } else if (string.equalsIgnoreCase("true")) { // in case the application runs under different locale, we still consider "true" is true. NON-NLS return...
11164718_0
public void setCounts(MLSJSONObject ichnaeaQueryObj) { mCellCount = ichnaeaQueryObj.getCellCount(); mWifiCount = ichnaeaQueryObj.getWifiCount(); }
11178914_16
public void removeIdAndRevision() { remove(table.getPrimaryKeyColumn().get()); if (table.getRevisionColumn().isPresent()) { remove(table.getRevisionColumn().get().getColumnName()); } }
11194069_0
boolean isValid() { try { new URL(this.uri); } catch (MalformedURLException ex) { return false; } return this.command != null; }
11198387_9
@Override public <T> Provider<T> scope(final Key<T> key, final Provider<T> unscoped) { return new Provider<T>() { @Override public T get() { Map<Key<?>, Object> map = getScopeMapForCurrentThread(); checkState(map != null, "No scope map found for the current thread. Forgot to call enterScope()?"); return g...
11206901_5
@Override public String getHtmlFragment(JRHtmlExporterContext context, JRGenericPrintElement element) { Map<String, Object> contextMap = new HashMap<String, Object>(); contextMap.put("mapCanvasId", "map_canvas_" + element.hashCode()); if (context.getExporter() instanceof JRXhtmlExporter) { contextMap.pu...
11217397_26
public FormValidation doCheckIncludeRegex(@QueryParameter String value) { String v = Util.fixEmpty(value); if (v != null) { try { Pattern.compile(v); } catch (PatternSyntaxException pse) { return FormValidation.error(pse.getMessage()); } } return FormValid...
11219096_12
@Override public boolean add(final Card card) { if (size() == MAX_CARDS) { throw new IllegalStateException("Card deck is already filled with " + MAX_CARDS + " cards."); } if (contains(card)) { throw new IllegalArgumentException("Card " + card + " is already contained in card deck."); } return super.a...
11226198_7
public V getUnchecked() { try { return get(); } catch (Throwable pokemon) { Util.pokeball(pokemon); } return null; }
11233417_148
@Override public SVAnnotation build() { final GenomeInterval changeInterval = svTandemDup.getGenomeInterval(); // Go over the different cases from most to least pathogenic step and return most pathogenic one. if (changeInterval.overlapsWith(transcript.getTXRegion())) { return new SVAnnotation(svTandemDup, transc...
11254311_793
static MD5Hash getFileClient(String nnHostPort, String queryString, List<File> localPaths, Storage dstStorage, boolean getChecksum) throws IOException { String str = HttpConfig.getSchemePrefix() + nnHostPort + "/getimage?" + queryString; LOG.info("Opening connection to " + str); // // open connec...
11267509_1
public static <T> ListenableFuture<T> submit(final RequestBuilder<T> requestBuilder) { return transformFromTargetAndResult(submitInternal(requestBuilder)); }
11275102_1
public static long computeArraySUID(String name) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream dout = new DataOutputStream(bout); try { dout.writeUTF(name); dout.writeInt(Modifier.PUBLIC | Modifier.FINAL | Modifier.ABSTRACT); dout.flush(); } catch (...
11281607_27
@Override public void addMessageHandler(MessageHandler handler) { checkConnectionState(State.CLOSED); synchronized (handlerManager) { handlerManager.addMessageHandler(handler); } }
11286308_6
@Override public boolean isValid() { // Must have exactly 9 numeric digits if (this.financialID.length() != 9 || !this.financialID.matches("\\d+")) { return false; } List<Character> firstDigits = Lists.charactersOf("123568"); boolean validFirstDigit = firstDigits .stream() ...
11290309_30
public byte[] read(Integer length) throws IOException { if (length == null) { return readToEof(); } else { return readTo(length); } }
11304836_0
@Override public Map<K, V> loadAll(final Iterable<? extends K> keys) throws CacheLoaderException { final Map<K, V> result = new HashMap<K, V>(); for (final K k : keys) { final V v = load(k); if (v != null) { result.put(k, v); } } return result; }
11304845_34
@Override public boolean equals(Object o) { if (o == null) { return false; } if (o == this) { return true; } if (o.getClass() != getClass()) { return false; } MethodSignature other = (MethodSignature) o; return other.internal.equals(internal); }
11309044_135
@Override public long dot(MapKL<K> m) { long s = 0; for (MapKL.Entry<K> e : m.entrySet()) { K key = e.getKey(); if (this.containsKey(key)) { s += this.get(key) * e.getValue(); } } return s; }
11324849_308
public static double getEditDistance(CharSequence s, CharSequence t) { return getEditDistance(s, t, DEFAULT_OPERATIONS_WEIGHTS); }
11335237_371
public T next() { return function.evaluate(iterator.next()); }
11337147_387
public Finder create(final Class<? extends ServerResource> clazz) { final Finder finder = finders.get(clazz); if (finder == null) { throw new RuntimeException("Finder unimplemented for class " + clazz); } return finder; }
11344750_180
public static DoubleMatrixDataset<String, String> weightedCorrelationColumnsOf2Datasets(DoubleMatrixDataset<String, String> d1, DoubleMatrixDataset<String, String> d2, DoubleMatrixDataset<String, String> rowWeigths) throws Exception { if (d1.rows() != d2.rows() || d1.rows() != rowWeigths.rows()) { throw new Excepti...
11367662_1
@Override public <T> T resolve(final Class<T> clazz) { final Object component = resolve(clazz, true); return clazz.cast(component); }
11369509_12
@Override public void unregisterProtoFile(String fileName) { log.debugf("Unregistering proto file : %s", fileName); writeLock.lock(); try { FileDescriptor fileDescriptor = fileDescriptors.remove(fileName); if (fileDescriptor != null) { unregisterFileDescriptorTypes(fileDescriptor); }...
11384368_4
public static String getContentAsString(final FileObject file, final Charset charset) throws IOException { try (final FileContent content = file.getContent()) { return content.getString(charset); } }
11392749_29
public static StringOperator replace(@NotNull final String what, @NotNull final String with) { return new StringOperator() { @Override public String apply(final String arg) { return Strings.replace(arg, what, with); } }; }
11395286_13
@Override public void setProgressEndpoints(double begin, double end) { if (Double.isNaN(begin) || Double.isNaN(end) || begin < 0.0 || (begin > end)) { throw new IllegalArgumentException( "invalid progress endpoints (begin == " + begin + ", end == " + end + ")"); }...
11397182_17
public static AllowedMechanisms fromBinaryEncoding(final byte[] binary) throws IllegalArgumentException { final ArrayList<Long> mechs = new ArrayList<>(); try { final LongBuffer lb = ByteBuffer.wrap(binary).order(ByteOrder.LITTLE_ENDIAN).asLongBuffer(); while (lb.hasRemaining()) { me...
11416570_5
public static byte[] macAddress() { byte[] override = getOverride(); return override != null ? override : realMacAddress(); }
11429654_9
public Object read() throws IOException { char[] buffer = new char[BUFFER_LENGTH]; reader.mark(BUFFER_LENGTH); int count = 0; int textEnd; while (true) { int r = reader.read(buffer, count, buffer.length - count); if (r == -1) { // the input is exhausted; return the remaining characters t...
11450329_1
@Override public void createFriendship(final Node following, final Node followed) { // try to find the replica node of the user followed Node followedReplica = null; for (Relationship followship : following.getRelationships( SocialGraphRelationshipType.FOLLOW, Direction.OUTGOING)) { followedReplica = followship...
11451879_32
public static String getName(Network object) { if (isFilled(object.getName())) return object.getName(); return object.getObjectId(); }
11452433_6
@Override public T readFrom( Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream ) throws IOException, WebApplicationException { InputStreamReader reader = new InputStreamReader( entityStream, "UTF-8" ); Type ...
11453959_8
@SuppressWarnings("unchecked") public static <T> Class<T> defineClass(String className, byte[] b, Class<?> neighbor, ClassLoader loader) throws Exception { Class<T> c = (Class<T>) DefineClassHelper.defineClass(className, b, 0, b.length, neighbor, loader, PROTECTION_DOMAIN); // Force static initializers to run....
11459376_4
protected Iterable<Row<String, String>> getRows(EnumSet<?> columns) throws Exception { int shardCount = config.getShardCount(); List<Future<Rows<String, String>>> futures = new ArrayList<Future<Rows<String, String>>>(); for (int i = 0; i < shardCount; i++) { futures.add(cassandra.selectAsync(genera...
11479356_0
public static Builder newBuilder() { return new Builder(); }
11480369_2
@Override public Object getProperty(String key) { return getProperty(key, null); }
11500828_55
public static <T> T getSingle(Iterator<T> iterator, String notFoundMessage) { T result = getSingleOrNull(iterator); if (result == null) { throw new NotFoundException(notFoundMessage); } return result; }
11525787_7
private MetricValue readQueueLength() { MetricValue value = null; Counter queueLength = metricRegistry .counter(MetricName.QUEUE_LENGTH.getName()); if (queueLength != null) { value = MetricValue.tuples(Long.valueOf( queueLength.getCount()).intValue()); } ...
11527775_8
@Override public int hashCode() { return Objects.hash(inner); }
11543457_128
public static FeedLocationStore get(){ return instance; }
11543691_11
@Override public List<Path> getClasspath() { String classpath = p.getProperty(CLASSPATH); if (classpath != null) { return parsePathList(classpath); } String classpathFile = p.getProperty(CLASSPATH_FILE); if (classpathFile != null) { return readPathList(Paths.get(classpathFile)); ...
11553940_10
void writeGetMethods(JClassType target, SourceWriter writer) throws UnableToCompleteException { String targetType = target.getQualifiedSourceName(); writer.println("public List<EventHandlerMethod<%s, ?>> getMethods() {", targetType); writer.indent(); // Write a list that we will add all handlers to before retu...
11558041_0
@Override public MobileSeries[] getAllSeries() throws VideoServiceException { try { return httpClient.get(new URL(MOBILE_URL + "keyword=index&d=" + idevice.getDeviceId()), MobileSeries[].class); } catch (MalformedURLException e) { throw new VideoServiceException(e); } catch (IOException e) { throw new Vide...
11566581_2
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) public void process(Exchange exchange) throws Exception { String processInstanceId = exchange.getProperty(EXCHANGE_HEADER_PROCESS_INSTANCE_ID, String.class); String businessKey = exchange.getProperty(EXCHANGE_HEADER_BUSINESS_KEY, String.class); Map<S...
11602449_2
public void validateOrderDate( @XPath(value = "/order:order/order:date", namespaces = @NamespacePrefix(prefix = "order", uri = "http://fabric8.com/examples/order/v7")) String date) throws OrderValidationException { final Calendar calendar = new GregorianCalendar(); try { calendar.setTime(DAT...
11608365_5
public static void unregister(XAResourceProducer producer) { final ProducerHolder holder = new ProducerHolder(producer); if (!resources.remove(holder)) { if (log.isDebugEnabled()) { log.debug("resource with uniqueName '{}' has not been registered", holder.getUniqueName()); } } }
11613195_0
public Map<String, String> getThumbnailsForCollection(int start, int limit, int errorHandlingPolicy) throws TechnicalRuntimeException, IOException, EuropeanaApiProblem { return getThumbnailsForCollection(CommonMetadata.EDM_FIELD_THUMBNAIL_LARGE, start, limit, errorHandlingPolicy); }
11629470_0
@GET @Transactional public Note get() { try { return manager.createQuery("select n from Note n", Note.class).getSingleResult(); } catch (NoResultException e) { Note note = new Note(); note.setContent("Default message"); manager.persist(note); return note; } }
11656984_397
@Override public String toString() { return new StringBuilder().append(getClass().getSimpleName()) .append(" [path=") .append(path) .append(", cancel=") .append(cancel) ...
11660383_23
@Override public void write(Job t, String contentType, HttpOutputMessage outputMessage) throws IOException { throw new UnsupportedOperationException(); }
11662606_6
public static String join(Collection<?> collection, String delimiter) { if (collection == null || collection.isEmpty()) { return EMPTY_STRING; } else if (delimiter == null) { delimiter = EMPTY_STRING; } StringBuilder builder = new StringBuilder(); Iterator<?> it = collection.iterat...
11664357_10
public static boolean isTrue(String tagValue) { return ("yes".equals(tagValue) || "1".equals(tagValue) || "true".equals(tagValue)); }
11666990_3
@Override public void transformPage(View view, float position) { int pageWidth = view.getWidth(); if (position < 0) { view.setAlpha(1 + position * 2); } else { view.setAlpha(1); view.setTranslationX((int) (pageWidth * -position * 0.7)); view.setScaleX(1 - position / 8); ...
11668780_7
public void newData(@Nonnull ChangesAdapter adapter, @Nonnull List<T> values, boolean force) { checkNotNull(adapter); checkNotNull(values); final ImmutableList<H> list = FluentIterable.from(values) .transform(mDetector) .toList(); int fir...
11694419_2
@Override public void cleanup() { super.cleanup(); notifier.cleanup(); }
11695624_11
void parseArgs(String... args) throws IllegalArgumentException { List<String> rest = null; rest = Args.parse(this, args); if (rest == null || rest.size() != 1) { //exit("Invalid syntax"); throw new IllegalArgumentException("missing input"); } context = parseContext(); String input = rest.get(0); url = pa...
11700816_3
@Override public boolean Validator(File file) throws FileNotFoundException, IOException, IllegalAccessException, InstantiationException { // Write your own elaborate validator to see if your LoadFile routine can deal with it String ext = getFileExtension(file); if (ext.equalsIgnoreCase(getExtention())) { ...
11711223_9
private static String splitLine(String str, final int col) { if (str.length() < col) { return str; } // scan from `col` to left for (int i = col - 1; i > 0; i--) { if (str.charAt(i) == ' ') { return str.substring(0, i) + "\n" + splitLine(str.substring(i + 1), col); }...
11719739_6
public URL findResource(String resource) throws MojoFailureException { URL res = null; // first search relatively to the base directory try { final Path p = basedir.resolve(resource); res = toURL(p.toAbsolutePath()); } catch (final InvalidPathException e) { // no-op - can be cau...
11724937_0
@Override public Future<RecordMetadata> send(ProducerRecord<K, V> record) { return send(record, null); }
11736323_36
public void putAll(Map<? extends String, ? extends Object> arg0) { inner.putAll(convertToTypedObjects(arg0)); }
11738699_2
public void stop() { // AstericsErrorHandling.instance.getLogger().fine("Invoking thread // <"+Thread.currentThread().getName()+">, : .stop called"); if (runningTaskFuture != null && !runningTaskFuture.isDone()) { runningTaskFuture.cancel(true); } active = false; count = 0; running...
11754395_21
@Override public Promise<HttpClientResponseAndBody> requestAbsAndReadBody(HttpMethod method, String absoluteURI) { return requestAbsAndReadBody(method, absoluteURI, null); }
11765760_0
public void parsePullRequestChains(PullRequests<? extends PullRequest> pullRequests) { Map<String, PullRequest> pullRequestsMap = Maps.newHashMap(); for (PullRequest pullRequest : pullRequests.getPullRequests()) { pullRequestsMap.put(pullRequest.getSource().getBranch().getName(), pullRequest); } ...
11769277_196
@POST @Path("/{id}/content_manipulation_lock") @RolesAllowed({ Role.ADMIN, Role.PROVIDER }) public Object contentManipulationLockCreate(@PathParam("id") @AuditId String id) throws ObjectNotFoundException { if (StringUtils.isBlank(id)) { throw new RequiredFieldException("id"); } if (ContentManipulationLockService...
11797725_37
@Override public void channelInactive(ChannelHandlerContext ctx) { Attribute<FixSession> fixSessionAttribute = ctx.channel().attr(FIX_SESSION_KEY); if (fixSessionAttribute != null) { FixSession session = fixSessionAttribute.getAndSet(null); if (session != null) { ctx.fireChannelRead(...
11799054_68
protected static int readAfterString(byte[] header, int off) { int start = readToString(header, off); int len = header[start + 2] & 0xFF; return start + len*2 + 3; }
11816589_0
void execute() { System.out.println(message); }
11851236_37
public CompletableFuture<Void> close() { log.info("Shutting down."); final CompletableFuture<Void> closeFuture; if (this.isClosed.compareAndSet(false, true)) { closeFuture = new CompletableFuture<>(); this.channelPool.close().addListener((GenericFutureListener<Future<Void>>) closePoolFutu...
11862260_1
@RequestMapping(value = "result/{buildKey}.json", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @ResponseBody public BambooResultResponse getBambooBuildResponse(@PathVariable("buildKey") String buildKey, @Reques...
11880356_8
public float getFloat(String fieldName) throws DbfException { return getNumber(fieldName).floatValue(); }
11896265_5
@GET @Path( "/default" ) public Response defaultElement() throws IOException { IElement defaultElement = coreService.getDefaultElement(); if ( defaultElement != null ) { try { String url = defaultElement.getPluginId() + API_ROOT + defaultElement.getId(); return CpkUtils.redirect( url ); } catch ...
11904180_16
public Scheme createScheme( String format, Fields fields, Properties properties ) { LOG.info( "creating {} format with properties {} and fields {}", format, properties, fields ); String selectQuery = properties.getProperty( FORMAT_SELECT_QUERY ); String countQuery = properties.getProperty( FORMAT_COUNT_QUERY ); String...
11916042_2
@Override public void patch( final DiscoveryResult orig, final List<? extends Location> locations, final Map<String, Object> context ) { final DiscoveryResult result = orig; final ProjectVersionRef ref = result.getSelectedRef(); try { final MavenPomView pomView = (MavenPomView...
11943595_64
public MutableSchema addTable(Table table) { _tables.add(table); return this; }
11971122_38
public PaaSInstance getPaaSInstance() { return paaSInstance; }
11974846_4
@Override public void preModifyColumn(ObserverContext<MasterCoprocessorEnvironment> c, byte[] tableName, HColumnDescriptor descriptor) throws IOException { requirePermission("modifyColumn", tableName, null, null, Action.ADMIN, Action.CREATE); }
11976306_9
public static String getAlias(final Dictionary<String, Object> config) { String alias = getValue(config, DECRYPTOR_ALIAS); for (Enumeration<String> e = config.keys(); e.hasMoreElements();) { final String key = e.nextElement(); String value = getValue(config, key); String newAlias = getAl...
11992364_6
static String cutFieldName(final String string, final int from) { final int nextIndex = from + 1; final int len = string.length(); if (len > nextIndex) { char c = string.charAt(nextIndex); if (c >= 'A' && c <= 'Z') { return string.substring(from); } } char[] buffe...
12002935_3
protected void applyModifications(Element modificationsRoot, Element targetRoot) { for(Object object : modificationsRoot.elements()){ if(object instanceof Element){ Element modificationElement = (Element) object; String copy = modificationElement.attributeValue("sdk-copy"); ...