class SchedulerAdapter {

    public XmlBuilder triggerToXmlBuilder(Trigger trigger) {
        XmlBuilder xbRoot = new XmlBuilder("triggerDetail");

        TriggerKey triggerKey = trigger.getKey();
        xbRoot.addAttribute("fullName", triggerKey.getGroup() + "." + triggerKey.getName());
        xbRoot.addAttribute("triggerName", triggerKey.getName());
        xbRoot.addAttribute("triggerGroup", triggerKey.getGroup());
        String cn = trigger.getCalendarName();

        xbRoot.addAttribute("calendarName", (cn == null ? "none" : cn));

        xbRoot.addAttribute("endTime", convertDate(trigger.getEndTime()));
        xbRoot.addAttribute("finalFireTime", convertDate(trigger.getFinalFireTime()));
        xbRoot.addAttribute("previousFireTime", convertDate(trigger.getPreviousFireTime()));
        xbRoot.addAttribute("nextFireTime", convertDate(trigger.getNextFireTime()));
        xbRoot.addAttribute("startTime", convertDate(trigger.getStartTime()));

        xbRoot.addAttribute("misfireInstruction", Integer.toString(trigger.getMisfireInstruction()));
        if (trigger instanceof CronTrigger) {
            xbRoot.addAttribute("triggerType", "cron");
            xbRoot.addAttribute("cronExpression", ((CronTrigger)trigger).getCronExpression());
        } else if (trigger instanceof SimpleTrigger) {
            xbRoot.addAttribute("triggerType", "simple");
            xbRoot.addAttribute("repeatInterval", ((SimpleTrigger)trigger).getRepeatInterval());
        } else {
            xbRoot.addAttribute("triggerType", "unknown");
        }

        return xbRoot;
    }

}