01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.wicket.util.parse.metapattern.parsers;
18:
19: import org.apache.wicket.util.parse.metapattern.MetaPattern;
20:
21: /**
22: * Parses out strings separated by commas.
23: * <p>
24: * Notes:
25: * <p>
26: * <ul>
27: * <li>It'll not trim the elements (it'll not remove whitespaces)</li>
28: * <li>It is able to handle quotes like "a", 'b', "b,c" etc..</li>
29: * <li>But no escapes like "c\"d"</li>
30: * <li>Empty list elements like "a,," are not supported. It'll return the "a"
31: * only.</li>
32: * </lu>
33: *
34: * @author Jonathan Locke
35: */
36: public final class CommaSeparatedVariableParser extends ListParser {
37: /** Pattern to use. */
38: private static final MetaPattern patternEntry = new MetaPattern(
39: new MetaPattern[] { MetaPattern.OPTIONAL_WHITESPACE,
40: MetaPattern.STRING, MetaPattern.OPTIONAL_WHITESPACE });
41:
42: /**
43: * Construct a new parser with parameter 'input' to be parsed. Base classes
44: * provide the method to access the elements of the input parsed.
45: *
46: * @param input
47: * to parse
48: */
49: public CommaSeparatedVariableParser(final CharSequence input) {
50: super(patternEntry, MetaPattern.COMMA, input);
51: }
52: }
|