id
stringlengths
7
14
text
stringlengths
1
37.2k
29629640_158
@VisibleForTesting boolean isTxConsistent(final Transaction tx, final boolean isSpent) { boolean isActuallySpent = true; for (TransactionOutput o : tx.getOutputs()) { if (o.isAvailableForSpending()) { if (o.isMineOrWatched(this)) isActuallySpent = false; if (o.getSpentBy() != nul...
29653587_37
@Override public void getStories(@FetchMode String filter, @CacheMode int cacheMode, final ResponseListener<Item[]> listener) { if (listener == null) { return; } Observable.defer(() -> getStoriesObservable(filter, cacheMode)) .subscribeOn(mIoScheduler) ...
29703871_12
public void invoke(Object receiver, String methodName, String argument) { Util.throwIfNull(receiver, methodName, argument); int size = invokers.size(); for (int i = 0; i < size; ++i) { final TypedMethodInvoker<?> invoker = invokers.get(i); if (invoker.invoke(receiver, methodName, argument)) { return...
29740272_0
@CheckForNull public Instant forkDate(Path rootBaseDir, String referenceBranch) { try { return findFork.findDate(rootBaseDir, referenceBranch); } catch (SVNException e) { LOG.warn("Unable to find fork date with '" + referenceBranch + "'", e); return null; } }
29740615_47
public int doWork() { switch (state) { case DISCONNECTED: { if (duringDay) { reply = library.initiate(sessionConfiguration); state = State.CONNECTING; return 1; } return 0; } case CO...
29748148_3
@Override public void close() throws Exception { LOG.info("Dscrudbenchmark Closed"); }
29748259_89
@Override public void storeLog(TSDRLogRecord logRecord) { try { store.store(logRecord); } catch (SQLException e) { LOG.error("Failed to store record to database", e); } }
29782400_3
public void setSettingFlags(@DebugWrapperAdapterSettingFlags int flags) { mFlags = flags; }
29807428_0
@Override public Asset toNova(ResourceLocation resource) { return new Asset(resource.getResourceDomain(), resource.getResourcePath()); }
29876931_134
@Override public Map<String, Long> getNbrOfUnhandledFragaSvarForCareUnits(List<String> vardenheterIds, Set<String> intygsTyper) { Map<String, Long> resultsMap = new HashMap<>(); if (vardenheterIds == null || vardenheterIds.isEmpty()) { LOGGER.warn("No ids for Vardenheter was supplied"); return...
29888015_19
@Override public Component parse(String source) { try { source = "<span>" + source + "</span>"; JAXBContext context = JAXBContext.newInstance(Element.class); Unmarshaller unmarshaller = context.createUnmarshaller(); Element tag = (Element) unmarshaller.unmarshal(new StringReader(source)); TextComp...
29898124_3
@Override public CamusWrapper<String> decode(byte[] payload) { long timestamp = 0; String payloadString; JsonObject jsonObject; payloadString = new String(payload); // Parse the payload into a JsonObject. try { jsonObject = jsonParser.parse(payloadString.trim()).getAsJsonObject(); } catch (RuntimeEx...
29903688_3
public void run() { if (this.getEntranceProcessingItems() == null) throw new IllegalStateException("You need to set entrance PI before running the topology."); if (this.getEntranceProcessingItems().size() != 1) throw new IllegalStateException("ThreadsTopology supports 1 entrance PI only. Number of entrance ...
29904381_32
}
29917329_63
public QuestionnaireParsingResult parse(String pathname) throws IOException { EncodersQLLexer lexer = new EncodersQLLexer(new ANTLRFileStream(pathname)); EncodersQLParser parser = new EncodersQLParser(new CommonTokenStream(lexer)); final List<SyntaxError> syntaxErrors = new ArrayList<>(); parser.addErrorListener(...
29917907_8
@Override public String setHash(String hashName, Map<String, String> map) { LOG.debug("Set hash map {}", hashName); return this.redisConnection.hmset(hashName, map); }
29918398_1
public void setBoardListener(BoardListener listener) { mBoardListener = listener; }
29959880_93
public static boolean isValidEmail(final String email) { return EMAIL_PATTERN.matcher(email.trim().toLowerCase()).matches(); }
29964541_11
protected Map<String, Map> mergeMaps(Map<String, Map> configuration, Map<String, Map> servicesConfig) { if (servicesConfig == null) { return configuration; } MutableMap<String, Map> newConfigurationMap = MutableMap.copyOf(configuration); for (Map.Entry<String, Map> stringMapEntry : servicesConf...
29969855_12
@Override public final AggregateIdentifier create() { return new UUIDAggregateIdentifier(); }
29974632_50
@Override public CredentialsConfig merge(final CredentialsConfig config) { // empty password value means 'use existing value' - see control-point-widget.js return super.merge(config).toBuilder() .password((password == null || password.isEmpty()) ? config.password : password) .build(); }
29993866_0
public void maybeCreateTopic(String topicName) throws ExecutionException, InterruptedException { Collection<NewTopic> topics = new ArrayList<>(); topics.add(new NewTopic(topicName, 1, (short) 1)); if (topicName.toLowerCase().startsWith("test")) { admin.createTopics(topics); // alter...
29996210_0
@Override public Map<String,String> getProperties() { Map<String,String> envVars = System.getenv(); if (!Collections.isEmpty(envVars)) { return new LinkedHashMap<>(envVars); } return java.util.Collections.emptyMap(); }
30000823_1
public RdRandStatus getStatus() { return status; }
30008530_24
@Override public synchronized Map<String, Integer> getRebalanceCount() { Map<String, Integer> countMap = new HashMap<String, Integer>(); try { for (String topic : m_allTopicPartitions.keySet()) { int count = 0; int toTake = getToTakePartitions(topic).size(); if (toTake > 0) { count = toTake; } else ...
30044052_147
protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } sourceCode.append(getStartClassDefinition(codeSnippet)).append(...
30047349_133
public void setClusterIdentifier(int clusterIdentifier) { Preconditions.checkArgument((clusterIdentifier & 0xFFFFF000)==0, "ClusterIdentifier can only be a 12bit value"); this.clusterIdentifier = clusterIdentifier; }
30073725_6
public List<Data> getData() throws ConnectException { final InputStream inputStream; try { inputStream = mRequestBuilder.create().connect().getInputStream(); return mParser.getModels(inputStream); } catch (IOException e) { throw new ConnectException(new DeliveryException(e)); } }
30084378_190
@Override public TLParsingResult get() { TLParsingResult result = new TLParsingResult(); TrustStatusListType jaxbObject = getJAXBObject(); parseSchemeInformation(result, jaxbObject.getSchemeInformation()); parseTrustServiceProviderList(result, jaxbObject.getTrustServiceProviderList()); return result; }
30120639_1
@SuppressWarnings("unchecked") public E insert(E e) { OID id = odb.store(e); odb.commit(); E attached = (E) odb.getObjectFromId(id); odb.disconnect(attached); return attached; }
30124869_20
public static void reduce(OWLOntology ontology, OWLReasonerFactory reasonerFactory) throws OWLOntologyCreationException { reduce(ontology, reasonerFactory, getDefaultOptions()); }
30125753_6
public static boolean isValidEmail(String email) { if (email == null) { return false; } final String emailPattern = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; Matcher matcher; Pattern pattern = Pattern.compile(emailPattern); matcher = patte...
30182457_0
@Override public SysStatusType getStatus() { return systemService.getStatus(); }
30195197_51
public boolean isOWLObjectInSubsets(OWLObject testObject, Collection<String> subsets) { return !Collections.disjoint(subsets, this.getSubsets(testObject)); }
30242992_10
@Override public final String toHaskell() { return "(" + this.value + ")"; }
30258802_2399
public static String applyRule(String ruleName, String serverOptStr, boolean value) throws OptionsException { throwOptionsExceptionIfConditionFails(isNotBlank(serverOptStr), "Null or Empty server options spec"); if (isBlank(ruleName)) { if (value) { return OPTPFX + serverOptStr; } } else { thro...
30259183_8
public double getXOffset() { return xOffset; }
30272363_6
@Override public int findTokenEnd(final @NonNull Spanned text, final int cursor) { int i = cursor; int end = getSearchEndIndex(text, cursor); // Starting from the cursor, increment i until it reaches the first word-breaking char while (i >= 0 && i < end) { if (isWordBreakingChar(text.charAt(i))...
30322187_24
public static boolean verifyIntentActions(final Intent intent) { boolean result = true; final List<Actions> actions = intent.getActions(); if (actions == null || actions.size() != NUM_OF_SUPPORTED_ACTION) { LOG.warn("Intent's action is either null or not equal to {} action {}", NUM_OF_SUPPORTED_ACTI...
30330883_1
public DoubleProperty zoomLevelProperty() { return zoomLevel; }
30333472_14
public BusinessDateTime plusSeconds(int seconds) { if (seconds == 0) { return this; } else { return move(seconds, Constants.NANOS_PER_SECOND); } }
30336945_5
public <X extends Throwable> T executeWithCheckedException(RetryExecutor executor, Class<X> propagateAsIsException) throws X { if (executor == null) { try { return this.call(); } catch (Exception e) { if (e in...
30405191_19
public Grammar processString(String inString) { return processStream(new ByteArrayInputStream((inString).getBytes()) ); }
30405521_62
protected List<Optional<Package>> resolvePackages(Collection<Package> installablePackages, List<String> minimumPackages) { return minimumPackages .stream() .map(pkgName -> installablePackages .stream() .filter(p -> pkgName.equals(p.getName())) ...
30417900_2
public static boolean isAuthenticated() { SecurityContext securityContext = SecurityContextHolder.getContext(); Collection<? extends GrantedAuthority> authorities = securityContext.getAuthentication().getAuthorities(); if (authorities != null) { for (GrantedAuthority authority : authorities) { ...
30419413_26
public static Tlv[] decode(ByteBuffer input) throws TlvException { try { List<Tlv> tlvs = new ArrayList<>(); while (input.remaining() > 0) { input.order(ByteOrder.BIG_ENDIAN); // decode type int typeByte = input.get() & 0xFF; TlvType type; ...
30422535_28
@Override public boolean isAllowedTo(Operation operation, Resource resource, Persona persona) { if (null == resource) { throw new IllegalArgumentException("Resource to be checked is invalid (null)."); } if (null == operation) { throw new IllegalArgumentException("Operation to be checked is ...
30425951_0
public static String formatAligned(String fmt, Object... lines) { final String FORMAT_ELEMENT_SYMBOL = "##"; final int hashStartIndex = fmt.indexOf(FORMAT_ELEMENT_SYMBOL); final int hashEndIndex = hashStartIndex + FORMAT_ELEMENT_SYMBOL.length(); final String linePrefix = getWhitespaceLinePrefix(fmt...
30438494_3
public static boolean isHex(char a) { return (a >= '0' && a <= '9') || (a >= 'a' && a <= 'f') || (a >= 'A' && a <= 'F'); }
30448037_0
@Override public String toString() { return getClass().getSimpleName() + "(" + interfaceIp.toString() + "\\" + networkPrefixLength + ")"; }
30449481_69
public CompletableFuture<Void> allItemsAvailableAsync() { final CompletableFuture<Void> allAvailable = new CompletableFuture<>(); readCompleted.thenRun(() -> allAvailable.complete(null)); readCompleted.exceptionally(t -> { allAvailable.completeExceptionally(t); return null; }); retur...
30451130_8
public List<UserEntity> transformUserEntityCollection(String userListJsonResponse) throws JsonSyntaxException { List<UserEntity> userEntityCollection; try { Type listOfUserEntityType = new TypeToken<List<UserEntity>>() {}.getType(); userEntityCollection = this.gson.fromJson(userListJsonResponse, listOf...
30515411_4
public static <T, X extends Throwable> CloseableThrowableSupplier<T, X> lazyEx(ThrowableSupplier<T, X> delegate) { return lazyEx(delegate, true); }
30520538_2
static void adjustXformDocument(Document doc, int patientId, int userId, Date dateEntered) throws SAXException, IOException { Element root = doc.getDocumentElement(); // This element sets the encounter's patient_id column. XmlUtils.getOrCreatePath(doc, root, "patient", "patient.patient_id") .setTex...
30535152_0
@Override public InputStream openInputStream(String fileId) throws IOException { Path fileName = resolvePath(fileId); logger.trace("Reading data from file {}", fileName); InputStream ret; if (!Files.exists(fileName)) { throw new FileNotFoundException(fileName.toString()); } else { ret = Files.newInputStream(fi...
30564046_0
public boolean isDemoCredentials() { return this.equals(Credentials.createDemoCredentials()); }
30567918_8
public void generate(OBridgeConfiguration c) { // populate objects table PopulateObjectsTable.run(c); // generate objects EntityObjectGenerator.generate(c); // generate converters ConverterObjectGenerator.generate(c); // generate contexts ProcedureContextGenerator.generate(c); //...
30607695_1
@Override public ListenableFuture<SearchResponse> extendedSearch(ExtendedSearchRequest request) { SearchResponse response = new SearchResponse(); response.setResultList(Arrays.asList( "result 1", "result 2", "result 3" )); return Futures.immediateFuture(response); }
30621232_8
public void receive(@NonNull ChunkHeader header, T data) { if (!mTransactionId.equals(header.getTransactionId())) { throw new IllegalArgumentException("Chunk contains data from a different transaction"); } if (header.getOffset() > mOffset) { throw new IllegalArgumentException("Chunk arrived...
30629253_1
public static ClickGuard guard(View view, View... others) { return guard(DEFAULT_WATCH_PERIOD_MILLIS, view, others); }
30649762_4
public String extract(AttributeDetail attributeDetail, String url, Document articleDoc) throws Exception { String domain = super.extract(attributeDetail, url, articleDoc); if(domain.equals(UNKOWN_DOMAN)){ return null; } else { // to parse a host, we must remove the suffix (this is a very poo...
30657069_1
public Response getSolution(String key, String jobId) throws ApiException { ApiResponse<Response> resp = getSolutionWithHttpInfo(key, jobId); return resp.getData(); }
30705823_1
public void run(String[] args) throws ClientException { try { List<String> remainingArgs = readActionAndOptions(args); switch (action) { case UPLOAD: doUpload(remainingArgs); break; case DELETE: doDelete(remainingArgs); ...
30761550_41
@Override public boolean isConnected() { return client.isConnected(); }
30764186_37
@Restricted(NoExternalUse.class) @RequirePOST public void doProvision(StaplerRequest req, StaplerResponse rsp, @QueryParameter String name) throws IOException { // Temporary workaround for https://issues.jenkins-ci.org/browse/JENKINS-37616 // Using Item.CONFIGURE as users authorized to do so can provision via ...
30803699_35
public boolean hasFilter() { return !"".equals(filter) || !TraceLevel.VERBOSE.equals(filterTraceLevel); }
30806608_0
public String getsegmenthtml(int tick) { r1 = Color.red(textcolor); g1 = Color.green(textcolor); b1 = Color.blue(textcolor); r2 = Color.red(emphasiscolor); g2 = Color.green(emphasiscolor); b2 = Color.blue(emphasiscolor); ing hextextcolor = "#" + Integer.toHexString(r1) + Integer.toHexString(g1) + Integer....
30818918_39
@VisibleForTesting void generateParser(File cupFile) throws IOException, MojoExecutionException { String javaPackage = findJavaPackage(cupFile); // compiling the generated source in target/generated-sources/cup is // the whole point of this plugin. mavenProject.addCompileSourceRoot(generatedSourcesDirectory.ge...
30822986_0
public void runMain(String...args) throws Exception { JCommander jcmdr = new JCommander(this); try { jcmdr.parse(args); } catch(ParameterException e) { System.err.println(e.getMessage()); //User provides invalid input -> print the usage info jcmdr.usage(); try{ Threa...
30837244_6
public double getYaw(double droneHeading, double phoneHeading) { double difference = phoneHeading - droneHeading; if (difference > 180) { difference = difference - 180 * 2; } else if (difference < -180) { difference = difference + 180 * 2; } return difference; }
30840080_2
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) static Single<String> checkGhostBlog(@NonNull String blogUrl, @NonNull OkHttpClient client) { final String adminPagePath = "/ghost/"; String adminPageUrl = NetworkUtils.makeAbsoluteUrl(blogUrl, adminPagePath); ret...
30850287_0
public int countWords(String words) { String[] separateWords = StringUtils.split(words, ' '); return (separateWords == null) ? 0 : separateWords.length; }
30881048_41
public int getRowCount() { return rows.size(); }
30883458_1
public final CommanderConfig loadProperties() throws CommanderException { Properties properties = new Properties(); CommanderConfig config = new CommanderConfig(); InputStream fis = null; try { fis = new FileInputStream(tmpPropFile); properties.load(fis); } catch (FileNotFoundExcepti...
30885057_1
@Override public T call(final RawJsonDocument document) { try { final String wrapped = join(START_OBJECT, document.content(), END_OBJECT); final BeanWrapper<T> bean = mapper.reader(reference).readValue(wrapped); return bean.getEntity(); } catch (final IOException e) { throw new JacksonConversionExce...
30921794_0
public static List<Operation> getOperations(Class<?> someClass) { try { return operations.get(someClass); } catch (ExecutionException e) { throw new Error(e); } }
30923249_47
@Override public Query prepareQuery( String sqlString, int maxRows, Map<String, String> parameters ) throws KettleException { SQL sql = new SQL( sqlString ); Query query; try { IMetaStore metaStore = metastoreLocator != null ? metastoreLocator.getMetastore() : null; DataServiceExecutor executor = resolv...
30927071_4
public static Matcher<Response> created() { final int statusCode = Response.Status.CREATED.getStatusCode(); return new CustomMatcher<Response>("created status (" + statusCode + ") with location header") { @Override public boolean matches(Object o) { if (!(o instanceof Response)) { ...
30947668_11
public MergeFeature getMergeFeature(final String featureId) { if (!this.orderedBuildList.isEmpty() && this.features.containsKey(featureId, getLatestBuild())) { final Feature feature = this.features.get(featureId, getLatestBuild()); final List<String> featureStatuses = getFeatureStatuses(feature); final List<Me...
30950312_0
public ListenableFuture<RpcChannel> createChannel(String server, int port) { Bootstrap b = new Bootstrap(); b.group(group) .channel(NioSocketChannel.class) .handler(init); // Make a new connection. final ChannelFuture channel = b.connect(server, port); final ExposedListenableFuture<RpcChannel> o...
30956727_0
public Long getLast_trade_id() { return last_trade_id; }
30956940_90
public void setWriters(List<WorkflowBundleWriter> writers) { this.writers = writers; }
30957532_1
public static byte[] createCodePoolDataFromClass(Class klass) throws IOException { String res = '/' + klass.getName().replace('.', '/') + ".class"; URL location = klass.getResource(res); System.out.println("createCodePoolDataFromClass " + klass + " -> " + location); String slocation = location.toString...
30977962_5
@Override public WebViewMapFragment build() { if (options == null) { options = new GoogleWebMapType(); } if (options instanceof GoogleWebMapType) { return GoogleWebViewMapFragment.newInstance(options); } if (options instanceof GoogleChinaMapType) { return GoogleChinaWebViewMapFragment.newInstance(...
31106547_52
@Override public void sendNotification(Check check, Subscription subscription, List<Alert> alerts) throws NotificationFailedException { String twilioUrl = StringUtils.trimToNull(seyrenConfig.getTwilioUrl()); if (twilioUrl == null) { LOGGER.warn("Twilio URL needs to be set before sending notification...
31117630_222
@Override public String resolve(final Class<?> entityType, Class<?> idType) { final AtomicReference<Field> found = new AtomicReference<>(); //try to find the ID field ReflectionUtils.doWithFields(entityType, field -> { if (isAnnotated(field)) { if (found.get() == null) { ...
31142024_0
public void tag(String tag) { loggly.setTags(tag); }
31202652_8
public static @Nullable FileType detectDataFileType(@Nonnull File fileName) throws IOException { // Parameter check Preconditions.checkNotNull(fileName); if (fileName.isDirectory()) { // To check for Waters .raw directory, we look for _FUNC[0-9]{3}.DAT for (File f : fileName.listFiles()) { if (f.i...
31214867_26
public boolean importRepository(String json){ ObjectMapper mapper = new ObjectMapper(); ImportExportModel model = null; try{ model = mapper.readValue(json, ImportExportModel.class); } catch (Exception e){ log.error("Exception while reading json import", e); } if (log.isInfoEnabled()){ ...
31231846_6
@PostConstruct public void register() { errorBus.register(this); ErrorBus.setErrorBus(errorBus); }
31282010_1
public void createTask(String name, String description, Boolean urgent, Callback<Task> callback, ErrorCallback errorCallback) { this.name = name; this.description = description; this.urgent = urgent; this.callback = callback; this.errorCallback = errorCallback; interactorHandler.execute(this); }
31306104_55
public int readUbyte(int offset) { return buf[offset + baseOffset] & 0xff; }
31322089_1
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (request instanceof HttpServletRequest) { HttpServletRequest req = (HttpServletRequest) request; doFilterHttp(req, response, chain); } else { chain.doFilter(r...
31323673_64
@Override public CrossValidationIterable<GroupedDataset<KEY, ListDataset<INSTANCE>, INSTANCE>> createIterable( GroupedDataset<KEY, ListDataset<INSTANCE>, INSTANCE> data) { return new GroupedLeaveOneOutIterable(data); }
31334576_2
public LearnStatusSerializer getSerializer() { return serializer; }
31334852_8
@RequestMapping("/") @ResponseBody public String list(Model model, // TODO model should no longer be injected @RequestParam(required = false, defaultValue = "FILENAME") SortBy sortBy, @RequestParam(required = false, defaultValue = "false") boolean desc, @RequestP...
31344294_0
public static <T> JAXBContext createContextIfNull(Class<T> clazz, JAXBContext context) { if (context != null) return context; try { return JAXBContext.newInstance(clazz.getPackage().getName()); } catch (JAXBException e) { LOG.error("Failed to create JaxbContext for {}", clazz.getPackage().getName(), e); ...
31356321_1
public static String getQnameParent(@Nullable String qname) { if (qname == null || qname.isEmpty()) { return ""; } int index = qname.lastIndexOf("."); if (index == -1) { return ""; } return qname.substring(0, index); }
31410513_3
public static VersionName parse(final String versionName) { if (versionName == null) { return null; } String[] array = versionName.split("\\."); if (array.length != 3) { return null; } try { int[] version = new int[array.length]; for (int i = 0; i < version.length...
31460755_0
public String getConfigFilename() { if (agentArgs.length == 0) { return System.getProperty("agent-config"); } return getArg("agent-config"); }