id
stringlengths
7
14
text
stringlengths
1
37.2k
18709657_13
@Override public synchronized ViNode node(String namePattern) { ensureAlive(); if (liveNodes.containsKey(namePattern)) { return liveNodes.get(namePattern); } else if (deadNodes.containsKey(namePattern)) { return deadNodes.get(namePattern); } else if (dynamicSelectors.containsKey(namePattern)){ return dynami...
18749529_0
public static StepFaultCause blame(Blame blame) { return new Builder(blame); }
18759272_59
public ClosedConnectionReport closeConnections(CloseType closeType) { return closeConnectionsByUrl(closeType, ""); }
18774289_3
public Leaf rightLeaf() { return (rightLeaf); }
18778871_50
@EventHandler public void handleCreated(AccountReceivableFeeCreatedEvent event) { AccountReceivableFeeEntry entry = new AccountReceivableFeeEntry(); entry.copy(event); repository.save(entry); }
18802764_21
public static boolean cutFile(File originFile, File targetFile) { Assert.notNull(originFile); Assert.notNull(targetFile); copyFile(originFile, targetFile); if (originFile.length() == targetFile.length()) { return originFile.delete(); } return false; }
18817575_7
@Override public int hashCode() { return this.hashCode; }
18826763_2
public List<Person> getValidPeople() { return validPeople; }
18830102_391
public Map<String, Object> readPropertyStandalone(JsonReader reader, final EdmProperty edmProperty, final DeserializerProperties readProperties) throws EntityProviderException { return readPropertyStandalone(reader, EntityInfoAggregator.create(edmProperty), readProperties); }
18830782_0
public void retrieveUser(final UserCallback callback) { mExecutor.execute(new RetrieveUserTask(callback)); }
18831720_2
public static String join(Collection c) { return join(c, ", "); }
18871700_92
@Override @SuppressWarnings("deprecation") public boolean containsRowWithKey(Object... keys) throws SQLException { String query = null; boolean contains = false; if (delegate != null) { if (delegate instanceof FreeformStatementDelegate) { try { StatementHelper sh = ((Free...
18894744_18
protected Object invokeJavascript(String function) { return checkUndefined(jsObject.call(function)); }
18907185_6
@Override public Long incrBy(String key, long integer) { Long result = 0L; if (this.exists(key)) { Long newValue = Long.valueOf(this.get(key)).longValue() + integer; this.del(key); this.set(key, newValue.toString()); result = newValue; } else { this.set(key, String.valueOf(integer)); result = integer; }...
18910111_9
public static ValidationResult isValid(Form form) { if (form == null) { throw new IllegalAddException("Arugment cannot be null"); } Class<? extends Object> type = form.getClass(); String key = type.getName(); ValidatorContianer contianer = cached.get(key); if (contianer == null) { ...
18912218_12
static List<String> expandArgs(List<String> args0, List<String> args) { final List<String> args1 = new ArrayList<String>(); boolean expanded = false; for (String a : args0) { if (a.startsWith("$")) { if (a.equals("$*")) { args1.addAll(args); expanded = tru...
18942355_240
@Override public void replaceAll(UnaryOperator<E> operator) { updates.beginEvent(true); // nested due to set below for (int i = size() - 1; i >= 0; i--) { E oldValue = get(i); E newValue = operator.apply(oldValue); if (oldValue != newValue) { /...
18948102_0
@Override public void parse(Bytes bytes) { long limit = bytes.readLimit(), limit2 = limit; while (limit2 > bytes.readPosition() && bytes.readByte(limit2 - 1) != FIELD_TERMINATOR) limit2--; bytes.readLimit(limit2); while (bytes.readRemaining() > 0) { long fieldNum = bytes.parseLong(); ...
18974940_126
public String getWebClientId() { return mAppConfig.getString("appspot_webClientId"); }
18982942_19
public static List<Node> isParallel(final List<Node> aFirstWay, final List<Node> aSecondWay) { ArrayList<Node> aFirstWayCopy = new ArrayList<Node>(aFirstWay); ArrayList<Node> aSecondWayCopy = new ArrayList<Node>(aSecondWay); List<Node> retval = isParallelInternal(aFirstWayCopy, aSecondWayCopy); if (ret...
18997610_32
public static String loadFileFromClasspath(String location) { InputStream inputStream = ClasspathHelper.class.getResourceAsStream(location); if(inputStream == null) { inputStream = ClasspathHelper.class.getClassLoader().getResourceAsStream(location); } if(inputStream == null) { inputS...
19008038_65
public static String getIri(OWLDeclarationAxiom expression) { return expression.getEntity().getIRI().toString(); }
19024198_201
@Override protected void encodeInitialLine(ByteBuf buf, HttpRequest request) throws Exception { request.getMethod().encode(buf); buf.writeByte(SP); // Add / as absolute path if no is present. // See http://tools.ietf.org/html/rfc2616#section-5.1.2 String uri = request.getUri(); if (uri.length(...
19060490_0
public long getTimestamp() throws IOException { return getTimestamps(1); }
19062268_150
@Override public Map<String,String> parameters() { return this.parameters; }
19067639_125
public Boolean isRegisteredFormat(String format){ return formats.containsKey(format.toLowerCase()); }
19069584_1
public static String replaceAllVariables(String strVars) { return replaceAllVariables(strVars, null); }
19076996_898
public static Endpoint lookupEndpoint(EndpointKey epKey, ReadOnlyTransaction transaction) { Optional<Endpoint> optionalEp = readFromDs(LogicalDatastoreType.OPERATIONAL, endpointIid(epKey.getL2Context(), epKey.getMacAddress()), transaction); if (optionalEp.isPresent()) { return optio...
19097627_21
@Override public Value compile(@Nullable Value value, Context context) { if (null == value) { return NO_GRAVITY; } return ParseHelper.getGravity(value.getAsString()); }
19097773_39
public static Date parse(String dateString, String format) { try { SimpleDateFormat sdf = new SimpleDateFormat(format); sdf.setLenient(false); Date date = sdf.parse(dateString); return date; } catch (Exception e) { LOGGER.error("error timestamp format,error:{}", e); ...
19116210_36
@Override public OrgData process(OrgData input) throws Exception { ServiceContext context = getServiceContext(); List<ValidationError> errors = Lists.newArrayList(); if (StringUtils.isBlank(input.getOrg().getOrgTypeCode())) { ValidationError error = new ValidationError("orgTypeCode", "Organization Type", "The ...
19141372_0
boolean hasRemotePartyId() { return remotePartyId != null; }
19143929_721
@Override public boolean handles(UiyValueType uiyValueType) { Preconditions.checkNotNull(uiyValueType); return UiyValueType.PERCENT == uiyValueType || UiyValueType.NUMBER_PER_1000 == uiyValueType; }
19163443_26
@ApiMethod(name = "getProfile", path = "profile", httpMethod = HttpMethod.GET) public Profile getProfile(final User user) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException("Authorization required"); } // TODO // load the Profile Entity String userId = user.g...
19169174_57
@NonNull public String getElementsKey() { return elementsKey; }
19172100_0
public void accept(ClassVisitor visitor) throws ClassFormatException { int version = this.getMajor(); int accessFlags = this.getAccessFlags(); String className = this.getClassName(); String superClassName = this.getSuperClassName(); String signature = null; visitor.visit(version, accessFlags,...
19253642_1
public static BEValue bdecode(InputStream in) throws IOException { return new BDecoder(in).bdecode(); }
19257422_24
@Override public final boolean getBool(Record rec) { throw new UnsupportedOperationException(); }
19260634_12
public int getLayoutResourceId() { return mLayoutResourceId; }
19260719_0
static void processArgs(String args, Config config) { String[] split = args.split(",\\s*"); for (String s : split) { if (s.equals("debug")) { DEBUG = true; } if (s.equals("tty")) { config.setTty(true); } if (s.startsWith("context=")) { CONTEXT = s.replace("context=", ""); } if (s.equals("window...
19271154_30
@Nullable ;
19276770_0
private UUID() { }
19308274_7
void parseLine(final String line) { if(line == null) return; String normalizedLine = line.trim().toLowerCase(); // inlcudes cannot be handled because of working directory mismatch while scanning if(normalizedLine.startsWith("!include")) { return; } if(parsingState == ParsingState.IGNO...
19314283_32
@Override public void refreshFileHandles() throws InterruptedException { latch.await(); }
19317653_20
public boolean isCompleted() { return completed; }
19351480_28
public List<String> getPathComponents() { return Arrays.asList(withFolders(job).split("/job/")); }
19361874_2
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/plain"); response.getWriter().println("Hello App Engine - Flexible!"); }
19367053_0
@Override public double getCurrentError() { if(weightSeen==0) return Double.MAX_VALUE; else { double sum=0; int numOutputs=sumSquaredError.length; for (int i=0; i<numOutputs; i++) sum+=Math.sqrt(sumSquaredError[i]/sumSquaredErrorToTargetMean[i]); return sum/numLearnedOutputs; } }
19368221_328
public static String processTemplateContents(String templateContents, EntityDriver driver, Map<String,? extends Object> extraSubstitutions) { return processTemplateContents(templateContents, new EntityAndMapTemplateModel(driver, extraSubstitutions)); }
19370824_2
@Override public boolean shouldExecuteOnProject(Project project) { return StringUtils.isNotEmpty(coverageReportPath(null)) || StringUtils.isNotEmpty(itReportPath()) || StringUtils.isNotEmpty(overallReportPath()) || StringUtils.isNotEmpty(unitTestReportPath()); }
19383958_20
public BatchUpdateSpreadsheetResponse pivotTables(String spreadsheetId) throws IOException { Sheets service = this.service; // Create two sheets for our pivot table. List<Request> sheetsRequests = new ArrayList<>(); sheetsRequests.add(new Request().setAddSheet(new AddSheetRequest())); sheetsRequest...
19394307_2
@Override public Long get() { return getPreferences().getLong(getKey(), getDefaultValue()); }
19408279_6
void run() { int dpi = 360; int xsize = 2976; int ysize = 4209; try(InputStream fin = new BufferedInputStream(new FileInputStream(ins)); AfpOutputStream out = new AfpOutputStream(new BufferedOutputStream(new FileOutputStream(outs)))) { String ovlName = String.format("%8s", new File(outs).getName()).substr...
19419350_42
public byte[] toByteArray() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { write(stream); } catch (IOException e) { // Should not happen as ByteArrayOutputStream does not throw IOException on write throw new RuntimeException(e); } return stream.toByteArra...
19436066_16
public int getIntValue(Properties props, String key, int defaultValue) { return Integer.parseInt(getStringValue(props, key, Integer.toString(defaultValue))); }
19454960_0
public int read(char[] cbuf, int off, int len) throws IOException { int charactersRead = wrappedReader.read(cbuf, off, len); if (charactersRead > 0) { if (rewindable && pos + charactersRead > buffer.length) { rewindable = false; } if (pos < buffer.length) { int freeBufferSpace = buffer.len...
19455304_2
public JsonObject register(Registration request) { tracer.info("registration arrived: " + request); Registration registration = em.merge(request); tracer.info("registration stored: " + request); registration.setCalculator(priceCalculator::calculateTotal); tracer.info("price computed: " + registratio...
19458722_0
public JSONObject decryptData(final String encryptedData, final String iv) { final byte[] aesKey = Base64.decodeBase64(sessionKey); final byte[] aesCipher = Base64.decodeBase64(encryptedData); final byte[] aesIV = Base64.decodeBase64(iv); final byte[] decryptedBytes = AESUtils.decrypt(aesCipher, aesKey, aesIV); f...
19480672_1
public static String trim(String input, final String toTrim) { if (input == null) return null; Preconditions.checkNotNull(toTrim); input = input.trim(); while (!input.isEmpty() && input.length() >= toTrim.length() && input.startsWith(toTrim)) input = input.substring(toTrim.length(), input.length()); ...
19481229_1
public long createRecord() { return unsafe.allocateMemory(byteSize); }
19482426_14
@Override public void reset() { throw new UnsupportedOperationException("Mark not supported"); }
19523554_0
@Override public void close(TaskAttemptContext context) throws IOException, InterruptedException { // Do nothing }
19530423_4
@Override public List<Map<String, Object>> findBySQL(SQL sql, Class<?> clazz) { if (sql == null) { throw new IllegalArgumentException("param sql should not be null"); } if (clazz == null) { throw new IllegalArgumentException("param class should not be null"); } CheckUtil.checkSQL(sq...
19537685_13
public void removeUser(String userName) throws CommunicationException { try { WebResource webResource = createRequestResource( "users/" + userName); webResource.delete(); } catch (UniformInterfaceException t) { throw new CommunicationException( "Exception ...
19547790_0
@Override public void debug(String msg) { log(LogType.DEBUG, msg, null); }
19551343_0
public static InetSocketAddress parse(String str) { String address, port; if (str.startsWith("[")) { int addressEnd = str.indexOf(']'); if (addressEnd == -1) throw new IllegalArgumentException(); if ((addressEnd + 2) > str.length()) throw new IllegalArgumentException(); address = str.substring(1, add...
19576190_8
public static boolean hasValidName(String name, boolean raiseException) { boolean valid = name == null || name.length() == 0 || (name.charAt(0) != '_' && !name.contains("$") && !name.contains(".") && !name.contains("\0")); if(!valid) { LiquidTools.exceptionOrLog(raiseException, "Event name cannot start ...
19603587_1
public List<CodeCompletionHint> complete(String incompletePath) { List<CodeCompletionHint> hints = new ArrayList<CodeCompletionHint>(); String objectPath = null; String prefix = null; String lastDelimiter = null; int lastSplit = splitter.lastSplit(incompletePath); if (lastSplit == -1) { prefix = inco...
19624760_12
public static Track reverse(Track track) { Track view = reverseView(track); return new DefaultTrack(view.getId(), view.getMetadata(), track.getWaypoints(), view.getSegments(), view.getStatistics()); }
19628709_8
public void transferTaxFor(Person person) { if (person == null) { taxService.sendErrorReport(); return; } taxService.transferTaxFor(person); }
19634578_0
public void index(final Path sstablePath) throws IOException { final FileSystem fileSystem = FileSystem.get(URI.create(sstablePath.toString()), configuration); final FileStatus fileStatus = fileSystem.getFileStatus(sstablePath); if (fileStatus.isDir()) { LOG.info("SSTable Indexing directory {}", s...
19638422_1129
@VisibleForTesting void resolveLogPathReferences(Telemetry telemetry, List<VmLog> logs) { Map<String, Object> fluentAttributes = telemetry.getFluentAttributes(); if (CollectionUtils.isNotEmpty(logs)) { Properties props = new Properties(); props.setProperty(SERVER_LOG_FOLDER_PREFIX, fluentAttribu...
19668829_0
@Override public final int read(ByteBuffer dst) throws IOException { int available = this.buf.remaining(); int size = java.lang.Math.min(dst.remaining(), available); if (size == 0) { // end of stream return -1; } ByteBuffer slice = this.buf.slice(); slice.limit(size); dst.pu...
19685642_1
@Override protected boolean isLoggable(int priority) { return priority >= mLogPriority; }
19688946_30
public void addFactory(String id, FlexFactory factory) { if (id == null) { // Cannot add ''{0}'' with null id to the ''{1}'' ConfigurationException ex = new ConfigurationException(); ex.setMessage(ConfigurationConstants.NULL_COMPONENT_ID, new Object[]{"FlexFactory", MESSAGEBROKER}); ...
19691579_63
public void setCourses(List<Course> courses) { this.courses = courses; dataSource.save(courses); }
19715233_2
public static String bytesToString(byte[] bytes, String encoding) { if(bytes == null) { throw new IllegalArgumentException("bytes may not be null in string conversion"); } if(bytes.length == 0) { return null; } try { return new String(bytes, encoding); } catch (Exception e) { throw new IllegalArgumentExc...
19733248_1
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel input) { DocumentModelList proxies = session.getProxies(input.getRef(), null); for (DocumentModel proxy : proxies) { session.removeDocument(proxy.getRef()); } session.save(); return null; }
19739444_17
@Override public String render(ModelAndView modelAndView) { String viewName = modelAndView.getViewName(); try { Template template = handlebars.compile(viewName); return template.apply(modelAndView.getModel()); } catch (IOException e) { throw new RuntimeIOException(e); } }
19746703_106
@Override public int compareTo(LatLong latLong) { if (this.longitude > latLong.longitude) { return 1; } else if (this.longitude < latLong.longitude) { return -1; } else if (this.latitude > latLong.latitude) { return 1; } else if (this.latitude < latLong.latitude) { return -1; } return 0; }
19748926_0
@Override public View getCardView(int position, CardModel model, View convertView, ViewGroup parent) { if(convertView == null) { LayoutInflater inflater = LayoutInflater.from(getContext()); convertView = inflater.inflate(R.layout.std_card_inner, parent, false); assert convertView != null; } ((ImageView) conve...
19759384_20
public static <T> void partialSort(List<T> list, List<Integer> items, Comparator<? super T> c) { List<T> temp = Lists.newLinkedList(); for (int index : items) { temp.add(list.get(index)); } Collections.sort(temp, c); for (int i = 0; i < temp.size(); ++i) { list.set(items.get(i), temp...
19777812_9
public static Result parse(String body) throws ParseException { try { Matcher m; Result result = new Result(); JSONObject jo = new JSONObject(body); if (jo.has("error")) { throw new ParseException(jo.getString("error"), body); } String i3 = jo.getString(...
19781635_3
@SuppressWarnings("unchecked") @Override public C getView(int position, View convertView, ViewGroup parent) { C view = null; if (convertView != null) { view = (C) convertView; } else { view = createView(); } view.update(getItem(position)); return view; }
19786369_9
@Override public void close() { if (catHelper != null) { catHelper.close(); catHelper = null; } super.close(); }
19789077_76
@Override public void save(String ring, CassandraInstance instance) { PutAttributesRequest request = new PutAttributesRequest( domain(ring), String.valueOf(instance.getId()), buildSaveAttributes(instance)); client.putAttributes(request); }
19802105_7
public static boolean shouldFollowRedirect(HttpRedirectPolicy redirectPolicy, URL currentURL, URL redirectURL) { return POLICY_CHECKERS.get(redirectPolicy).compare(currentURL, redirectURL) == 0; }
19821698_135
@Override protected <T> void doExecute(SelectContext<T> context) { super.doExecute(context); Map<String, List<String>> protocolParameters = context.getProtocolParameters(); // TODO: make symmetrical with AgRequestBuilder (namely hide the parser inside the builder) // Or even better - convert "filter...
19825381_78
@SuppressWarnings("WeakerAccess") // Public API. public int run( String[] args ) { CommandLine cl = new CommandLine(this); cl.setUsageHelpAutoWidth(true); cl.setExecutionStrategy(new CommandLine.RunAll()); cl.setOverwrittenOptionsAllowed(true); return cl.execute(args); }
19827565_2
public static String generate(String releaseFilename) { if (releaseFilename != null && !releaseFilename.endsWith(".zip")) { return releaseFilename.replaceAll("-", "_"); } releaseFilename = releaseFilename.replace(".zip", ""); String[] splits = releaseFilename.split("_", -1); for (int i = 0; i < splits.length; i+...
19836152_70
public List transformList( List source, EvaluationContext evaluationContext, ExpressionEvaluationSummary summary, Map<String, Object> additionalContext) { List<Object> result = new ArrayList<>(); for (Object obj : source) { if (obj instanceof Map) { result.add(transformMap((Map<String, Obj...
19851429_9
@Override public String evaluate(final Document target) { final String result = currentState.evaluate(target); return result != null && result.trim().length() > 0 ? result : null; }
19873472_1
public static byte[] read(String filename) throws IOException { BufferedInputStream stream = new BufferedInputStream( new FileInputStream(filename)); byte[] content = read(stream); stream.close(); return (content); }
19888357_5
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userRepository.findByUsername(username); if (user != null) { return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), mapRoles(user)); } th...
19932015_26
@Override public void deleteSchema() throws GoraException { }
19961085_109
public static Status getServiceStatus() { return getServiceStatus(serviceStatusCallback); }
19975898_1
public static Boolean toBoolean(Verdict verdict) { if(verdict == Verdict.INCONCLUSIVE) return null; if(verdict == Verdict.PASS) return true; return false; }
19995362_4
public static String getLocaleCode(String localeStr) { Locale locale = FALLBACK; try { locale = (localeStr != null)? LocaleUtils.toLocale(localeStr):FALLBACK; } catch (IllegalArgumentException e) { logger.warn("cannot get locale from {}. Returning fallback locale: "+FALLBACK,localeStr); ...
20007993_7
public static Timer timer(String name) { return metrics.timer(name); }
20046149_0
public void get() throws InterruptedException { sync.innerGet(); }