001    /**
002     * Copyright 2005-2014 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.kew.engine.node.var;
017    
018    /**
019     * Represents a property that can be accessed relative to a specific "scheme".
020     * Property format: <code>[scheme:]locator</code>
021     * <dl>
022     *   <dt>scheme</dt>
023     *   <dd>The "scheme" of the property, which is implemented by a PropertyScheme implementation to
024     *       resolve the locator to an actual value</dd>
025     *   <dt>locator</dt>
026     *   <dd>PropertyScheme-implementation-specific property name or URI</dd>
027     * </dl>
028     * 
029     * @author Kuali Rice Team (rice.collab@kuali.org)
030     */
031    public final class Property {
032        /**
033         * The property scheme (e.g. var:, url:, file:
034         */
035        public String scheme;
036        /**
037         * The property locator; in the case of a variable it is a name; in the case of a url, a url;
038         * in the case of a file, a file path
039         */
040        public String locator;
041    
042        /**
043         * Parses the scheme and locator from a property name/locator string
044         * @param string the property name/locator
045         */
046        public Property(String string) {
047            int i = string.indexOf(':');
048            if (i == -1) {
049                locator = string;
050            } else {
051                if (i > 0) {
052                    scheme = string.substring(0, i);
053                }
054                locator = string.substring(i + 1);
055            }
056        }
057    
058        /**
059         * Initialized the property with specified scheme and locator
060         * @param scheme the scheme
061         * @param locator the locator
062         */
063        public Property(String scheme, String locator) {
064            this.scheme = scheme;
065            this.locator = locator;
066        }
067    
068        public String toString() {
069            return "[Property: scheme=" + scheme + ", locator=" + locator + "]";
070        }
071    }