Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * JBoss, Home of Professional Open Source.
  * Copyright 2009, Red Hat Middleware LLC, and individual contributors
  * as indicated by the @author tags. See the copyright.txt file in the
  * distribution for a full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.as.ejb3.timerservice.schedule.value;
import static org.jboss.as.ejb3.EjbMessages.MESSAGES;
Represents a value for a javax.ejb.ScheduleExpression which is expressed as an list type. An ListValue comprises of values separated by a ",".

Each value in the ListValue must be an individual attribute value or a range. List items cannot themselves be lists, wild-cards, or increments. Duplicate values are allowed, but are ignored.

Author(s):
Jaikiran Pai
Version:
$Revision: $
See also:
ScheduleExpressionType.LIST
public class ListValue implements ScheduleValue {

    
Separator used for parsing a java.lang.String which represents a ListValue
    public static final String LIST_SEPARATOR = ",";

    
The individual values in a ListValue

Each value in this set may be a java.lang.String representing a SingleValue or a RangeValue

    private final List<Stringvalues = new ArrayList<String>();

    
Creates a ListValue by parsing the passed value.

Parameters:
list The value to be parsed
Throws:
java.lang.IllegalArgumentException If the passed value cannot be represented as an ListValue
    public ListValue(String list) {
        if (list == null || list.isEmpty()) {
            throw .invalidListExpression(list);
        }
        StringTokenizer tokenizer = new StringTokenizer(list);
        while (tokenizer.hasMoreTokens()) {
            String value = tokenizer.nextToken().trim();
            this..add(value);
        }
        // a list MUST minimally contain 2 elements
        // Ex: "," "1," ", 2" are all invalid
        if (this..size() < 2) {
            throw .invalidListExpression(list);
        }
    }

    
Returns the values that make up the ListValue.

Each value in this set may be a java.lang.String representing a SingleValue or a RangeValue

Returns:
    public List<StringgetValues() {
        return this.;
    }
New to GrepCode? Check out our FAQ X