All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mtvnet.boxspring.scheduling.quartz.CronTriggerParser Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2009, MTV Networks. All rights reserved.
 *
 * This program is licensed to you under the Apache License Version 2.0,
 * and you may not use this file except in compliance with the Apache License Version 2.0.
 * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the Apache License Version 2.0 is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
 */
package com.mtvnet.boxspring.scheduling.quartz;

import java.text.ParseException;

import org.quartz.Trigger;
import org.springframework.beans.factory.InitializingBean;

import com.mtvnet.boxspring.util.SubstringUtils;

/**
 * Creates a CronTriggerBean based on a supplied String which must conform to the syntax
 * specifie in class org.quartz.CronExpression, but prefixed by the word "cron".
 *
 * @see org.quartz.CronExpression
*/
class CronTriggerParser extends PropertyValueParser {
    /**
     * The property value text.
     */
    private String text;

    /**
     * The cron trigger bean.
     */
    private CronTriggerBean bean = new CronTriggerBean();

    public CronTriggerParser(String text) throws ParseException {
        this.text = text;
    }

    public static boolean isCronTrigger(String text) {
        return text.startsWith("cron");
    }

    protected void parse() throws ParseException {
        bean.setCronExpression(SubstringUtils.substringAfter(text, "cron").trim());
    }

    protected Trigger asTrigger() {
        return bean;
    }

    protected InitializingBean asInitializingBean() {
        return bean;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy