Package org.apache.torque.generator

Examples of org.apache.torque.generator.GeneratorException


                    new RawText(generated.getBytes(charsetName)),
                    new RawText(edited.getBytes(charsetName)));
        }
        catch (UnsupportedEncodingException e)
        {
            throw new GeneratorException(
                    "unknown character set " + charsetName,
                    e);
        }
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        try
        {
            new MergeFormatter().formatMerge(
                    outputStream,
                    mergeResult,
                    "base",
                    "generated",
                    "edited",
                    charsetName);
        }
        catch (IOException e)
        {
            throw new GeneratorException("could nor render merge result", e);
        }
        try
        {
            String result
                = new String(outputStream.toByteArray(), charsetName);
            return result;
        }
        catch (UnsupportedEncodingException e)
        {
            throw new GeneratorException(
                    "unknown character set " + charsetName,
                    e);
        }
    }
View Full Code Here


                    .getConfigurationHandlers()
                    .getOutputTypes();
        OutputType outputType = outputTypes.get(outputTypeString);
        if (outputType == null)
        {
            throw new GeneratorException("Unknown output type "
                    + outputTypeString
                    + " in output "
                    + output.getName());
        }
        String commentStart = outputType.getCommentStart(lineBreak);
View Full Code Here

    public OutletResult execute(ControllerState controllerState)
            throws GeneratorException
    {
        if (count < 0)
        {
            throw new GeneratorException("count must not be < 0");
        }

        StringBuilder result = new StringBuilder();
        for (int i = 0; i < count; ++i)
        {
View Full Code Here

                false);
        Object attribute
                = sourceElement.getAttribute(attributeName);
        if (attribute == null)
        {
            throw new GeneratorException(
                    "Source element attribute not set in "
                    + clazz.getName()
                    + "\n"
                    + "The attribute "
                    + attributeName
View Full Code Here

        throws GeneratorException
    {
        Object optionValue = controllerState.getOption(optionName);
        if (optionValue == null)
        {
            throw new GeneratorException("Invalid configuration of "
                    + clazz.getName()
                    + "\n"
                    + "The option "
                    + optionName
                    + " is not set.");
View Full Code Here

        {
            return presetValue;
        }
        else
        {
            throw new GeneratorException("Invalid configuration of "
                    + clazz.getName()
                    + "\n"
                    + "Make sure that one and only one of "
                    + expectedFieldNames
                    + " are set.");
View Full Code Here

                        "");
                Velocity.init(properties);
            }
            catch (Exception e)
            {
                throw new GeneratorException(
                        "Could not initialize velocity",
                        e);
            }

            SourceElement sourceElement = controllerState.getSourceElement();

            String inputElementName = getInputElementName();
            if (inputElementName != null
                    && !inputElementName.equals(sourceElement.getName()))
            {
                throw new GeneratorException("Input element name, "
                        + sourceElement.getName()
                        + ", is not the expected name, "
                        + getInputElementName()
                        + ", for outlet "
                        + getName());
            }

            Context context = createVelocityContext(controllerState);

            Writer writer = new StringWriter();
            try
            {
                Velocity.evaluate(context, writer,
                        "VelocityTemplateOutlet:" + getName(),
                        getContent(controllerState));
                writer.flush();
                writer.close();
            }
            catch (Exception e)
            {
                log.error("error during execution of outlet "
                            + getName()
                            + " : " + e.getMessage(),
                        e);
                throw new GeneratorException(
                        "Error during execution of outlet "
                            + getName()
                            + " : "
                            + e.getMessage(),
                        e);
View Full Code Here

            StringBuilder result = new StringBuilder();
            for (OutletResult part : input)
            {
                if (!part.isStringResult())
                {
                    throw new GeneratorException(
                            "first OutletResult to concatenate is a "
                            + "String result but a following result is a "
                            + "byte array."
                            + " All concatenated results must be "
                            + "of the same type");
                }
                String partContent = part.getStringResult();
                if (partContent != null)
                {
                    result.append(partContent);
                }
            }
            return new OutletResult(result.toString());
        }
        int totalLength = 0;
        for (OutletResult part : input)
        {
            if (!part.isByteArrayResult())
            {
                throw new GeneratorException(
                        "first OutletResult to concatenate is a "
                        + "byte array result but a following result is a "
                        + "String result."
                        + " All concatenated results must be "
                        + "of the same type");
View Full Code Here

            try
            {
                OutletResult actionResult = action.execute(controllerState);
                if (!actionResult.isStringResult())
                {
                    throw new GeneratorException(
                            "mergepoint actions "
                            + "must return a String result! Mergepoint name: "
                            + mergepointName
                            + ", outlet name: "
                            + controllerState.getOutlet().getName().toString());
View Full Code Here

            {
                return new OutletResult("");
            }
            else
            {
                throw new GeneratorException("SourceElementAttributeAction: "
                        + "No element "
                        + elementPath
                        + "can be found.");
            }
        }
        String detokenizedAttributeName = tokenReplacer.process(attributeName);
        Object result = sourceElement.getAttribute(detokenizedAttributeName);
        if (result == null)
        {
            if (acceptNotSet)
            {
                return new OutletResult("");
            }
            throw new GeneratorException("SourceElementAttributeAction: "
                    + "The attribute "
                    + attributeName
                    + " is not set on the element "
                    + sourceElement.getName()
                    + " (element path was "
View Full Code Here

TOP

Related Classes of org.apache.torque.generator.GeneratorException

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.