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     */
017    package org.apache.camel.component.properties;
018    
019    import java.util.Properties;
020    
021    /**
022     * A parser to parse properties for a given input
023     */
024    public interface PropertiesParser {
025    
026        /**
027         * Parses the string and replaces the property placeholders with values from the given properties.
028         *
029         * @param text        the text to be parsed
030         * @param properties  the properties resolved which values should be looked up
031         * @param prefixToken the prefix token
032         * @param suffixToken the suffix token
033         * @return the parsed text with replaced placeholders
034         * @throws IllegalArgumentException if uri syntax is not valid or a property is not found
035         */
036        String parseUri(String text, Properties properties, String prefixToken, String suffixToken) throws IllegalArgumentException;
037    
038        /**
039         * While parsing the uri using {@link #parseUri(String, java.util.Properties, String, String) parseUri} each
040         * parsed property found invokes this callback.
041         * <p/>
042         * This strategy method allows you to hook into the parsing and do custom lookup and return the actual value to use.
043         *
044         * @param key        the key
045         * @param value      the value
046         * @param properties the properties resolved which values should be looked up
047         * @return the value to use
048         */
049        String parseProperty(String key, String value, Properties properties);
050    }