001/*
002 * Copyright 2002-2012 the original author or authors.
003 *
004 * Licensed under the Apache 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 *      https://www.apache.org/licenses/LICENSE-2.0
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
017package org.springframework.scripting;
018
019import java.io.IOException;
020
021/**
022 * Interface that defines the source of a script.
023 * Tracks whether the underlying script has been modified.
024 *
025 * @author Rob Harrop
026 * @author Juergen Hoeller
027 * @since 2.0
028 */
029public interface ScriptSource {
030
031        /**
032         * Retrieve the current script source text as String.
033         * @return the script text
034         * @throws IOException if script retrieval failed
035         */
036        String getScriptAsString() throws IOException;
037
038        /**
039         * Indicate whether the underlying script data has been modified since
040         * the last time {@link #getScriptAsString()} was called.
041         * Returns {@code true} if the script has not been read yet.
042         * @return whether the script data has been modified
043         */
044        boolean isModified();
045
046        /**
047         * Determine a class name for the underlying script.
048         * @return the suggested class name, or {@code null} if none available
049         */
050        String suggestedClassName();
051
052}