001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.util.parse.metapattern.parsers; 018 019import org.apache.wicket.util.parse.metapattern.MetaPattern; 020 021/** 022 * Parses out strings separated by commas. 023 * <p> 024 * Notes: 025 * <p> 026 * <ul> 027 * <li>It'll not trim the elements (it'll not remove whitespace)</li> 028 * <li>It is able to handle quotes like "a", 'b', "b,c" etc..</li> 029 * <li>But no escapes like "c\"d"</li> 030 * <li>Empty list elements like "a,," are not supported. It'll return the "a" only.</li> 031 * </ul> 032 * 033 * @author Jonathan Locke 034 */ 035public final class CommaSeparatedVariableParser extends ListParser 036{ 037 /** Pattern to use. */ 038 private static final MetaPattern patternEntry = new MetaPattern( 039 MetaPattern.OPTIONAL_WHITESPACE, MetaPattern.STRING, MetaPattern.OPTIONAL_WHITESPACE); 040 041 /** 042 * Construct a new parser with parameter 'input' to be parsed. Base classes provide the method 043 * to access the elements of the input parsed. 044 * 045 * @param input 046 * to parse 047 */ 048 public CommaSeparatedVariableParser(final CharSequence input) 049 { 050 super(patternEntry, MetaPattern.COMMA, input); 051 } 052}