Package org.clapper.util.text

Examples of org.clapper.util.text.VariableSubstitutionException


            checkVariableName (varName);
        }

        catch (ConfigurationException ex)
        {
            throw new VariableSubstitutionException (ex);
        }

        currentVariable = substContext.currentVariable;
        if (currentVariable.getName().equals (varName))
        {
            throw new VariableSubstitutionException
                                 (Package.BUNDLE_NAME,
                                  "Configuration.recursiveSubst",
                                  "Attempt to substitute value for variable " +
                                  "\"{0}\" within itself.",
                                  new Object[] {varName});
        }

        variableParentSection = substContext.currentVariable.getSection();
        i = varName.indexOf (':');
        if (i == -1)
        {
            // No section in the variable reference. Use the variable's
            // context.

            section = variableParentSection;
            sectionName = section.getName();
        }

        else
        {
            sectionName = varName.substring (0, i);
            varName = varName.substring (i + 1);

            if (sectionName.equals (SYSTEM_SECTION_NAME))
                section = systemSection;

            else if (sectionName.equals (PROGRAM_SECTION_NAME))
                section = programSection;

            else if (sectionName.equals (ENV_SECTION_NAME))
                section = envSection;

            else
                section = sectionsByName.get (sectionName);
        }

        if (section == null)
        {
            if (abortOnUndefinedVariable)
            {
                throw new VariableSubstitutionException
                    (Package.BUNDLE_NAME,
                     "Configuration.nonExistentSection",
                     "Reference to variable \"{0}\" in nonexistent section " +
                     "\"{1}\".",
                     new Object[] {varName, sectionName});
            }
        }

        else
        {
            if (variableParentSection.getID() < section.getID())
            {
                String parentSectionName = variableParentSection.getName();
                String thisSectionName = section.getName();

                throw new VariableSubstitutionException
                    (Package.BUNDLE_NAME,
                     "Configuration.badSectionRef",
                     "Variable \"{0}\" in section \"{1}\" cannot substitute " +
                     "the value of variable \"{2}\" from section \"{3}\", " +
                     "because section \"{3}\" appears after section \"{1}\" " +
                     "in the configuration file.",
                     new Object[]
                     {
                         substContext.currentVariable.getName(),
                         parentSectionName,
                         varName,
                         thisSectionName,
                         thisSectionName,
                         parentSectionName
                     });
            }

            Variable varToSubst;

            try
            {
                varToSubst = section.getVariable (varName);
            }

            catch (ConfigurationException ex)
            {
                throw new VariableSubstitutionException (ex.getMessage());
            }

            if (varToSubst != null)
             {
                value = varToSubst.getCookedValue();
View Full Code Here


                variable = section.addVariable(variableName, value);
        }

        catch (ConfigurationException ex)
        {
            throw new VariableSubstitutionException (ex.getMessage());
        }


        if (expand)
        {
            try
            {
                substituteVariables(variable, varSubstituter, true);
            }

            catch (ConfigurationException ex)
            {
                throw new VariableSubstitutionException (ex.getMessage());
            }
        }
    }
View Full Code Here

        public String getVariableValue (String varName, Object context)
            throws VariableSubstitutionException
        {
            if (! varName.equals ("n"))
            {
                throw new VariableSubstitutionException
                    (Package.BUNDLE_NAME,
                     "RollingFileWriter.unknownVariable",
                     "Unknown variable \"{0}\" in file pattern \"{1}\"",
                     new Object[] {varName, context});
            }
View Full Code Here

TOP

Related Classes of org.clapper.util.text.VariableSubstitutionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.