code
stringlengths
73
34.1k
label
stringclasses
1 value
public double[] getZeroRates(double[] maturities) { double[] values = new double[maturities.length]; for(int i=0; i<maturities.length; i++) { values[i] = getZeroRate(maturities[i]); } return values; }
java
public static double[][] invert(double[][] matrix) { if(isSolverUseApacheCommonsMath) { // Use LU from common math LUDecomposition lu = new LUDecomposition(new Array2DRowRealMatrix(matrix)); double[][] matrixInverse = lu.getSolver().getInverse().getData(); return matrixInverse; } else { return or...
java
public static double[][] factorReductionUsingCommonsMath(double[][] correlationMatrix, int numberOfFactors) { // Extract factors corresponding to the largest eigenvalues double[][] factorMatrix = getFactorMatrix(correlationMatrix, numberOfFactors); // Renormalize rows for (int row = 0; row < correlationMatrix...
java
public static double[][] pseudoInverse(double[][] matrix){ if(isSolverUseApacheCommonsMath) { // Use LU from common math SingularValueDecomposition svd = new SingularValueDecomposition(new Array2DRowRealMatrix(matrix)); double[][] matrixInverse = svd.getSolver().getInverse().getData(); return matrixInver...
java
public static double[][] diag(double[] vector){ // Note: According to the Java Language spec, an array is initialized with the default value, here 0. double[][] diagonalMatrix = new double[vector.length][vector.length]; for(int index = 0; index < vector.length; index++) { diagonalMatrix[index][index] = vecto...
java
private double[] formatTargetValuesForOptimizer() { //Put all values in an array for the optimizer. int numberOfMaturities = surface.getMaturities().length; double mats[] = surface.getMaturities(); ArrayList<Double> vals = new ArrayList<Double>(); for(int t = 0; t<numberOfMaturities; t++) { double mat = ...
java
public static ForwardCurveInterpolation createForwardCurveFromDiscountFactors(String name, double[] times, RandomVariable[] givenDiscountFactors, double paymentOffset) { ForwardCurveInterpolation forwardCurveInterpolation = new ForwardCurveInterpolation(name, paymentOffset, InterpolationEntityForward.FORWARD, null); ...
java
public static ForwardCurveInterpolation createForwardCurveFromMonteCarloLiborModel(String name, LIBORModelMonteCarloSimulationModel model, double startTime) throws CalculationException{ int timeIndex = model.getTimeIndex(startTime); // Get all Libors at timeIndex which are not yet fixed (others null) and times for...
java
private void addForward(AnalyticModel model, double fixingTime, RandomVariable forward, boolean isParameter) { double interpolationEntitiyTime; RandomVariable interpolationEntityForwardValue; switch(interpolationEntityForward) { case FORWARD: default: interpolationEntitiyTime = fixingTime; interpolation...
java
public LinearInterpolatedTimeDiscreteProcess add(LinearInterpolatedTimeDiscreteProcess process) throws CalculationException { Map<Double, RandomVariable> sum = new HashMap<>(); for(double time: timeDiscretization) { sum.put(time, realizations.get(time).add(process.getProcessValue(time, 0))); } return new L...
java
public StochasticPathwiseLevenbergMarquardt getCloneWithModifiedTargetValues(List<RandomVariable> newTargetVaues, List<RandomVariable> newWeights, boolean isUseBestParametersAsInitialParameters) throws CloneNotSupportedException { StochasticPathwiseLevenbergMarquardt clonedOptimizer = clone(); clonedOptimizer.targe...
java
public RandomVariableInterface[] getBasisFunctions(double exerciseDate, LIBORModelMonteCarloSimulationInterface model) throws CalculationException { ArrayList<RandomVariableInterface> basisFunctions = new ArrayList<RandomVariableInterface>(); RandomVariableInterface basisFunction; // Constant basisFunction =...
java
private DiscountCurve createDiscountCurve(String discountCurveName) { DiscountCurve discountCurve = model.getDiscountCurve(discountCurveName); if(discountCurve == null) { discountCurve = DiscountCurveInterpolation.createDiscountCurveFromDiscountFactors(discountCurveName, new double[] { 0.0 }, new double[] { 1.0 ...
java
public double d(double x){ int intervalNumber =getIntervalNumber(x); if (intervalNumber==0 || intervalNumber==points.length) { return x; } return getIntervalReferencePoint(intervalNumber-1); }
java
public double getValue(ForwardCurveInterface forwardCurve, double swaprateVolatility) { double swaprate = swaprates[0]; for (double swaprate1 : swaprates) { if (swaprate1 != swaprate) { throw new RuntimeException("Uneven swaprates not allows for analytical pricing."); } } double[] swapTenor = new dou...
java
public double getRate(AnalyticModel model) { if(model==null) { throw new IllegalArgumentException("model==null"); } ForwardCurve forwardCurve = model.getForwardCurve(forwardCurveName); if(forwardCurve==null) { throw new IllegalArgumentException("No forward curve of name '" + forwardCurveName + "' found i...
java
public RandomVariable[] getParameter() { double[] parameterAsDouble = this.getParameterAsDouble(); RandomVariable[] parameter = new RandomVariable[parameterAsDouble.length]; for(int i=0; i<parameter.length; i++) { parameter[i] = new Scalar(parameterAsDouble[i]); } return parameter; }
java
public static DiscountCurveInterface createDiscountCurveFromMonteCarloLiborModel(String forwardCurveName, LIBORModelMonteCarloSimulationModel model, double startTime) throws CalculationException{ // Check if the LMM uses a discount curve which is created from a forward curve if(model.getModel().getDiscountCurve()=...
java
public static boolean isEasterSunday(LocalDate date) { int y = date.getYear(); int a = y % 19; int b = y / 100; int c = y % 100; int d = b / 4; int e = b % 4; int f = (b + 8) / 25; int g = (b - f + 1) / 3; int h = (19 * a + b - d - g + 15) % 30; int i = c / 4; int k = c % 4; int l = (32 + 2 * e ...
java
public static LocalDateTime getDateFromFloatingPointDate(LocalDateTime referenceDate, double floatingPointDate) { if(referenceDate == null) { return null; } Duration duration = Duration.ofSeconds(Math.round(floatingPointDate * SECONDS_PER_DAY)); return referenceDate.plus(duration); }
java
public static double getFloatingPointDateFromDate(LocalDateTime referenceDate, LocalDateTime date) { Duration duration = Duration.between(referenceDate, date); return ((double)duration.getSeconds()) / SECONDS_PER_DAY; }
java
public static LocalDate getDateFromFloatingPointDate(LocalDate referenceDate, double floatingPointDate) { if(referenceDate == null) { return null; } return referenceDate.plusDays((int)Math.round(floatingPointDate*365.0)); }
java
public double inverseCumulativeDistribution(double x) { double p = Math.exp(-lambda); double dp = p; int k = 0; while(x > p) { k++; dp *= lambda / k; p += dp; } return k; }
java
protected void addPoint(double time, RandomVariable value, boolean isParameter) { synchronized (rationalFunctionInterpolationLazyInitLock) { if(interpolationEntity == InterpolationEntity.LOG_OF_VALUE_PER_TIME && time == 0) { boolean containsOne = false; int index=0; for(int i = 0; i< value.size(); i++){if(...
java
public static String getOffsetCodeFromSchedule(Schedule schedule) { double doubleLength = 0; for(int i = 0; i < schedule.getNumberOfPeriods(); i ++) { doubleLength += schedule.getPeriodLength(i); } doubleLength /= schedule.getNumberOfPeriods(); doubleLength *= 12; int periodLength = (int) Math...
java
public static String getOffsetCodeFromCurveName(String curveName) { if(curveName == null || curveName.length() == 0) { return null; } String[] splits = curveName.split("(?<=\\D)(?=\\d)"); String offsetCode = splits[splits.length-1]; if(!Character.isDigit(offsetCode.charAt(0))) { return null; }...
java
public ScheduleDescriptor generateScheduleDescriptor(LocalDate startDate, LocalDate endDate) { return new ScheduleDescriptor(startDate, endDate, getFrequency(), getDaycountConvention(), getShortPeriodConvention(), getDateRollConvention(), getBusinessdayCalendar(), getFixingOffsetDays(), getPaymentOffsetDays(), ...
java
public Schedule generateSchedule(LocalDate referenceDate, LocalDate startDate, LocalDate endDate) { return ScheduleGenerator.createScheduleFromConventions(referenceDate, startDate, endDate, getFrequency(), getDaycountConvention(), getShortPeriodConvention(), getDateRollConvention(), getBusinessdayCalendar(), ge...
java
@Deprecated public static ScheduleInterface createScheduleFromConventions( LocalDate referenceDate, LocalDate startDate, String frequency, double maturity, String daycountConvention, String shortPeriodConvention ) { return createScheduleFromConventions( referenceDate, startDate, fre...
java
public AnalyticProductInterface getCalibrationProductForSymbol(String symbol) { /* * The internal data structure is not optimal here (a map would make more sense here), * if the user does not require access to the products, we would allow non-unique symbols. * Hence we store both in two side by side vectors...
java
@Override public RandomVariable getValue(double evaluationTime, AssetModelMonteCarloSimulationModel model) throws CalculationException { if(exerciseMethod == ExerciseMethod.UPPER_BOUND_METHOD) { // Find optimal lambda GoldenSectionSearch optimizer = new GoldenSectionSearch(-1.0, 1.0); while(!optimizer.isDon...
java
public static HazardCurve createHazardCurveFromSurvivalProbabilities(String name, double[] times, double[] givenSurvivalProbabilities){ HazardCurve survivalProbabilities = new HazardCurve(name); for(int timeIndex=0; timeIndex<times.length;timeIndex++) { survivalProbabilities.addSurvivalProbability(times[timeInd...
java
public SwaptionDataLattice convertLattice(QuotingConvention targetConvention, double displacement, AnalyticModel model) { if(displacement != 0 && targetConvention != QuotingConvention.PAYERVOLATILITYLOGNORMAL) { throw new IllegalArgumentException("SwaptionDataLattice only supports displacement, when using Quot...
java
public SwaptionDataLattice append(SwaptionDataLattice other, AnalyticModel model) { SwaptionDataLattice combined = new SwaptionDataLattice(referenceDate, quotingConvention, displacement, forwardCurveName, discountCurveName, floatMetaSchedule, fixMetaSchedule); combined.entryMap.putAll(entryMap); if(qu...
java
public double[] getMoneynessAsOffsets() { DoubleStream moneyness = getGridNodesPerMoneyness().keySet().stream().mapToDouble(Integer::doubleValue); if(quotingConvention == QuotingConvention.PAYERVOLATILITYLOGNORMAL) { moneyness = moneyness.map(new DoubleUnaryOperator() { @Override public double apply...
java
public double[] getMaturities(double moneyness) { int[] maturitiesInMonths = getMaturities(convertMoneyness(moneyness)); double[] maturities = new double[maturitiesInMonths.length]; for(int index = 0; index < maturities.length; index++) { maturities[index] = convertMaturity(maturitiesInMonths[index]); ...
java
public int[] getTenors() { Set<Integer> setTenors = new HashSet<>(); for(int moneyness : getGridNodesPerMoneyness().keySet()) { setTenors.addAll(Arrays.asList((IntStream.of(keyMap.get(moneyness)[1]).boxed().toArray(Integer[]::new)))); } return setTenors.stream().sorted().mapToInt(Integer::intValue).to...
java
public int[] getTenors(int moneynessBP, int maturityInMonths) { try { List<Integer> ret = new ArrayList<>(); for(int tenor : getGridNodesPerMoneyness().get(moneynessBP)[1]) { if(containsEntryFor(maturityInMonths, tenor, moneynessBP)) { ret.add(tenor); } } return ret.stream().mapToIn...
java
public double[] getTenors(double moneyness, double maturity) { int maturityInMonths = (int) Math.round(maturity * 12); int[] tenorsInMonths = getTenors(convertMoneyness(moneyness), maturityInMonths); double[] tenors = new double[tenorsInMonths.length]; for(int index = 0; index < tenors.length; index++) ...
java
private int convertMoneyness(double moneyness) { if(quotingConvention == QuotingConvention.PAYERVOLATILITYLOGNORMAL) { return (int) Math.round(moneyness * 100); } else if(quotingConvention == QuotingConvention.RECEIVERPRICE) { return - (int) Math.round(moneyness * 10000); } else { return (int) Math...
java
private double convertMaturity(int maturityInMonths) { Schedule schedule = fixMetaSchedule.generateSchedule(referenceDate, maturityInMonths, 12); return schedule.getFixing(0); }
java
private double convertTenor(int maturityInMonths, int tenorInMonths) { Schedule schedule = fixMetaSchedule.generateSchedule(referenceDate, maturityInMonths, tenorInMonths); return schedule.getPayment(schedule.getNumberOfPeriods()-1); }
java
public boolean containsEntryFor(int maturityInMonths, int tenorInMonths, int moneynessBP) { return entryMap.containsKey(new DataKey(maturityInMonths, tenorInMonths, moneynessBP)); }
java
private double convertToConvention(double value, DataKey key, QuotingConvention toConvention, double toDisplacement, QuotingConvention fromConvention, double fromDisplacement, AnalyticModel model) { if(toConvention == fromConvention) { if(toConvention != QuotingConvention.PAYERVOLATILITYLOGNORMAL) { r...
java
public double getCouponPayment(int periodIndex, AnalyticModel model) { ForwardCurve forwardCurve = model.getForwardCurve(forwardCurveName); if(forwardCurve == null && forwardCurveName != null && forwardCurveName.length() > 0) { throw new IllegalArgumentException("No forward curve with name '" + forwardCurveName...
java
public double getValueWithGivenSpreadOverCurve(double evaluationTime,Curve referenceCurve, double spread, AnalyticModel model) { double value=0; for(int periodIndex=0; periodIndex<schedule.getNumberOfPeriods();periodIndex++) { double paymentDate = schedule.getPayment(periodIndex); value+= paymentDate>evaluati...
java
public double getValueWithGivenYield(double evaluationTime, double rate, AnalyticModel model) { DiscountCurve referenceCurve = DiscountCurveInterpolation.createDiscountCurveFromDiscountFactors("referenceCurve", new double[] {0.0, 1.0}, new double[] {1.0, 1.0}); return getValueWithGivenSpreadOverCurve(evaluationTim...
java
public double getSpread(double bondPrice, Curve referenceCurve, AnalyticModel model) { GoldenSectionSearch search = new GoldenSectionSearch(-2.0, 2.0); while(search.getAccuracy() > 1E-11 && !search.isDone()) { double x = search.getNextPoint(); double fx=getValueWithGivenSpreadOverCurve(0.0,referenceCurve,x,mo...
java
public double getYield(double bondPrice, AnalyticModel model) { GoldenSectionSearch search = new GoldenSectionSearch(-2.0, 2.0); while(search.getAccuracy() > 1E-11 && !search.isDone()) { double x = search.getNextPoint(); double fx=getValueWithGivenYield(0.0,x,model); double y = (bondPrice-fx)*(bondPrice-fx...
java
public double getAccruedInterest(LocalDate date, AnalyticModel model) { int periodIndex=schedule.getPeriodIndex(date); Period period=schedule.getPeriod(periodIndex); DayCountConvention dcc= schedule.getDaycountconvention(); double accruedInterest=getCouponPayment(periodIndex,model)*(dcc.getDaycountFraction(peri...
java
public double getAccruedInterest(double time, AnalyticModel model) { LocalDate date= FloatingpointDate.getDateFromFloatingPointDate(schedule.getReferenceDate(), time); return getAccruedInterest(date, model); }
java
public static double blackScholesOptionTheta( double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike) { if(optionStrike <= 0.0 || optionMaturity <= 0.0) { // The Black-Scholes model does not consider it being an option return 0.0; } els...
java
public Map<String, Object> getValues(double evaluationTime, MonteCarloSimulationInterface model) throws CalculationException { RandomVariableInterface values = getValue(evaluationTime, model); if(values == null) { return null; } // Sum up values on path double value = values.getAverage(); double error...
java
public double getValue(double x) { synchronized(interpolatingRationalFunctionsLazyInitLock) { if(interpolatingRationalFunctions == null) { doCreateRationalFunctions(); } } // Get interpolating rational function for the given point x int pointIndex = java.util.Arrays.binarySearch(points, x); if(poi...
java
public RandomVariable[] getGradient(){ // for now let us take the case for output-dimension equal to one! int numberOfVariables = getNumberOfVariablesInList(); int numberOfCalculationSteps = factory.getNumberOfEntriesInList(); RandomVariable[] omega_hat = new RandomVariable[numberOfCalculationSteps]; ...
java
public AbstractVolatilitySurfaceParametric getCloneCalibrated(final AnalyticModel calibrationModel, final Vector<AnalyticProduct> calibrationProducts, final List<Double> calibrationTargetValues, Map<String,Object> calibrationParameters, final ParameterTransformation parameterTransformation, OptimizerFactory optimizerFa...
java
public static double[] computeSeasonalAdjustments(double[] realizedCPIValues, int lastMonth, int numberOfYearsToAverage) { /* * Cacluate average log returns */ double[] averageLogReturn = new double[12]; Arrays.fill(averageLogReturn, 0.0); for(int arrayIndex = 0; arrayIndex < 12*numberOfYearsToAverage; a...
java
public ProductFactoryCascade<T> addFactoryBefore(ProductFactory<? extends T> factory) { ArrayList<ProductFactory<? extends T>> factories = new ArrayList<ProductFactory<? extends T>>(this.factories.size()+1); factories.addAll(this.factories); factories.add(0, factory); return new ProductFactoryCascade<>(factorie...
java
public RandomVariable getValues(double evaluationTime, LIBORMarketModel model) { if(evaluationTime > 0) { throw new RuntimeException("Forward start evaluation currently not supported."); } // Fetch the covariance model of the model LIBORCovarianceModel covarianceModel = model.getCovarianceModel(); // We ...
java
public RandomVariableInterface[] getFactorLoading(double time, double component, RandomVariableInterface[] realizationAtTimeIndex) { int componentIndex = liborPeriodDiscretization.getTimeIndex(component); if(componentIndex < 0) { componentIndex = -componentIndex - 2; } return getFactorLoading(time, component...
java
private RandomVariable getValueUnderlyingNumeraireRelative(LIBORModelMonteCarloSimulationModel model, Schedule legSchedule, boolean paysFloat, double swaprate, double notional) throws CalculationException { RandomVariable value = model.getRandomVariableForConstant(0.0); for(int periodIndex = legSchedule.getNumb...
java
public ConditionalExpectationEstimator getConditionalExpectationEstimator(double exerciseTime, LIBORModelMonteCarloSimulationModel model) throws CalculationException { RandomVariable[] regressionBasisFunctions = regressionBasisFunctionProvider.getBasisFunctions(exerciseTime, model); return conditionalExpectationR...
java
@Override public RandomVariable getNumeraire(double time) throws CalculationException { int timeIndex = getLiborPeriodIndex(time); if(timeIndex < 0) { // Interpolation of Numeraire: linear interpolation of the reciprocal. int lowerIndex = -timeIndex -1; int upperIndex = -timeIndex; double alpha = (tim...
java
private double u_neg_inf(double x, double tau) { return f(boundaryCondition.getValueAtLowerBoundary(model, f_t(tau), f_s(x)), x, tau); }
java
public double[] getRegressionCoefficients(RandomVariable value) { if(basisFunctions.length == 0) { return new double[] { }; } else if(basisFunctions.length == 1) { /* * Regression with one basis function is just a projection on that vector. <b,x>/<b,b> */ return new double[] { value.mult(basisFun...
java
private ProductDescriptor getSwapProductDescriptor(Element trade) { InterestRateSwapLegProductDescriptor legReceiver = null; InterestRateSwapLegProductDescriptor legPayer = null; NodeList legs = trade.getElementsByTagName("swapStream"); for(int legIndex = 0; legIndex < legs.getLength(); legIndex++) { ...
java
public static String getVersionString() { String versionString = "UNKNOWN"; Properties propeties = getProperites(); if(propeties != null) { versionString = propeties.getProperty("finmath-lib.version"); } return versionString; }
java
public static String getBuildString() { String versionString = "UNKNOWN"; Properties propeties = getProperites(); if(propeties != null) { versionString = propeties.getProperty("finmath-lib.build"); } return versionString; }
java
public static DiscountCurve createDiscountCurveFromDiscountFactors(String name, double[] times, double[] givenDiscountFactors) { DiscountCurve discountFactors = new DiscountCurve(name); for(int timeIndex=0; timeIndex<times.length;timeIndex++) { discountFactors.addDiscountFactor(times[timeIndex], givenDiscountFa...
java
public Map<Double, SingleAssetEuropeanOptionProductDescriptor> getDescriptors(LocalDate referenceDate){ int numberOfStrikes = strikes.length; HashMap<Double, SingleAssetEuropeanOptionProductDescriptor> descriptors = new HashMap<Double, SingleAssetEuropeanOptionProductDescriptor>(); LocalDate maturityDate = Floa...
java
public SingleAssetEuropeanOptionProductDescriptor getDescriptor(LocalDate referenceDate, int index) throws ArrayIndexOutOfBoundsException{ LocalDate maturityDate = FloatingpointDate.getDateFromFloatingPointDate(referenceDate, maturity); if(index >= strikes.length) { throw new ArrayIndexOutOfBoundsException("Stri...
java
public RandomVariable[] getValues(double[] times) { RandomVariable[] values = new RandomVariable[times.length]; for(int i=0; i<times.length; i++) { values[i] = getValue(null, times[i]); } return values; }
java
public static double getDaycount(LocalDate startDate, LocalDate endDate, String convention) { DayCountConventionInterface daycountConvention = getDayCountConvention(convention); return daycountConvention.getDaycount(startDate, endDate); }
java
public double getValue(ForwardCurve forwardCurve, double swaprateVolatility) { double[] swapTenor = new double[fixingDates.length+1]; System.arraycopy(fixingDates, 0, swapTenor, 0, fixingDates.length); swapTenor[swapTenor.length-1] = paymentDates[paymentDates.length-1]; TimeDiscretization fixTenor = new TimeDi...
java
@Override public double getDiscountFactor(AnalyticModelInterface model, double maturity) { // Change time scale maturity *= timeScaling; double beta1 = parameter[0]; double beta2 = parameter[1]; double beta3 = parameter[2]; double beta4 = parameter[3]; double tau1 = parameter[4]; double tau2 = para...
java
@Deprecated public static Schedule createScheduleFromConventions( LocalDate referenceDate, LocalDate startDate, String frequency, double maturity, String daycountConvention, String shortPeriodConvention, String dateRollConvention, BusinessdayCalendar businessdayCalendar, int fixingOffsetDays...
java
public Curve getRegressionCurve(){ // @TODO Add threadsafe lazy init. if(regressionCurve !=null) { return regressionCurve; } DoubleMatrix a = solveEquationSystem(); double[] curvePoints=new double[partition.getLength()]; curvePoints[0]=a.get(0); for(int i=1;i<curvePoints.length;i++) { curvePoints[i]...
java
public double getValueAsPrice(double evaluationTime, AnalyticModel model) { ForwardCurve forwardCurve = model.getForwardCurve(forwardCurveName); DiscountCurve discountCurve = model.getDiscountCurve(discountCurveName); DiscountCurve discountCurveForForward = null; if(forwardCurve == null && forwardCurveName != ...
java
public void setDerivatives(double[] parameters, double[][] derivatives) throws SolverException { // Calculate new derivatives. Note that this method is called only with // parameters = parameterCurrent, so we may use valueCurrent. Vector<Future<double[]>> valueFutures = new Vector<Future<double[]>>(parameterCurr...
java
private List<String> parseParams(String param) { Assert.hasText(param, "param must not be empty nor null"); List<String> paramsToUse = new ArrayList<>(); Matcher regexMatcher = DEPLOYMENT_PARAMS_PATTERN.matcher(param); int start = 0; while (regexMatcher.find()) { String p = removeQuoting(param.substring(st...
java
public static String load(LoadConfiguration config, String prefix) { if (config.getMode() == Mode.INSERT) { return loadInsert(config, prefix); } else if (config.getMode() == Mode.UPDATE) { return loadUpdate(config, prefix); } throw new IllegalArgumentException("Unsupported mode " + config.getMode()); }
java
public static Map<String, String> parseProperties(String s) { Map<String, String> properties = new HashMap<String, String>(); if (!StringUtils.isEmpty(s)) { Matcher matcher = PROPERTIES_PATTERN.matcher(s); int start = 0; while (matcher.find()) { addKeyValuePairAsProperty(s.substring(start, matcher.star...
java
public synchronized HttpServer<Buffer, Buffer> start() throws Exception { if (server == null) { server = createProtocolListener(); } return server; }
java
public void setSegmentReject(String reject) { if (!StringUtils.hasText(reject)) { return; } Integer parsedLimit = null; try { parsedLimit = Integer.parseInt(reject); segmentRejectType = SegmentRejectType.ROWS; } catch (NumberFormatException e) { } if (parsedLimit == null && reject.contains("%")) ...
java
public void setReadTimeout(int millis) { // Hack to get round Spring's dynamic loading of http client stuff ClientHttpRequestFactory f = getRequestFactory(); if (f instanceof SimpleClientHttpRequestFactory) { ((SimpleClientHttpRequestFactory) f).setReadTimeout(millis); } else { ((HttpComponentsClientHtt...
java
public void setConnectTimeout(int millis) { ClientHttpRequestFactory f = getRequestFactory(); if (f instanceof SimpleClientHttpRequestFactory) { ((SimpleClientHttpRequestFactory) f).setConnectTimeout(millis); } else { ((HttpComponentsClientHttpRequestFactory) f).setConnectTimeout(millis); } }
java
private void handleTextWebSocketFrameInternal(TextWebSocketFrame frame, ChannelHandlerContext ctx) { if (logger.isTraceEnabled()) { logger.trace(String.format("%s received %s", ctx.channel(), frame.text())); } addTraceForFrame(frame, "text"); ctx.channel().write(new TextWebSocketFrame("Echo: " + frame.text(...
java
private void addTraceForFrame(WebSocketFrame frame, String type) { Map<String, Object> trace = new LinkedHashMap<>(); trace.put("type", type); trace.put("direction", "in"); if (frame instanceof TextWebSocketFrame) { trace.put("payload", ((TextWebSocketFrame) frame).text()); } if (traceEnabled) { webs...
java
@SuppressWarnings({ "rawtypes", "unchecked" }) private IntegrationFlowBuilder getFlowBuilder() { IntegrationFlowBuilder flowBuilder; URLName urlName = this.properties.getUrl(); if (this.properties.isIdleImap()) { flowBuilder = getIdleImapFlow(urlName); } else { MailInboundChannelAdapterSpec adapterS...
java
private IntegrationFlowBuilder getIdleImapFlow(URLName urlName) { return IntegrationFlows.from(Mail.imapIdleAdapter(urlName.toString()) .shouldDeleteMessages(this.properties.isDelete()) .javaMailProperties(getJavaMailProperties(urlName)) .selectorExpression(this.properties.getExpression()) .shouldMark...
java
@SuppressWarnings("rawtypes") private MailInboundChannelAdapterSpec getImapFlowBuilder(URLName urlName) { return Mail.imapInboundAdapter(urlName.toString()) .shouldMarkMessagesAsRead(this.properties.isMarkAsRead()); }
java
protected View postDeclineView() { return new TopLevelWindowRedirect() { @Override protected String getRedirectUrl(Map<String, ?> model) { return postDeclineUrl; } }; }
java
@SuppressWarnings("unchecked") public Map<String, ?> decodeSignedRequest(String signedRequest) throws SignedRequestException { return decodeSignedRequest(signedRequest, Map.class); }
java
public <T> T decodeSignedRequest(String signedRequest, Class<T> type) throws SignedRequestException { String[] split = signedRequest.split("\\."); String encodedSignature = split[0]; String payload = split[1]; String decoded = base64DecodeToString(payload); byte[] signature = base64DecodeToBytes(encodedSi...
java
public String getString(String fieldName) { return hasValue(fieldName) ? String.valueOf(resultMap.get(fieldName)) : null; }
java
public Integer getInteger(String fieldName) { try { return hasValue(fieldName) ? Integer.valueOf(String.valueOf(resultMap.get(fieldName))) : null; } catch (NumberFormatException e) { throw new FqlException("Field '" + fieldName +"' is not a number.", e); } }
java
public Long getLong(String fieldName) { try { return hasValue(fieldName) ? Long.valueOf(String.valueOf(resultMap.get(fieldName))) : null; } catch (NumberFormatException e) { throw new FqlException("Field '" + fieldName +"' is not a number.", e); } }
java
public Float getFloat(String fieldName) { try { return hasValue(fieldName) ? Float.valueOf(String.valueOf(resultMap.get(fieldName))) : null; } catch (NumberFormatException e) { throw new FqlException("Field '" + fieldName +"' is not a number.", e); } }
java
public Boolean getBoolean(String fieldName) { return hasValue(fieldName) ? Boolean.valueOf(String.valueOf(resultMap.get(fieldName))) : null; }
java
public Date getTime(String fieldName) { try { if (hasValue(fieldName)) { return new Date(Long.valueOf(String.valueOf(resultMap.get(fieldName))) * 1000); } else { return null; } } catch (NumberFormatException e) { throw new FqlException("Field '" + fieldName +"' is not a time.", e); } }
java