Examples of ClassDefinition


Examples of archmapper.main.model.archmapping.ClassDefinition

    return null;
  }
 
  private ClassDefinition createClassDefinitionFromAnnotationOrClassNamePattern(ITypeBinding binding,
      ImplementableArchitectureElementMapping mapping, ImplementationArtifactDefinition classNamePattern) {
    ClassDefinition classDef = new ClassDefinition();
    classDef.setClassName(binding.getName());
    classDef.setPackageName(binding.getPackage().getName());
    classDef.setParent(mapping);
    mapping.getClassDefinition().add(classDef);
   
    if (classNamePattern != null) {
      classDef.setType(classNamePattern.getType());
    }
   
    return classDef;
  }
View Full Code Here

Examples of co.cask.cdap.internal.asm.ClassDefinition

    generateGetter(field);
    generateSetter(field);

    classWriter.visitEnd();

    ClassDefinition classDefinition = new ClassDefinition(classWriter.toByteArray(), className);
    // DEBUG block. Uncomment for debug
//    co.cask.cdap.internal.asm.Debugs.debugByteCode(classDefinition, new java.io.PrintWriter(System.out));
    // End DEBUG block
    return classDefinition;
  }
View Full Code Here

Examples of co.cask.tigon.internal.asm.ClassDefinition

    private final Map<TypeToken<?>, ByteCodeClassLoader> classloaders = Maps.newIdentityHashMap();

    @SuppressWarnings("unchecked")
    @Override
    public Class<DatumWriter<?>> load(CacheKey key) throws Exception {
      ClassDefinition classDef = new DatumWriterGenerator().generate(key.getType(), key.getSchema());

      ClassLoader typeClassloader = ClassLoaders.getClassLoader(key.getType());
      ByteCodeClassLoader classloader = classloaders.get(key.getType());
      if (classloader == null) {
        classloader = new ByteCodeClassLoader(typeClassloader);
        classloaders.put(key.getType(), classloader);
      }

      return (Class<DatumWriter<?>>) classloader.addClass(classDef, key.getType().getRawType())
                                                .loadClass(classDef.getClassName());
    }
View Full Code Here

Examples of com.facebook.presto.byteCode.ClassDefinition

    {
        DynamicClassLoader classLoader = createClassLoader();
        Class<? extends T> singleStateClass = generateSingleStateClass(clazz, classLoader);
        Class<? extends T> groupedStateClass = generateGroupedStateClass(clazz, classLoader);

        ClassDefinition definition = new ClassDefinition(new CompilerContext(null),
                a(PUBLIC, FINAL),
                typeFromPathName(clazz.getSimpleName() + "Factory_" + CLASS_ID.incrementAndGet()),
                type(Object.class),
                type(AccumulatorStateFactory.class));

        // Generate constructor
        definition.declareConstructor(new CompilerContext(null), a(PUBLIC))
                .getBody()
                .pushThis()
                .invokeConstructor(Object.class)
                .ret();

        // Generate single state creation method
        definition.declareMethod(new CompilerContext(null), a(PUBLIC), "createSingleState", type(Object.class))
                .getBody()
                .newObject(singleStateClass)
                .dup()
                .invokeConstructor(singleStateClass)
                .retObject();

        // Generate grouped state creation method
        definition.declareMethod(new CompilerContext(null), a(PUBLIC), "createGroupedState", type(Object.class))
                .getBody()
                .newObject(groupedStateClass)
                .dup()
                .invokeConstructor(groupedStateClass)
                .retObject();
View Full Code Here

Examples of com.facebook.swift.codec.internal.compiler.byteCode.ClassDefinition

        this.metadata = metadata;

        structType = type(metadata.getStructClass());
        codecType = toCodecType(metadata);

        classDefinition = new ClassDefinition(
                a(PUBLIC, SUPER),
                codecType.getClassName(),
                type(Object.class),
                type(ThriftCodec.class, structType)
        );
View Full Code Here

Examples of com.google.opengse.webapp.codegen.ClassDefinition

    if (!javadir.exists()) {
      System.err.println("Can't create '" + javadir + "' for some reason.");
      return;
    }

    ClassDefinition classdef = new ClassDefinition(EXAMPLE_CODE_PACKAGE, EXAMPLE_CODE_CLASS);
    classdef.setSuperClass(HttpServlet.class);
    classdef.addImport(HttpServlet.class);
    classdef.addImport(HttpServletRequest.class);
    classdef.addImport(HttpServletResponse.class);
    classdef.addImport(ServletException.class);
    classdef.addImport(IOException.class);
    MethodDefinition method = new MethodDefinition("service");
    method.setPublic(true);
    method.addThrowsClause(ServletException.class).addThrowsClause(IOException.class);
    method.addArg(HttpServletRequest.class, "request");
    method.addArg(HttpServletResponse.class, "response");
    method.addLine("response.setContentType(\"text/plain\");");
    method.addLine("response.getWriter().println(\"Hello World!\");");
    classdef.addMethod(method);

    File javafile = new File(javadir
        , EXAMPLE_CODE_PACKAGE.replace('.', File.separatorChar) + File.separator + EXAMPLE_CODE_CLASS + ".java");
    javafile.getParentFile().mkdirs();
    PrintWriter java = new PrintWriter(javafile);
    try {
      classdef.write(java);
    } finally {
      java.close();
    }
   
    WebAppConfigurationBuilder wxmlb = new WebAppConfigurationBuilder();
View Full Code Here

Examples of com.hazelcast.nio.serialization.ClassDefinition

        }
        return fieldExtractor;
    }

    private static FieldDefinition getFieldDefinition(Data data, String fieldName, PortableContext portableContext) {
        ClassDefinition classDefinition = data.getClassDefinition();
        FieldDefinition fieldDefinition = portableContext.getFieldDefinition(classDefinition, fieldName);
        if (fieldDefinition == null) {
            throw new QueryException("Unknown Portable field: " + fieldName);
        }
        return fieldDefinition;
View Full Code Here

Examples of java.lang.instrument.ClassDefinition

            } else {
                log.trace(_loc.get("redefine-types", classes.keySet()));
                // in a Java 5 context, we can use class redefinition instead
                ClassDefinition[] defs = new ClassDefinition[array.length];
                for (int i = 0; i < defs.length; i++)
                    defs[i] = new ClassDefinition(array[i],
                        classes.get(array[i]));
                inst.redefineClasses(defs);
            }
        } catch (NoSuchMethodException e) {
            throw new InternalException(e);
View Full Code Here

Examples of org.apache.flex.compiler.internal.definitions.ClassDefinition

        }
    }

    private void processRootTag(MXMLTreeBuilder builder, IMXMLTagData rootTag, IMXMLTextData asDoc)
    {
        ClassDefinition fileDef = fileScope.getMainClassDefinition();
        assert fileDef != null;

        IDefinition tagDef = builder.getFileScope().resolveTagToDefinition(rootTag);

        // Report a problem if the root tag doesn't map to a definition.
        if (tagDef == null)
        {
            ICompilerProblem problem = new MXMLUnresolvedTagProblem(rootTag);
            builder.addProblem(problem);
            return;
        }

        // Report a problem if that definition isn't for a class.
        if (!(tagDef instanceof IClassDefinition))
        {
            ICompilerProblem problem = new MXMLNotAClassProblem(rootTag, tagDef.getQualifiedName());
            builder.addProblem(problem);
            return;
        }

        IClassDefinition tagDefinition = (IClassDefinition)tagDef;

        // Report a problem if that class is final.
        if (tagDefinition != null && tagDefinition.isFinal())
        {
            ICompilerProblem problem = new MXMLFinalClassProblem(rootTag, tagDef.getQualifiedName());
            builder.addProblem(problem);
            return;
        }

        // Report a problem is that class's constructor has required parameters.
        IFunctionDefinition constructor = tagDefinition.getConstructor();
        if (constructor != null && constructor.hasRequiredParameters())
        {
            ICompilerProblem problem = new MXMLConstructorHasParametersProblem(rootTag, tagDef.getQualifiedName());
            builder.addProblem(problem);
            return;
        }

        documentNode = new MXMLDocumentNode(this);
        documentNode.setClassReference(project, tagDefinition);
        documentNode.setClassDefinition(fileDef);
        documentNode.initializeFromTag(builder, rootTag);
       
        if (asDoc != null)
        {
            IASDocComment asDocComment = builder.getWorkspace().getASDocDelegate().createASDocComment(asDoc, tagDefinition);
            documentNode.setASDocComment(asDocComment);
        }

        fileDef.setNode(documentNode);
        // TODO setNode() sets the nameStart and nameEnd to -1
        // Fix setNode() to set the values properly
        // From MXMLScopeBuilder - CM clients expect the name start of the root class definition to be at 0.
        if (fileDef.getNameStart() == -1 && fileDef.getNameEnd() == -1)
            fileDef.setNameLocation(0, 0);
    }
View Full Code Here

Examples of org.destecs.tools.jprotocolgenerator.ast.ClassDefinition

  private String generateExtendedMethod(Method m)
  {

    StringBuffer sb = new StringBuffer();
    List<ClassDefinition> defs = new Vector<ClassDefinition>();
    ClassDefinition returnClass = null;

    if (m.javaDoc != null)
    {
      sb.append(m.javaDoc);
      sb.append("\n\t");
    }
    sb.append("public ");
    if (m.returnType instanceof MapType)
    {
      returnClass = new ClassDefinition();
      returnClass.setName(m.name + "Struct");
      returnClass.packageName = structPackageName;
      returnClass.imports.add(new Type(Map.class));
      returnClass.imports.add(new Type(List.class));
      returnClass.implemented.add(stryctInterface);
      sb.append(returnClass.getName());
    } else
    {

      sb.append(m.returnType.toSource());
    }
    sb.append(" ");
    sb.append(m.name);
    sb.append("(");

    Parameter p1 = m.parameters.get(0);

    MapType type = (MapType) p1.type;

    Map<String, ClassDefinition> structs = new Hashtable<String, ClassDefinition>();

    for (String key : type.possibleEntries.keySet())
    {
      ITypeNode t = type.possibleEntries.get(key);
      if ((t instanceof ListType
          && ((ListType) t).type instanceof MapType || t instanceof MapType))
      {

        ClassDefinition pClass = new ClassDefinition();
        pClass.setName(m.name + key + "StructParam");
        pClass.packageName = structPackageName;
        pClass.imports.add(new Type(Map.class));
        pClass.imports.add(new Type(List.class));
        pClass.implemented.add(stryctInterface);
        defs.add(pClass);
        structs.put(key, pClass);
        MapType mType = null;
        if (t instanceof ListType)
        {
          mType = (MapType) ((ListType) t).type;
        } else
        {
          mType = (MapType) t;
        }
        defs.addAll(generateStructs(pClass, structPackageName, mType));

        if (t instanceof ListType)
        {
          sb.append("List<" + pClass.getName() + ">");
        } else
        {

          sb.append(pClass.getName());
        }
      } else
      {

        sb.append(type.possibleEntries.get(key).toSource());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.