protected JClass generateZclType(JPackage jPackage, JClass jClass, String type, Object o) throws Exception {

		JDefinedClass jZclDefinedClass = null;

		try {
			jZclDefinedClass = jPackage._class("Zcl" + type);
		} catch (Exception e) {
			return jPackage._getClass("Zcl" + type);
		}

		// JDefinedClass jDefinedClass = null;

		// try {
		// jDefinedClass = jPackage._class(type);
		// } catch (Exception e) {
		// System.out.println("AAA");
		// return jModel.ref(jPackage.name() + "." + type);
		// }

		JClass jType = jModel.ref(jClass._package().name() + "." + type);
		JType jZclFrameInterface = jModel._ref(IZclFrame.class);

		JMethod jZclParseMethod = jZclDefinedClass.method(JMod.PUBLIC | JMod.STATIC, jType, "zclParse");
		JVar jVarZclFrameParseMethod = jZclParseMethod.param(jZclFrameInterface, "zclFrame");
		jZclParseMethod._throws(ZclValidationException.class);

		JBlock jBodyParseMethod = jZclParseMethod.body();

		JMethod jZclSerializeMethod = jZclDefinedClass.method(JMod.PUBLIC | JMod.STATIC, jModel.VOID, "zclSerialize");
		JVar jZclFrameSerializeVar = jZclSerializeMethod.param(jZclFrameInterface, "zclFrame");
		JVar jZclParamSerializeMethod = jZclSerializeMethod.param(jType, "r");
		jZclSerializeMethod._throws(ZclValidationException.class);

		JMethod jZclSizeMethod = jZclDefinedClass.method(JMod.PUBLIC | JMod.STATIC, jModel.INT, "zclSize");
		JVar jZclParamSizeMethod = jZclSizeMethod.param(jType, "r");
		jZclSizeMethod._throws(ZclValidationException.class);

		if (o instanceof ZclCommandDescriptor) {

			JVar jParseMethodVar = jBodyParseMethod.decl(jType, "r").init(JExpr._new(jType));

			ZclCommandDescriptor zclCommandDescriptor = (ZclCommandDescriptor) o;
			Vector zclParametersDescriptors = zclCommandDescriptor.getParametersDescriptors();

			JVar jSizeVar = jZclSizeMethod.body().decl(jModel.INT, "size").init(JExpr.lit(0));

			for (int i = 0; i < zclParametersDescriptors.size(); i++) {
				ZclField zclParameterDescriptor = (ZclField) zclParametersDescriptors.get(i);

				JClass jZclFieldType = getZclDataTypeJClass(jModel, jPackage, jClass, zclParameterDescriptor.getType(), null);
				if (jZclFieldType == null) {
					jZclParseMethod.body().directStatement(
							"// FIXME: unable handle parameter '" + zclParameterDescriptor.getName() + "' of type '"
									+ zclParameterDescriptor.getType() + "'");
					continue;
				}

				jZclParseMethod.body().assign(jParseMethodVar.ref(zclParameterDescriptor.getName()),
						jZclFieldType.staticInvoke("zclParse").arg(jVarZclFrameParseMethod));

				jZclSerializeMethod.body().staticInvoke(jZclFieldType, "zclSerialize").arg(jZclFrameSerializeVar)
						.arg(jZclParamSerializeMethod.ref(zclParameterDescriptor.getName()));

				// NEWWWWWWW
				jZclSizeMethod.body().assignPlus(jSizeVar,
						jZclFieldType.staticInvoke("zclSize").arg(jZclParamSizeMethod.ref(zclParameterDescriptor.getName())));

			}
			jZclParseMethod.body()._return(jParseMethodVar);
			jZclSizeMethod.body()._return(jSizeVar); // NEWWWWW

			// jZclSizeMethod.body().directStatement("// FIXME: put here the correct size");
			// jZclSizeMethod.body()._throw(
			// JExpr._new(jModel.ref(ZclValidationException.class)).arg("Not completely implemented type"));
			// jZclSizeMethod.body()._return(jSizeVar);
		}

		return jZclDefinedClass;
	}