Package org.jbpm.pvm.internal.cal

Examples of org.jbpm.pvm.internal.cal.BusinessCalendarImpl


  public BusinessCalendarBinding() {
    super("business-calendar");
  }

  public Object parse(Element element, Parse parse, Parser parser) {
    BusinessCalendarImpl businessCalendarImpl = new BusinessCalendarImpl();
   
    TimeZone timeZone = null;
    if (element.hasAttribute("timezone")) {
      timeZone = TimeZone.getTimeZone(element.getAttribute("timezone"));
    } else {
      timeZone = TimeZone.getDefault();
    }
    businessCalendarImpl.setTimeZone(timeZone);
   
    String hourFormatText = "HH:mm";
    if (element.hasAttribute("hour-format")) {
      hourFormatText = element.getAttribute("hour-format");
    }
    DateFormat hourFormat = new SimpleDateFormat(hourFormatText);

    Day[] days = new Day[8];
    days[Calendar.SUNDAY] = parseDay(element, "sunday", hourFormat, businessCalendarImpl, parse);
    days[Calendar.MONDAY] = parseDay(element, "monday", hourFormat, businessCalendarImpl, parse);
    days[Calendar.TUESDAY] = parseDay(element, "tuesday", hourFormat, businessCalendarImpl, parse);
    days[Calendar.WEDNESDAY] = parseDay(element, "wednesday", hourFormat, businessCalendarImpl, parse);
    days[Calendar.THURSDAY] = parseDay(element, "thursday", hourFormat, businessCalendarImpl, parse);
    days[Calendar.FRIDAY] = parseDay(element, "friday", hourFormat, businessCalendarImpl, parse);
    days[Calendar.SATURDAY] = parseDay(element, "saturday", hourFormat, businessCalendarImpl, parse);
    businessCalendarImpl.setDays(days);

    String dayFormatText = "dd/MM/yyyy";
    if (element.hasAttribute("day-format")) {
      dayFormatText = element.getAttribute("day-format");
    }
    DateFormat dayFormat = new SimpleDateFormat(dayFormatText);

    Holiday[] holidays = null;
    List<Element> holidayElements = XmlUtil.elements(element, "holiday");
    if (!holidayElements.isEmpty()) {
      holidays = new Holiday[holidayElements.size()];
      for (int i=0; i<holidayElements.size(); i++) {
        holidays[i] = parseHoliday(holidayElements.get(i), dayFormat, businessCalendarImpl, parse);
      }
    }
    businessCalendarImpl.setHolidays(holidays);
   
    ProvidedObjectDescriptor descriptor = new ProvidedObjectDescriptor(businessCalendarImpl, true);
    return descriptor;
  }
View Full Code Here

TOP

Related Classes of org.jbpm.pvm.internal.cal.BusinessCalendarImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.