code
stringlengths
73
34.1k
label
stringclasses
1 value
public final void load(final String filename) { logger.debug("Loading the cache from places file: " + filename); try ( InputStream fis = new FileInputStream(filename); ) { load(fis); } catch (IOException e) { logger.error("Problem reading places file",...
java
private static Feature createLocation(final Point point, final LocationType locationType) { final Feature location = new Feature(); location.setGeometry(point); location.setProperty("locationType", locationType); location.setId("location"); return location; }
java
public void checkFamily(final Family family) { final LocalDate familyDate = analyzeDates(family); final LocalDate seenDate = earliestDate(seenFamily); if (seenDate == null) { if (familyDate != null) { seenFamily = family; } } else { if ...
java
private LocalDate analyzeDates(final Family family) { if (family == null) { return null; } LocalDate earliestDate = null; final FamilyAnalysisVisitor visitor = new FamilyAnalysisVisitor(); family.accept(visitor); for (final Attribute attribute : visitor.getTri...
java
@RequestMapping(value = "/v1/upload", method = RequestMethod.POST, consumes = "multipart/form-data") @ResponseBody public final ApiHead upload( @RequestParam("file") final MultipartFile file) { if (file == null) { logger.info("in file upload: file is null"...
java
protected static final StringBuilder renderPad(final StringBuilder builder, final int pad, final boolean newLine) { renderNewLine(builder, newLine); for (int i = 0; i < pad; i++) { builder.append(' '); } return builder; }
java
@Override public final void visit(final Attribute attribute) { attributes.add(attribute); if (ignoreable(attribute)) { return; } trimmedAttributes.add(attribute); }
java
@RequestMapping("/submission") public final String submission( @RequestParam(value = "id", required = false, defaultValue = "SUBN1") final String idString, @RequestParam(value = "db", required = false, defaultValue = "schoeller"...
java
private String loginDestinationUrl(final HttpServletRequest request) { final HttpSession session = request.getSession(); final String requestReferer = request.getHeader("referer"); final String sessionReferer = (String) session .getAttribute(SESSION_REFERER_KEY); if (useR...
java
public LocalDate estimateFromMarriage(final LocalDate localDate) { if (localDate != null) { return localDate; } final PersonNavigator navigator = new PersonNavigator(person); final List<Family> families = navigator.getFamiliesC(); LocalDate date = null; for (f...
java
private LocalDate estimateFromParentMarriage(final Person parent) { final BirthDateEstimator bde = createEstimator(parent); return estimateFromParentMarriage(bde); }
java
private LocalDate ancestorAdjustment(final LocalDate date) { if (date == null) { return null; } return date.plusYears(typicals.ageAtMarriage() + typicals.gapBetweenChildren()) .withMonthOfYear(1).withDayOfMonth(1); }
java
private LocalDate childAdjustment(final LocalDate date) { if (date == null) { return date; } return date.plusYears(typicals.gapBetweenChildren()) .withMonthOfYear(1).withDayOfMonth(1); }
java
private static String buildParentString(final String tag, final String tail) { if (tail.isEmpty()) { return tag; } else { return tag + " " + tail; } }
java
@Override public void visit(final Child child) { final Person person = child.getChild(); if (child.isSet() && person.isSet()) { childList.add(child); children.add(person); } }
java
@Override public void visit(final Family family) { for (final GedObject gob : family.getAttributes()) { gob.accept(this); } }
java
@Override public void visit(final Husband husband) { this.husbandFound = husband; if (husband.isSet()) { father = husband.getFather(); spouses.add(father); } }
java
@Override public void visit(final Wife wife) { this.wifeFound = wife; if (wife.isSet()) { mother = wife.getMother(); spouses.add(mother); } }
java
@Override public ApiPerson createOne(final String db, final ApiPerson person) { logger.info("Entering create person in db: " + db); return create(readRoot(db), person, (i, id) -> new ApiPerson(i, id)); }
java
@Override public void visit(final Attribute attribute) { if ("Restriction".equals(attribute.getString()) && "confidential".equals(attribute.getTail())) { isConfidential = true; } }
java
public GeoCodeItem toGeoCodeItem(final GeoServiceItem gsItem) { if (gsItem == null) { return null; } return new GeoCodeItem(gsItem.getPlaceName(), gsItem.getModernPlaceName(), toGeocodingResult(gsItem.getResult())); }
java
public GeocodingResult toGeocodingResult( final GeoServiceGeocodingResult gsResult) { if (gsResult == null) { return null; } final GeocodingResult result = new GeocodingResult(); final AddressComponent[] addressComponents = gsResult.getAddressCompo...
java
private AddressComponent copy(final AddressComponent in) { final AddressComponent out = new AddressComponent(); out.longName = in.longName; out.shortName = in.shortName; out.types = Arrays.copyOf(in.types, in.types.length); return out; }
java
public Geometry toGeometry(final FeatureCollection featureCollection) { if (featureCollection == null) { return null; } final Geometry geometry = new Geometry(); final Feature location = populateBoundaries(geometry, featureCollection); populateLocation...
java
private LocationType toLocationType(final Object property) { if (property == null) { return null; } return LocationType.valueOf(property.toString()); }
java
public GeoServiceItem toGeoServiceItem(final GeoCodeItem item) { if (item == null) { return null; } return new GeoServiceItem(item.getPlaceName(), item.getModernPlaceName(), toGeoServiceGeocodingResult(item.getGeocodingResult())); }
java
public GeoServiceGeocodingResult toGeoServiceGeocodingResult( final GeocodingResult result) { if (result == null) { return null; } return new GeoServiceGeocodingResult( result.addressComponents, result.formattedAddress, resu...
java
public FeatureCollection toGeoServiceGeometry(final Geometry geometry) { if (geometry == null) { return GeoServiceGeometry.createFeatureCollection( toLocationFeature(new LatLng(Double.NaN, Double.NaN), LocationType.UNKNOWN), null, n...
java
public Person getMother() { if (!isSet()) { return new Person(); } final Person mother = (Person) find(getToString()); if (mother == null) { return new Person(); } else { return mother; } }
java
@Override public void visit(final Attribute attribute) { for (final GedObject gob : attribute.getAttributes()) { gob.accept(this); } }
java
@Override public void visit(final Person person) { for (final GedObject gob : person.getAttributes()) { gob.accept(this); } final PersonNavigator navigator = new PersonNavigator(person); for (final Family family : navigator.getFamilies()) { family.accept(this)...
java
@Override public void visit(final Place place) { placeStrings.add(place.getString()); places.add(place); }
java
@Override public void visit(final Root root) { for (final String letter : root.findSurnameInitialLetters()) { for (final String surname : root.findBySurnamesBeginWith(letter)) { for (final Person person : root.findBySurname(surname)) { person.accept(this); ...
java
public void init() { final String string = getString(); final int bpos = string.indexOf('/'); if (bpos == -1) { prefix = string; surname = ""; suffix = ""; } else { final int epos = string.indexOf('/', bpos + 1); prefix = string...
java
public void init() { surnameIndex.clear(); final RootVisitor visitor = new RootVisitor(); mRoot.accept(visitor); for (final Person person : visitor.getPersons()) { final String key = person.getString(); // Surname for inclusion in the index. // This i...
java
private SortedMap<String, SortedSet<String>> findNamesPerSurname( final String surname) { if (surnameIndex.containsKey(surname)) { return surnameIndex.get(surname); } final SortedMap<String, SortedSet<String>> namesPerSurname = new TreeMap<String, SortedSe...
java
private SortedSet<String> findIdsPerName(final String indexName, final SortedMap<String, SortedSet<String>> names) { if (names.containsKey(indexName)) { return names.get(indexName); } final TreeSet<String> idsPerName = new TreeSet<String>(); names.put(indexName, i...
java
public Set<String> getNamesPerSurname(final String surname) { if (surname == null) { return Collections.emptySet(); } if (!surnameIndex.containsKey(surname)) { return Collections.emptySet(); } return Collections.unmodifiableSet(surnameIndex.get(surname).ke...
java
private Map<String, SortedSet<String>> getNamesPerSurnameMap( final String surname) { if (!surnameIndex.containsKey(surname)) { return Collections.emptyMap(); } return surnameIndex.get(surname); }
java
public Set<String> getIdsPerName(final String surname, final String name) { if (surname == null || name == null) { return Collections.emptySet(); } final Map<String, SortedSet<String>> namesPerSurname = getNamesPerSurnameMap(surname); if (!namesPerSurname.cont...
java
protected final LocalDate estimateFromOtherEvents( final LocalDate localDate) { if (localDate != null) { return localDate; } final PersonAnalysisVisitor visitor = new PersonAnalysisVisitor(); person.accept(visitor); for (final Attribute attr : visitor.getA...
java
public Person getFather() { if (!isSet()) { return new Person(); } final Person father = (Person) find(getToString()); if (father == null) { return new Person(); } else { return father; } }
java
public static PrimitiveMatrix toCorrelations(Access2D<?> covariances, boolean clean) { int size = Math.toIntExact(Math.min(covariances.countRows(), covariances.countColumns())); MatrixStore<Double> covarianceMtrx = MatrixStore.PRIMITIVE.makeWrapper(covariances).get(); if (clean) { ...
java
static ResourceLocator.Request buildChallengeRequest(ResourceLocator.Session session, String symbol) { // The "options" part causes the cookie to be set. // Other path endings may also work, // but there has to be something after the symbol return session.request().host(FINANCE_YAHOO_COM...
java
@Override protected PrimitiveMatrix calculateAssetWeights() { if (this.getOptimisationOptions().logger_appender != null) { BasicLogger.debug(); BasicLogger.debug("###################################################"); BasicLogger.debug("BEGIN RAF: {} MarkowitzModel optim...
java
public static Scalar<?> calculatePortfolioReturn(final PrimitiveMatrix assetWeights, final PrimitiveMatrix assetReturns) { return PrimitiveScalar.valueOf(assetWeights.dot(assetReturns)); }
java
public PrimitiveMatrix calculateAssetReturns(final PrimitiveMatrix assetWeights) { final PrimitiveMatrix tmpAssetWeights = myRiskAversion.compareTo(DEFAULT_RISK_AVERSION) == 0 ? assetWeights : assetWeights.multiply(myRiskAversion); return myCovariances.multiply(tmpAssetWeights); }
java
public PrimitiveMatrix calculateAssetWeights(final PrimitiveMatrix assetReturns) { final PrimitiveMatrix tmpAssetWeights = myCovariances.solve(assetReturns); if (myRiskAversion.compareTo(DEFAULT_RISK_AVERSION) == 0) { return tmpAssetWeights; } else { return tmpAssetWeight...
java
public Scalar<?> calculatePortfolioVariance(final PrimitiveMatrix assetWeights) { PrimitiveMatrix tmpLeft; PrimitiveMatrix tmpRight; if (assetWeights.countColumns() == 1L) { tmpLeft = assetWeights.transpose(); tmpRight = assetWeights; } else { tmpLef...
java
public MarketEquilibrium clean() { final PrimitiveMatrix tmpAssetVolatilities = FinanceUtils.toVolatilities(myCovariances, true); final PrimitiveMatrix tmpCleanedCorrelations = FinanceUtils.toCorrelations(myCovariances, true); final PrimitiveMatrix tmpCovariances = FinanceUtils.toCovariances(t...
java
protected PrimitiveMatrix getViewReturns() { final int tmpRowDim = myViews.size(); final int tmpColDim = 1; final PrimitiveMatrix.DenseReceiver retVal = MATRIX_FACTORY.makeDense(tmpRowDim, tmpColDim); double tmpRet; final double tmpRAF = this.getRiskAversion().doubleValue(); ...
java
public User initialize(String authCode, String redirectUri) throws WorkspaceApiException { return initialize(authCode, redirectUri, null, null); }
java
public User initialize(String token) throws WorkspaceApiException { return initialize(null, null, null, token); }
java
public void destroy(long disconnectRequestTimeout) throws WorkspaceApiException { try { if (this.workspaceInitialized) { notifications.disconnect(disconnectRequestTimeout); sessionApi.logout(); } } catch (Exception e) { throw new...
java
public void setAgentReady(KeyValueCollection reasons, KeyValueCollection extensions) throws WorkspaceApiException { try { VoicereadyData readyData = new VoicereadyData(); readyData.setReasons(Util.toKVList(reasons)); readyData.setExtensions(Util.toKVList(extensions)); ...
java
public void dndOn() throws WorkspaceApiException { try { ApiSuccessResponse response = this.voiceApi.setDNDOn(null); throwIfNotOk("dndOn", response); } catch (ApiException e) { throw new WorkspaceApiException("dndOn failed.", e); } }
java
public void dndOff() throws WorkspaceApiException { try { ApiSuccessResponse response = this.voiceApi.setDNDOff(null); throwIfNotOk("dndOff", response); } catch (ApiException e) { throw new WorkspaceApiException("dndOff failed.", e); } }
java
public void setForward(String destination) throws WorkspaceApiException { try { VoicesetforwardData forwardData = new VoicesetforwardData(); forwardData.setForwardTo(destination); ForwardData data = new ForwardData(); data.data(forwardData); ...
java
public void cancelForward() throws WorkspaceApiException { try { ApiSuccessResponse response = this.voiceApi.cancelForward(null); throwIfNotOk("cancelForward", response); } catch (ApiException e) { throw new WorkspaceApiException("cancelForward failed.", e); ...
java
public void answerCall( String connId, KeyValueCollection reasons, KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData answerData = new VoicecallsidanswerData(); answerData.setReasons(Util.toKVList(rea...
java
public void holdCall( String connId, KeyValueCollection reasons, KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData holdData = new VoicecallsidanswerData(); holdData.setReasons(Util.toKVList(reasons))...
java
public void retrieveCall( String connId, KeyValueCollection reasons, KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData retrieveData = new VoicecallsidanswerData(); retrieveData.setReasons(Util.toKVLi...
java
public void releaseCall( String connId, KeyValueCollection reasons, KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData releaseData = new VoicecallsidanswerData(); releaseData.setReasons(Util.toKVLis...
java
public void initiateConference( String connId, String destination, String location, String outboundCallerId, KeyValueCollection userData, KeyValueCollection reasons, KeyValueCollection extensions ) throws WorkspaceApiExcepti...
java
public void completeConference(String connId, String parentConnId) throws WorkspaceApiException { this.completeConference(connId, parentConnId, null, null); }
java
public void attachUserData(String connId, KeyValueCollection userData) throws WorkspaceApiException { try { VoicecallsidcompleteData completeData = new VoicecallsidcompleteData(); completeData.setUserData(Util.toKVList(userData)); UserDataOperationId data = new UserDataOp...
java
public void deleteUserDataPair(String connId, String key) throws WorkspaceApiException { try { VoicecallsiddeleteuserdatapairData deletePairData = new VoicecallsiddeleteuserdatapairData(); deletePairData.setKey(key); KeyData data = new KeyData(); ...
java
public void redirectCall(String connId, String destination) throws WorkspaceApiException { this.redirectCall(connId, destination, null, null); }
java
public void redirectCall( String connId, String destination, KeyValueCollection reasons, KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidredirectData redirectData = new VoicecallsidredirectData(); ...
java
public void clearCall( String connId, KeyValueCollection reasons, KeyValueCollection extensions ) throws WorkspaceApiException { try { VoicecallsidanswerData clearData = new VoicecallsidanswerData(); clearData.setReasons(Util.toKVList(reason...
java
public ApiResponse<CurrentSession> getCurrentSessionWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = getCurrentSessionValidateBeforeCall(null, null); Type localVarReturnType = new TypeToken<CurrentSession>(){}.getType(); return apiClient.execute(call, localVarReturnType); ...
java
public ApiResponse<CurrentSession> getUserInfoWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = getUserInfoValidateBeforeCall(null, null); Type localVarReturnType = new TypeToken<CurrentSession>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
java
public List<StatisticValue> peek(String subscriptionId) throws WorkspaceApiException { try { InlineResponse2002 resp = api.peek(subscriptionId); Util.throwIfNotOk(resp.getStatus()); InlineResponse2002Data data = resp.getData(); if(data == null) ...
java
public void unsubscribe(String subscriptionId) throws WorkspaceApiException { try { ApiSuccessResponse resp = api.unsubscribe(subscriptionId); Util.throwIfNotOk(resp); } catch(ApiException ex) { throw new WorkspaceApiException("Cannot unsubscribe", ex); ...
java
public ApiResponse<ApiSuccessResponse> ackRecentMissedCallsWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = ackRecentMissedCallsValidateBeforeCall(null, null); Type localVarReturnType = new TypeToken<ApiSuccessResponse>(){}.getType(); return apiClient.execute(call, localVarRe...
java
public ApiResponse<Void> swaggerDocWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = swaggerDocValidateBeforeCall(null, null); return apiClient.execute(call); }
java
public ApiResponse<Info> versionInfoWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = versionInfoValidateBeforeCall(null, null); Type localVarReturnType = new TypeToken<Info>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
java
public ApiResponse<Void> notificationsWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = notificationsValidateBeforeCall(null, null); return apiClient.execute(call); }
java
public SearchResult<Target> search(String searchTerm, TargetsSearchOptions options) throws WorkspaceApiException { try { String types = null; List<String> typesArray = null; if(options.getTypes() != null){ typesArray = new ArrayList<>(10); ...
java
public Target getTarget(long id, TargetType type) throws WorkspaceApiException { try { TargetsResponse resp = targetsApi.getTarget(new BigDecimal(id), type.getValue()); Util.throwIfNotOk(resp.getStatus()); Target target = null; if(resp.getData()...
java
public void deletePersonalFavorite(Target target) throws WorkspaceApiException { try { ApiSuccessResponse resp = targetsApi.deletePersonalFavorite(String.valueOf(target.getId()), target.getType().getValue()); Util.throwIfNotOk(resp); } catch(ApiException ex) { ...
java
public SearchResult<Target> getPersonalFavorites(int limit) throws WorkspaceApiException { try { TargetsResponse resp = targetsApi.getPersonalFavorites(limit > 0? new BigDecimal(limit): null); Util.throwIfNotOk(resp.getStatus()); TargetsResponseData data = r...
java
public void savePersonalFavorite(Target target, String category) throws WorkspaceApiException { TargetspersonalfavoritessaveData data = new TargetspersonalfavoritessaveData(); data.setCategory(category); data.setTarget(toInformation(target)); PersonalFavoriteData favData = new Person...
java
public void ackRecentMissedCalls() throws WorkspaceApiException { try { ApiSuccessResponse resp = targetsApi.ackRecentMissedCalls(); Util.throwIfNotOk(resp); } catch(ApiException ex) { throw new WorkspaceApiException("Cannot ack recent missed calls", ex)...
java
public ApiResponse<InlineResponse200> getCallsWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = getCallsValidateBeforeCall(null, null); Type localVarReturnType = new TypeToken<InlineResponse200>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
java
public ApiSuccessResponse switchToBargeIn(String id, MonitoringScopeData monitoringScopeData) throws ApiException { ApiResponse<ApiSuccessResponse> resp = switchToBargeInWithHttpInfo(id, monitoringScopeData); return resp.getData(); }
java
public ApiSuccessResponse switchToCoaching(String id, MonitoringScopeData monitoringScopeData) throws ApiException { ApiResponse<ApiSuccessResponse> resp = switchToCoachingWithHttpInfo(id, monitoringScopeData); return resp.getData(); }
java
private List<DependencyError> checkAllowedSection(final Dependencies dependencies, final Package<DependsOn> allowedPkg, final ClassInfo classInfo) { final List<DependencyError> errors = new ArrayList<DependencyError>(); final Iterator<String> it = classInfo.getImports().iterator(); ...
java
private static List<DependencyError> checkForbiddenSection(final Dependencies dependencies, final Package<NotDependsOn> forbiddenPkg, final ClassInfo classInfo) { final List<DependencyError> errors = new ArrayList<DependencyError>(); final Iterator<String> it = classInfo.getImports()....
java
private static String nameOnly(final String filename) { final int p = filename.lastIndexOf('.'); if (p == -1) { return filename; } return filename.substring(0, p); }
java
private static List<DependencyError> checkAlwaysForbiddenSection(final Dependencies dependencies, final ClassInfo classInfo) { final List<DependencyError> errors = new ArrayList<DependencyError>(); final Iterator<String> importedPackages = classInfo.getImports().iterator(); while (importe...
java
public final void analyze(final File classesDir) { final FileProcessor fileProcessor = new FileProcessor(new FileHandler() { @Override public final FileHandlerResult handleFile(final File classFile) { if (!classFile.getName().endsWith(".class")) { ...
java
static void analyzeDir(final Set<Class<?>> classes, final File baseDir, final File srcDir, final boolean recursive, final ClassFilter classFilter) { final FileProcessor fileProcessor = new FileProcessor(new FileHandler() { @Override public final FileHandlerResult handle...
java
static EntityManager bind(EntityManager entityManager) { return entityManagerMap( true ).put( entityManager.getEntityManagerFactory(), entityManager ); }
java
static EntityManager unbind(EntityManagerFactory factory) { final Map<EntityManagerFactory,EntityManager> entityManagerMap = entityManagerMap(false); EntityManager existing = null; if ( entityManagerMap != null ) { existing = entityManagerMap.remove( factory ); doCleanup(...
java
static void unBindAll(Consumer<EntityManager> function) { final Map<EntityManagerFactory,EntityManager> entityManagerMap = entityManagerMap(false); if ( entityManagerMap != null ) { Iterator<EntityManager> iterator = entityManagerMap.values().iterator(); while (iterator.hasNext()...
java
EntityManager build(EntityManagerContext entityManagerContext) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); return (EntityManager) Proxy.newProxyInstance( classLoader, new Class[]{EntityManager.class}, new SharedEntityManager...
java
public static boolean hasAnnotation(final List<AnnotationInstance> annotations, final String annotationClaszName) { final DotName annotationName = DotName.createSimple(annotationClaszName); for (final AnnotationInstance annotation : annotations) { if (annotation.name().equals(annotationNa...
java
public static List<MethodInfo> findOverrideMethods(final Index index, final MethodInfo method) { return findOverrideMethods(index, method.declaringClass(), method, 0); }
java
public static void setPrivateField(final Object obj, final String name, final Object value) { try { final Field field = obj.getClass().getDeclaredField(name); field.setAccessible(true); field.set(obj, value); } catch (final Exception ex) { throw new Runtim...
java