001// Copyright 2004, 2005 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.hivemind.conditional;
016
017import org.apache.hivemind.ApplicationRuntimeException;
018import org.apache.hivemind.ClassResolver;
019import org.apache.hivemind.util.Defense;
020
021/**
022 * @author Howard M. Lewis Ship
023 */
024public class EvaluationContextImpl implements EvaluationContext
025{
026    private ClassResolver _resolver;
027
028    public EvaluationContextImpl(ClassResolver resolver)
029    {
030        Defense.notNull(resolver, "resolver");
031
032        _resolver = resolver;
033    }
034
035    public boolean isPropertySet(String propertyName)
036    {
037        return Boolean.getBoolean(propertyName);
038    }
039
040    public boolean doesClassExist(String className)
041    {
042        try
043        {
044            _resolver.findClass(className);
045
046            return true;
047        }
048        catch (ApplicationRuntimeException ex)
049        {
050            return false;
051        }
052    }
053
054}