/*----------------------------------------------------------------------------
Copyright (c)2000 TogetherSoft Corporation. Patents pending. All rights reserved.
----------------------------------------------------------------------------*/
package com.togethersoft.modules.patterns.JAVA.CLASS.HP_E_Speak.Service_Provider.code;

import com.togethersoft.openapi.sci.*;
import com.togethersoft.openapi.util.propertyMap.PropertyMap;

import com.togethersoft.modules.patterns.JAVA.CLASS.HP_E_Speak.Service_Provider.LeafSciTemplate;
import com.togethersoft.modules.patterns.JAVA.CLASS.HP_E_Speak.Service_Provider.ClientProperty;
import com.togethersoft.modules.patterns.JAVA.CLASS.HP_E_Speak.Service_Provider.ClientConstant;

class ServiceExceptionTemplate extends LeafSciTemplate {


        public ServiceExceptionTemplate(PropertyMap properties) {
                super(properties);
                }

        public SciObject generate(SciObject target) {

                SciClass clazz = (SciClass) target;

                /*
                 * Generate operation.
                 */
                SciOperation operation = getSciFactory().newOperation();
                operation.setName("handleException");
                operation.setProperty(SciProperty.PROTECTED, true);
                operation.setProperty(SciProperty.STATIC, true);
                operation.getParameterList().setText("String description, Exception exception");


                /*
                 * Generate getter code.
                 */
                String code = "System.out.println(\"[EXCEPTION] \" + description + \" due to : \" + exception.getMessage());\n";

                try {
                        SciCodeBlock codeBlock = getSciGenericFactory().newCodeBlock(code);
                        operation.setBody(codeBlock);
                        }
                catch(SciGenericFactoryException sciGFException) {}

                operation = (SciOperation) clazz.paste(operation, null, true);

                return super.generate(clazz);
                }

        public boolean canGenerate() {
                return true;
                }

        }


