001// Licensed under the Apache License, Version 2.0 (the "License"); 002// you may not use this file except in compliance with the License. 003// You may obtain a copy of the License at 004// 005// http://www.apache.org/licenses/LICENSE-2.0 006// 007// Unless required by applicable law or agreed to in writing, software 008// distributed under the License is distributed on an "AS IS" BASIS, 009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 010// See the License for the specific language governing permissions and 011// limitations under the License.package org.apache.tapestry5.internal.services; 012package org.apache.tapestry5.internal.services; 013 014import java.util.Collections; 015import java.util.Set; 016 017import org.apache.tapestry5.commons.util.CollectionFactory; 018import org.apache.tapestry5.internal.InternalSymbols; 019import org.apache.tapestry5.internal.TapestryInternalUtils; 020import org.apache.tapestry5.ioc.annotations.Symbol; 021 022public class FormControlNameManagerImpl implements FormControlNameManager 023{ 024 025 final private Set<String> names; 026 027 public FormControlNameManagerImpl( 028 @Symbol(InternalSymbols.RESERVED_FORM_CONTROL_NAMES) String preselectedFormNames) 029 { 030 this.names = Collections.unmodifiableSet(CollectionFactory.<String,String>newSet(TapestryInternalUtils.splitAtCommas(preselectedFormNames))); 031 } 032 033 @Override 034 public Set<String> getReservedNames() 035 { 036 return names; 037 } 038 039 @Override 040 public boolean isReserved(String name) 041 { 042 return names.contains(name.toLowerCase()); 043 } 044 045}