Example usage for org.joda.time Interval getEnd

List of usage examples for org.joda.time Interval getEnd

Introduction

In this page you can find the example usage for org.joda.time Interval getEnd.

Prototype

public DateTime getEnd() 

Source Link

Document

Gets the end of this time interval, which is exclusive, as a DateTime.

Usage

From source file:org.jasig.portlet.calendar.adapter.CoursesCalendarAdapter.java

License:Apache License

public CalendarEventSet getEvents(CalendarConfiguration calendarConfiguration, Interval interval,
        PortletRequest request) throws CalendarException {

    String intervalCacheKey = cacheKeyGenerator.getKey(calendarConfiguration, interval, request,
            cacheKeyPrefix.concat(".") + interval.toString());

    // Get the calendar event set for the set of terms from cache
    CalendarEventSet eventSet;/* w w  w. ja v  a2  s .c  o  m*/
    Element cachedElement = this.cache.get(intervalCacheKey);
    if (cachedElement != null) {
        if (log.isDebugEnabled()) {
            log.debug("Retrieving calendar event set from cache, termCacheKey:" + intervalCacheKey);
        }
        return (CalendarEventSet) cachedElement.getValue();
    }

    // Get the terms that overlap the requested interval.  Current implementation
    // requires the terms to have the start date and end date present in the
    // term.
    TermList allTerms = courseDao.getTermList(request);
    Set<VEvent> calendarEventSet = new HashSet<VEvent>();
    for (Term term : allTerms.getTerms()) {

        // todo determine if term ending Fri 10/31 (which means THROUGH 10/31 to 23:59:59)
        // and interval starting Fri 10/31 (meaning 10/31 12:00am) works as expected.

        // Determine if the interval overlaps any terms.
        if (interval.getStart().isBefore(term.getEnd().getTimeInMillis())
                && interval.getEnd().isAfter(term.getStart().getTimeInMillis())) {

            Calendar calendar = retrieveCourseCalendar(request, interval, calendarConfiguration, term);
            Set<VEvent> events = contentProcessor.getEvents(interval, calendar);
            log.debug("contentProcessor found " + events.size() + " events");
            calendarEventSet.addAll(events);
        }
    }

    // Save the calendar event set to the cache.
    eventSet = new CalendarEventSet(intervalCacheKey, calendarEventSet);
    cachedElement = new Element(intervalCacheKey, eventSet);
    if (log.isDebugEnabled()) {
        log.debug("Storing calendar event set to cache, key:" + intervalCacheKey);
    }
    cache.put(cachedElement);

    return eventSet;
}

From source file:org.jasig.portlet.calendar.adapter.ExchangeCalendarAdapter.java

License:Apache License

protected GetUserAvailabilityRequest getAvailabilityRequest(Interval interval, String emailAddress)
        throws DatatypeConfigurationException {

    // construct the SOAP request object to use
    GetUserAvailabilityRequest soapRequest = new GetUserAvailabilityRequest();

    // create an array of mailbox data representing the current user
    ArrayOfMailboxData mailboxes = new ArrayOfMailboxData();
    MailboxData mailbox = new MailboxData();
    Mailbox address = new Mailbox();
    address.setAddress(emailAddress);//  w ww . j  a v  a  2  s  .  c om
    address.setName("");
    mailbox.setAttendeeType(MeetingAttendeeType.REQUIRED);
    mailbox.setExcludeConflicts(false);
    mailbox.setEmail(address);
    mailboxes.getMailboxDatas().add(mailbox);
    soapRequest.setMailboxDataArray(mailboxes);

    // create a FreeBusyViewOptions representing the specified period
    FreeBusyViewOptions view = new FreeBusyViewOptions();
    view.setMergedFreeBusyIntervalInMinutes(60);
    view.getRequestedView().add("DetailedMerged");

    Duration dur = new Duration();

    XMLGregorianCalendar start = getXmlDate(interval.getStart());
    XMLGregorianCalendar end = getXmlDate(interval.getEnd());
    dur.setEndTime(end);
    dur.setStartTime(start);

    view.setTimeWindow(dur);
    soapRequest.setFreeBusyViewOptions(view);

    // set the bias to the start time's timezone offset (in minutes 
    // rather than milliseconds)
    TimeZone tz = new TimeZone();
    java.util.TimeZone tZone = java.util.TimeZone.getTimeZone(UTC);
    tz.setBias(tZone.getRawOffset() / 1000 / 60);

    // TODO: time zone standard vs. daylight info is temporarily hard-coded
    SerializableTimeZoneTime standard = new SerializableTimeZoneTime();
    standard.setBias(0);
    standard.setDayOfWeek(DayOfWeekType.SUNDAY);
    standard.setDayOrder((short) 1);
    standard.setMonth((short) 11);
    standard.setTime("02:00:00");
    SerializableTimeZoneTime daylight = new SerializableTimeZoneTime();
    daylight.setBias(0);
    daylight.setDayOfWeek(DayOfWeekType.SUNDAY);
    daylight.setDayOrder((short) 1);
    daylight.setMonth((short) 3);
    daylight.setTime("02:00:00");
    tz.setStandardTime(standard);
    tz.setDaylightTime(daylight);

    soapRequest.setTimeZone(tz);

    return soapRequest;
}

From source file:org.jasig.portlet.calendar.mvc.CalendarDisplayEvent.java

License:Apache License

/**
 * Constructs an object from specified data.
 *
 * @param event "Raw" Event object/*  ww  w .jav a2  s .c o  m*/
 * @param eventInterval Interval portion of the event that applies to this specific day
 * @param theSpecificDay Interval of the specific day in question
 * @param df date formatter to represent date displays
 * @param tf time formatter to represent time displays
 */
public CalendarDisplayEvent(VEvent event, Interval eventInterval, Interval theSpecificDay, DateTimeFormatter df,
        DateTimeFormatter tf) {
    assert theSpecificDay.abuts(eventInterval)
            || theSpecificDay.overlaps(eventInterval) : "Event interval is not in the specified day!";

    this.summary = event.getSummary() != null ? event.getSummary().getValue() : null;
    this.description = event.getDescription() != null ? event.getDescription().getValue() : null;
    this.location = event.getLocation() != null ? event.getLocation().getValue() : null;

    boolean multi = false;
    if (eventInterval.getStart().isBefore(theSpecificDay.getStart())) {
        dayStart = theSpecificDay.getStart();
        multi = true;
    } else {
        dayStart = eventInterval.getStart();
    }

    if (event.getEndDate() == null) {
        dayEnd = dayStart;
    } else if (eventInterval.getEnd().isAfter(theSpecificDay.getEnd())) {
        dayEnd = theSpecificDay.getEnd();
        multi = true;
    } else {
        dayEnd = eventInterval.getEnd();
    }
    this.isMultiDay = multi;

    this.dateStartTime = tf.print(dayStart);
    this.startTime = tf.print(eventInterval.getStart());
    this.startDate = df.print(eventInterval.getStart());

    if (event.getEndDate() != null) {
        this.dateEndTime = tf.print(dayEnd);
        this.endTime = tf.print(eventInterval.getEnd());
        this.endDate = df.print(eventInterval.getEnd());
    } else {
        this.dateEndTime = null;
        this.endTime = null;
        this.endDate = null;
    }

    Interval dayEventInterval = new Interval(dayStart, dayEnd);
    this.isAllDay = dayEventInterval.equals(theSpecificDay);

}

From source file:org.jasig.portlet.calendar.mvc.controller.CalendarController.java

License:Apache License

@RequestMapping
public ModelAndView getCalendar(@RequestParam(required = false, value = "interval") String intervalString,
        RenderRequest request) {/*from  w  w w .j a  v a 2  s.  co  m*/

    PortletSession session = request.getPortletSession(true);

    PortletPreferences prefs = request.getPreferences();

    Map<String, Object> model = new HashMap<String, Object>();

    // get the list of hidden calendars
    @SuppressWarnings("unchecked")
    HashMap<Long, String> hiddenCalendars = (HashMap<Long, String>) session.getAttribute("hiddenCalendars");

    // indicate if the current user is a guest (unauthenticated) user
    model.put("guest", request.getRemoteUser() == null);

    /**
     * Add and remove calendars from the hidden list.  Hidden calendars
     * will be fetched, but rendered invisible in the view.
     */

    // check the request parameters to see if we need to add any
    // calendars to the list of hidden calendars
    String hideCalendar = request.getParameter("hideCalendar");
    if (hideCalendar != null) {
        hiddenCalendars.put(Long.valueOf(hideCalendar), "true");
        session.setAttribute("hiddenCalendars", hiddenCalendars);
    }

    // check the request parameters to see if we need to remove
    // any calendars from the list of hidden calendars
    String showCalendar = request.getParameter("showCalendar");
    if (showCalendar != null) {
        hiddenCalendars.remove(Long.valueOf(showCalendar));
        session.setAttribute("hiddenCalendars", hiddenCalendars);
    }

    // See if we're configured to show or hide the jQueryUI DatePicker.
    // By default, we assume we are to show the DatePicker because that's
    // the classic behavior.
    String showDatePicker = prefs.getValue("showDatePicker", "true");
    model.put("showDatePicker", showDatePicker);

    /**
     * Find our desired starting and ending dates.
     */

    Interval interval = null;

    if (!StringUtils.isEmpty(intervalString)) {
        interval = Interval.parse(intervalString);
        model.put("startDate", new DateMidnight(interval.getStart()).toDate());
        model.put("days", interval.toDuration().getStandardDays());
        model.put("endDate", new DateMidnight(interval.getEnd()));
    } else {
        //StartDate can only be changed via an AJAX request
        DateMidnight startDate = (DateMidnight) session.getAttribute("startDate");
        log.debug("startDate from session is: " + startDate);
        model.put("startDate", startDate.toDate());

        // find how many days into the future we should display events
        int days = (Integer) session.getAttribute("days");
        model.put("days", days);

        // set the end date based on our desired time period
        DateMidnight endDate = startDate.plusDays(days);
        model.put("endDate", endDate.toDate());

        interval = new Interval(startDate, endDate);
    }

    // define "today" and "tomorrow" so we can display these specially in the
    // user interface
    // get the user's configured time zone
    String timezone = (String) session.getAttribute("timezone");
    DateMidnight today = new DateMidnight(DateTimeZone.forID(timezone));
    model.put("today", today.toDate());
    model.put("tomorrow", today.plusDays(1).toDate());

    /**
     * retrieve the calendars defined for this portlet instance
     */

    CalendarSet<?> set = calendarSetDao.getCalendarSet(request);
    List<CalendarConfiguration> calendars = new ArrayList<CalendarConfiguration>();
    calendars.addAll(set.getConfigurations());
    Collections.sort(calendars, new CalendarConfigurationByNameComparator());
    model.put("calendars", calendars);

    Map<Long, Integer> colors = new HashMap<Long, Integer>();
    Map<Long, String> links = new HashMap<Long, String>();
    int index = 0;
    for (CalendarConfiguration callisting : calendars) {

        // don't bother to fetch hidden calendars
        if (hiddenCalendars.get(callisting.getId()) == null) {

            try {

                // get an instance of the adapter for this calendar
                ICalendarAdapter adapter = (ICalendarAdapter) applicationContext
                        .getBean(callisting.getCalendarDefinition().getClassName());

                //get hyperlink to calendar
                String link = adapter.getLink(callisting, interval, request);
                if (link != null) {
                    links.put(callisting.getId(), link);
                }

            } catch (NoSuchBeanDefinitionException ex) {
                log.error("Calendar class instance could not be found: " + ex.getMessage());
            } catch (CalendarLinkException linkEx) {
                // Not an error. Ignore
            } catch (Exception ex) {
                log.error(ex);
            }
        }

        // add this calendar's id to the color map
        colors.put(callisting.getId(), index);
        index++;

    }

    model.put("timezone", session.getAttribute("timezone"));
    model.put("colors", colors);
    model.put("links", links);
    model.put("hiddenCalendars", hiddenCalendars);

    /*
     * Check if we need to disable either the preferences and/or administration links
     */

    Boolean disablePrefs = Boolean.valueOf(prefs.getValue(PREFERENCE_DISABLE_PREFERENCES, "false"));
    model.put(PREFERENCE_DISABLE_PREFERENCES, disablePrefs);
    Boolean disableAdmin = Boolean.valueOf(prefs.getValue(PREFERENCE_DISABLE_ADMINISTRATION, "false"));
    model.put(PREFERENCE_DISABLE_ADMINISTRATION, disableAdmin);

    return new ModelAndView(viewSelector.getCalendarViewName(request), "model", model);
}

From source file:org.jasig.portlet.calendar.url.CalendarkeyUrlCreatorImpl.java

License:Apache License

public String constructUrl(CalendarConfiguration calendarListing, Interval interval, PortletRequest request) {
    String baseUrl = calendarListing.getCalendarDefinition().getParameters().get("baseUrl");
    StringBuilder finalUrl = new StringBuilder();
    finalUrl.append(baseUrl);//from ww  w .ja  va2  s  .  com
    if (!baseUrl.endsWith("/")) {
        finalUrl.append("/");
    }
    String username = request.getRemoteUser();
    if (null == username || "".equals(username)) {
        throw new CalendarException("user not logged in");
    }
    finalUrl.append(username);
    finalUrl.append("/");

    finalUrl.append(formatter.print(interval.getStart()));
    finalUrl.append("/");
    finalUrl.append(formatter.print(interval.getEnd()));
    return finalUrl.toString();
}

From source file:org.jasig.portlet.calendar.url.StringTemplateUrlCreatorImpl.java

License:Apache License

/**
 *
 * @param configuration// w  w w . ja  v a 2s.c  o m
 * @param interval
 * @param username
 * @return
 */
public String constructUrlInternal(CalendarConfiguration configuration, Interval interval, String username) {

    // get the template url from the calendar configuration
    String url = (String) configuration.getCalendarDefinition().getParameters().get("url");

    try {

        // replace the username in the url
        url = url.replace(USERNAME_TOKEN, URLEncoder.encode(username, URL_ENCODING));

        // replace the start and end dates in the url, using the configured date format
        if (url.contains(START_DATE_TOKEN) || url.contains(END_DATE_TOKEN)) {

            // get the configured date format from the calendar configuration, or if none is configured, use the
            // default date format
            String urlDateFormat = (String) configuration.getCalendarDefinition().getParameters()
                    .get("urlDateFormat");
            if (urlDateFormat == null) {
                urlDateFormat = DEFAULT_DATE_FORMAT;
            }

            // replace the start date in the url
            String startString = URLEncoder.encode(getDateFormatter(urlDateFormat).print(interval.getStart()),
                    URL_ENCODING);
            url = url.replace(START_DATE_TOKEN, startString);

            // replace the end date in the url
            String endString = URLEncoder.encode(getDateFormatter(urlDateFormat).print(interval.getEnd()),
                    URL_ENCODING);
            url = url.replace(END_DATE_TOKEN, endString);

        }

    } catch (UnsupportedEncodingException e) {
        log.error(e);
    }

    return url;
}

From source file:org.jevis.commons.dataprocessing.function.AggrigatorFunction.java

License:Open Source License

@Override
public List<JEVisSample> getResult(Process mainTask) {
    List<JEVisSample> result = new ArrayList<>();

    List<List<JEVisSample>> allSamples = new ArrayList<>();
    for (Process task : mainTask.getSubProcesses()) {
        allSamples.add(task.getResult());
        System.out.println("Add input result: " + allSamples.size());
    }/*w  ww  .j a v a2  s.c o m*/

    List<DateTime> allTimestamps = getAllTimestamps(allSamples);
    if (allTimestamps.isEmpty()) {
        return result;
    }
    List<Interval> intervals = ProcessOptions.getIntervals(mainTask, allTimestamps.get(0),
            allTimestamps.get(allTimestamps.size() - 1));

    System.out.println("intervals: " + intervals.size());

    int lastPos = 0;
    for (Interval interval : intervals) {
        List<JEVisSample> samplesInPeriod = new ArrayList<>();
        System.out.println("interval: " + interval);

        for (List<JEVisSample> samples : allSamples) {
            for (int i = lastPos; i < samples.size(); i++) {
                try {
                    if (interval.contains(samples.get(i).getTimestamp())) {
                        //                        System.out.println("add sample: " + samples.get(i));
                        samplesInPeriod.add(samples.get(i));
                    } else if (samples.get(i).getTimestamp().isAfter(interval.getEnd())) {
                        lastPos = i;
                        break;
                    }
                } catch (JEVisException ex) {
                    System.out.println("JEVisExeption while going trou sample: " + ex.getMessage());
                }
            }

            double sum = 0;
            for (JEVisSample sample : samplesInPeriod) {
                try {
                    sum += sample.getValueAsDouble();
                } catch (JEVisException ex) {
                    Logger.getLogger(AggrigatorFunction.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

            JEVisSample resultSum = new VirtuelSample(interval.getStart(), sum, mainTask.getJEVisDataSource(),
                    new VirtualAttribute(null));
            result.add(resultSum);
            try {
                System.out.println(
                        "resultSum: " + resultSum.getTimestamp() + "  " + resultSum.getValueAsDouble());
            } catch (JEVisException ex) {
                Logger.getLogger(AggrigatorFunction.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }

    return result;
}

From source file:org.jevis.commons.dataprocessing.function.ImpulsFunction.java

License:Open Source License

@Override
public List<JEVisSample> getResult(Process mainTask) {
    List<JEVisSample> result = new ArrayList<>();

    if (mainTask.getSubProcesses().size() > 1) {
        System.out.println("Impuscleaner cannot work with more than one imput, using first only.");
    } else if (mainTask.getSubProcesses().size() < 1) {
        System.out.println("Impuscleaner, no input nothing to do");
    }//  www .ja  va  2s .  c  om

    List<JEVisSample> samples = mainTask.getSubProcesses().get(0).getResult();

    DateTime firstTS = DateTime.now();
    DateTime lastTS = DateTime.now();
    try {
        firstTS = samples.get(0).getTimestamp();
        lastTS = samples.get(samples.size()).getTimestamp();
    } catch (JEVisException ex) {
        Logger.getLogger(ImpulsFunction.class.getName()).log(Level.SEVERE, null, ex);
    }

    List<Interval> intervals = ProcessOptions.getIntervals(mainTask, firstTS, lastTS);

    int lastPos = 0;
    for (Interval interval : intervals) {
        List<JEVisSample> samplesInPeriod = new ArrayList<>();

        for (int i = lastPos; i < samples.size(); i++) {
            try {
                if (interval.contains(samples.get(i).getTimestamp())) {
                    //                        System.out.println("add sample: " + samples.get(i));
                    samplesInPeriod.add(samples.get(i));
                } else if (samples.get(i).getTimestamp().isAfter(interval.getEnd())) {
                    lastPos = i;
                    break;
                }
            } catch (JEVisException ex) {
                System.out.println("JEVisExeption while going trou sample: " + ex.getMessage());
            }
        }

        //TODO: thi sis an dummy for
        JEVisSample bestmatch = null;
        for (JEVisSample sample : samplesInPeriod) {

            long bestDiff = 99999999999999999l;
            try {
                long middelMili = ((interval.getEndMillis() - interval.getStartMillis()) / 2)
                        + interval.getStartMillis();
                long diff = Math.abs(sample.getTimestamp().getMillis() - middelMili);
                //                    System.out.println("Diff for: " + sample.getTimestamp() + "      -> " + diff);

                if (bestmatch != null) {
                    if (bestDiff < diff) {
                        bestDiff = diff;
                        bestmatch = sample;
                    }
                } else {
                    bestmatch = sample;
                    bestDiff = diff;
                }

            } catch (JEVisException ex) {
                System.out.println("JEVisExeption while going trou sample2: " + ex.getMessage());
            }
        }
        if (bestmatch != null) {
            System.out.println("Best match: " + bestmatch);
            result.add(bestmatch);
        }
    }

    return result;
}

From source file:org.jevis.commons.dataprocessing.function.ImpulsFunction.java

License:Open Source License

public List<JEVisSample> getResult(ProcessOptions options, List<List<JEVisSample>> allSamples) {
    List<JEVisSample> result = new ArrayList<>();
    for (List<JEVisSample> samples : allSamples) {

        try {/*from   w w w .  j av  a2 s  .  c o  m*/
            _durations = ProcessOptions.buildIntervals(Period.minutes(15), _offset,
                    samples.get(0).getTimestamp(), samples.get(samples.size() - 1).getTimestamp());
        } catch (JEVisException ex) {
            Logger.getLogger(ImpulsFunction.class.getName()).log(Level.SEVERE, null, ex);
        }

        //Samples list is sorted by default
        int lastPos = 0;
        for (Interval interval : _durations) {
            //            System.out.println("Interval: " + interval);
            List<JEVisSample> samplesInPeriod = new ArrayList<>();

            for (int i = lastPos; i < samples.size(); i++) {
                try {
                    if (interval.contains(samples.get(i).getTimestamp())) {
                        //                        System.out.println("add sample: " + samples.get(i));
                        samplesInPeriod.add(samples.get(i));
                    } else if (samples.get(i).getTimestamp().isAfter(interval.getEnd())) {
                        lastPos = i;
                        break;
                    }
                } catch (JEVisException ex) {
                    System.out.println("JEVisExeption while going trou sample: " + ex.getMessage());
                }
            }

            //TODO: thi sis an dummy for
            JEVisSample bestmatch = null;
            for (JEVisSample sample : samplesInPeriod) {

                long bestDiff = 99999999999999999l;
                try {
                    long middelMili = ((interval.getEndMillis() - interval.getStartMillis()) / 2)
                            + interval.getStartMillis();
                    long diff = Math.abs(sample.getTimestamp().getMillis() - middelMili);
                    //                    System.out.println("Diff for: " + sample.getTimestamp() + "      -> " + diff);

                    if (bestmatch != null) {
                        if (bestDiff < diff) {
                            bestDiff = diff;
                            bestmatch = sample;
                        }
                    } else {
                        bestmatch = sample;
                        bestDiff = diff;
                    }

                } catch (JEVisException ex) {
                    System.out.println("JEVisExeption while going trou sample2: " + ex.getMessage());
                }
            }
            if (bestmatch != null) {
                System.out.println("Best match: " + bestmatch);
                result.add(bestmatch);
            }

        }

    }
    return result;
}

From source file:org.jevis.commons.dataprocessing.processor.AggrigatorProcessor.java

License:Open Source License

@Override
public List<JEVisSample> getResult(Task mainTask) {
    List<JEVisSample> result = new ArrayList<>();

    ////from w  ww  .j a  v  a2 s  . com
    //       
    //        List<Interval> durations = ProcessController.buildIntervals(Period.days(1), ProcessController.getOffset(), samples.get(0).getTimestamp(), samples.get(samples.size() - 1).getTimestamp());
    List<Map<DateTime, JEVisSample>> sampleMaps = new ArrayList<>();
    List<List<JEVisSample>> allSamples = new ArrayList<>();
    for (Task task : mainTask.getSubTasks()) {
        allSamples.add(task.getResult());
        System.out.println("Add input result: " + allSamples.size());
    }

    List<DateTime> allTimestamps = getAllTimestamps(allSamples);
    List<Interval> intervals = Options.getIntervals(mainTask, allTimestamps.get(0),
            allTimestamps.get(allTimestamps.size() - 1));

    System.out.println("intervals: " + intervals.size());

    int lastPos = 0;
    for (Interval interval : intervals) {
        List<JEVisSample> samplesInPeriod = new ArrayList<>();
        System.out.println("interval: " + interval);

        for (List<JEVisSample> samples : allSamples) {
            for (int i = lastPos; i < samples.size(); i++) {
                try {
                    if (interval.contains(samples.get(i).getTimestamp())) {
                        //                        System.out.println("add sample: " + samples.get(i));
                        samplesInPeriod.add(samples.get(i));
                    } else if (samples.get(i).getTimestamp().isAfter(interval.getEnd())) {
                        lastPos = i;
                        break;
                    }
                } catch (JEVisException ex) {
                    System.out.println("JEVisExeption while going trou sample: " + ex.getMessage());
                }
            }

            double sum = 0;
            for (JEVisSample sample : samplesInPeriod) {
                try {
                    sum += sample.getValueAsDouble();
                } catch (JEVisException ex) {
                    Logger.getLogger(AggrigatorProcessor.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

            JEVisSample resultSum = new VirtuelSample(interval.getStart(), sum, mainTask.getJEVisDataSource(),
                    new VirtualAttribute(null));
            result.add(resultSum);
            try {
                System.out.println(
                        "resultSum: " + resultSum.getTimestamp() + "  " + resultSum.getValueAsDouble());
            } catch (JEVisException ex) {
                Logger.getLogger(AggrigatorProcessor.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }

    return result;
}