當前位置: 首頁>>代碼示例>>Java>>正文


Java JClassType.getSimpleSourceName方法代碼示例

本文整理匯總了Java中com.google.gwt.core.ext.typeinfo.JClassType.getSimpleSourceName方法的典型用法代碼示例。如果您正苦於以下問題:Java JClassType.getSimpleSourceName方法的具體用法?Java JClassType.getSimpleSourceName怎麽用?Java JClassType.getSimpleSourceName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gwt.core.ext.typeinfo.JClassType的用法示例。


在下文中一共展示了JClassType.getSimpleSourceName方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generate

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
    throws UnableToCompleteException {
  TypeOracle typeOracle = context.getTypeOracle();
  JClassType extensionManager = typeOracle.findType(typeName);
  if (extensionManager == null) {
    logger.log(TreeLogger.ERROR, "Can't find interface type '" + typeName + "'", null);
    throw new UnableToCompleteException();
  }
  if (extensionManager.isInterface() == null) {
    logger.log(
        TreeLogger.ERROR,
        extensionManager.getQualifiedSourceName() + " is not an interface",
        null);
    throw new UnableToCompleteException();
  }

  List<JClassType> extensions = new ArrayList<>();
  for (JClassType type : typeOracle.getTypes()) {
    if (type.isAnnotationPresent(Extension.class)) {
      extensions.add(type);
    }
  }

  String packageName = extensionManager.getPackage().getName();
  String className = extensionManager.getSimpleSourceName() + "Impl";

  generateClass(logger, context, packageName, className, extensions);

  return packageName + "." + className;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:33,代碼來源:ExtensionRegistryGenerator.java

示例2: generate

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
    throws UnableToCompleteException {
  JClassType requestedType = context.getTypeOracle().findType(typeName);
  String packageName = requestedType.getPackage().getName();
  String requestedName = requestedType.getSimpleSourceName();
  String newClassName = requestedName + "Impl";

  String moduleName = createModule(logger, context, requestedType, packageName, requestedName);

  String ginjectorName =
      createGinjector(logger, context, packageName, requestedName, newClassName, moduleName);

  ClassSourceFileComposerFactory composerFactory =
      new ClassSourceFileComposerFactory(packageName, newClassName);
  composerFactory.setSuperclass(requestedType.getQualifiedSourceName());
  composerFactory.addImport(GWT.class.getCanonicalName());
  SourceWriter writer = composerFactory
      .createSourceWriter(context, context.tryCreate(logger, packageName, newClassName));
  writer.println("public void initialize() {");
  writer.indent();
  writer.println(
      "((" +  ginjectorName + ") GWT.create(" + ginjectorName + ".class)).injectMembers(this);");
  writer.outdent();
  writer.println("}");
  writer.commit(logger);

  return packageName + "." + newClassName;
}
 
開發者ID:google-code-export,項目名稱:google-gin,代碼行數:30,代碼來源:FrameworkGenerator.java

示例3: generate

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    TypeOracle typeOracle = context.getTypeOracle();
    JClassType subsystemExtensionManager = typeOracle.findType(typeName);
    if (subsystemExtensionManager == null) {
        logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null);
        throw new UnableToCompleteException();
    }
    if (subsystemExtensionManager.isInterface() == null) {
        logger.log(TreeLogger.ERROR, subsystemExtensionManager.getQualifiedSourceName() + " is not an interface",
                null);
        throw new UnableToCompleteException();
    }

    List<SubsystemExtension> subsystemExtensions = new ArrayList<SubsystemExtension>();
    for (JClassType type : typeOracle.getTypes()) {
        if (type.isAnnotationPresent(SubsystemExtension.class)) {
            subsystemExtensions.add(type.getAnnotation(SubsystemExtension.class));
        }
    }

    String packageName = subsystemExtensionManager.getPackage().getName();
    String className = subsystemExtensionManager.getSimpleSourceName() + "Impl";

    generateClass(logger, context, packageName, className, subsystemExtensions);

    return packageName + "." + className;
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:30,代碼來源:SubsystemExtensionProcessorGenerator.java

示例4: generate

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
public String generate(TreeLogger logger, GeneratorContext context,
		String requestedClass) throws UnableToCompleteException {

	TypeOracle typeOracle = context.getTypeOracle();

	JClassType objectType = typeOracle.findType(requestedClass);
	if (objectType == null) {
		logger.log(TreeLogger.ERROR, "Could not find type: " + requestedClass);
		throw new UnableToCompleteException();
	}

	implTypeName = objectType.getSimpleSourceName() + "Impl";

	implPackageName = objectType.getPackage().getName();

	JClassType[] implementedTypes = objectType.getImplementedInterfaces();

	// Can only implement one interface
	if (implementedTypes == null
			|| implementedTypes.length != 1
			|| !implementedTypes[0].getQualifiedSourceName().equals(
					TextBinder.class.getName())) {
		logger
		.log(
				TreeLogger.ERROR,
				"The type: " + requestedClass
				+ " Must implement only one interface: "
				+ TextBinder.class.getName());
		throw new UnableToCompleteException();
	}

	// Get parameterized type
	JParameterizedType parameterType = implementedTypes[0].isParameterized();
	if (parameterType == null) {
		logger.log(TreeLogger.ERROR, "The type: " + requestedClass
				+ " Must implement only one parameterized interface: "
				+ TextBinder.class.getName());
		throw new UnableToCompleteException();
	}

	if (parameterType.getTypeArgs() == null

			|| parameterType.getTypeArgs().length != 2) {
		logger.log(TreeLogger.ERROR,
				"The type: " + requestedClass
				+ " Must implement two parameterized interface: "
				+ TextBinder.class.getName() + " with two Parameter");
		throw new UnableToCompleteException();

	}

	parameterizedType1 = parameterType.getTypeArgs()[0];
	parameterizedType2 = parameterType.getTypeArgs()[1];
	// logger.log(TreeLogger.INFO ,
	// parameterizedType2.getParameterizedQualifiedSourceName() +"\n"
	// + parameterizedType2.getQualifiedSourceName());

	ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(
			implPackageName, implTypeName);

	composerFactory.addImport(Map.class.getCanonicalName());
	composerFactory.addImport(List.class.getCanonicalName());
	// composerFactory.addImport(Field.class.getCanonicalName());
	composerFactory
	.addImplementedInterface(objectType.getQualifiedSourceName());

	PrintWriter printWriter = context.tryCreate(logger, implPackageName,
			implTypeName);
	if (printWriter != null) {

		SourceWriter sourceWriter = composerFactory.createSourceWriter(context,
				printWriter);

		composeBindMethod(logger, sourceWriter);
		composeSyncMethod(logger, sourceWriter);
		sourceWriter.commit(logger);

	}
	return implPackageName + "." + implTypeName;
}
 
開發者ID:ICT-BDA,項目名稱:EasyML,代碼行數:82,代碼來源:TextBinderGenerator.java

示例5: generateExtendedProxy

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
 * Generates a wrapper around the proxy generated by
 * {@link ServiceInterfaceProxyGenerator}.
 *
 * @param logger log interface
 * @param context generator context
 * @param typeName name of the interface that was passed to
 *        {@link com.google.gwt.core.client.GWT#create(Class)}
 * @param proxyTypeName the name of the wrapped proxy class
 * @return the name of the extended proxy class
 */
private String generateExtendedProxy(TreeLogger logger, GeneratorContext context,
    String typeName, String proxyTypeName) {
  JClassType type = context.getTypeOracle().findType(typeName);
  String packageName = type.getPackage().getName();
  String className = type.getSimpleSourceName() + PROXY_SUFFIX;
  String asyncName = typeName + ASYNC_SUFFIX;

  String classNameExtendedServiceProxy = "com.google.appinventor.client.ExtendedServiceProxy";

  // The generator can be invoked for the same class name more than once.
  // In this case the GeneratorContext.tryCreate method will return null to
  // indicate that the file already exists. This is not an error.
  PrintWriter out = context.tryCreate(logger, packageName, className);
  if (out != null) {
    out.println("package " + packageName + ";");
    out.println("class " + className);
    out.println("    extends " + classNameExtendedServiceProxy + "<" + typeName + ">");
    out.println("    implements " + ServiceDefTarget.class.getName() + ", " + asyncName + " {");
    out.println("  private " + proxyTypeName + " proxy = new " + proxyTypeName + "();");
    out.println("  public String getServiceEntryPoint() {");
    out.println("    return proxy.getServiceEntryPoint();");
    out.println("  }");
    out.println("  public void setRpcRequestBuilder(" + RpcRequestBuilder.class.getName() +
        " builder) {");
    out.println("    proxy.setRpcRequestBuilder(builder);");
    out.println("  }");
    out.println("  public void setServiceEntryPoint(String address) {");
    out.println("    proxy.setServiceEntryPoint(address);");
    out.println("  }");
    out.println("  public String getSerializationPolicyName() {");
    out.println("    return proxy.getSerializationPolicyName();");
    out.println("  }");

    for (JMethod method : type.getMethods()) {
      printMethod(out, method, typeName);
    }

    out.println("}");

    context.commit(logger, out);
  }

  return packageName + "." + className;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:56,代碼來源:ExtendedServiceProxyGenerator.java

示例6: simpleNameFrom

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
private String simpleNameFrom(JClassType classType) {
	return classType.getSimpleSourceName() + "_default_VersionGenerator"; 
}
 
開發者ID:TOMOTON,項目名稱:gwt-dagger2,代碼行數:4,代碼來源:VersionGenerator.java

示例7: generate

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
    throws UnableToCompleteException {
  
  TypeOracle typeOracle = context.getTypeOracle();
  JClassType classToBeGenerated = typeOracle.findType(typeName);
  JParameterizedType superInterface = classToBeGenerated.getImplementedInterfaces()[0]
      .isParameterized();
  JClassType poolableType = superInterface.getTypeArgs()[0];
  String implName = classToBeGenerated.getSimpleSourceName() + "Impl";
  String generatedImplFullName = classToBeGenerated.getPackage().getName() + "." + implName;
  
  PrintWriter pw = context.tryCreate(logger, classToBeGenerated.getEnclosingType().getPackage()
      .getName(), implName);
  if (pw == null) {
    return generatedImplFullName;
  }
  String poolableTypeName = poolableType.getName();

  pw.append("package " + classToBeGenerated.getEnclosingType().getPackage().getName() + ";\n");
  pw.append("import " + superInterface.getQualifiedSourceName() + ";\n");
  pw.append("import " + classToBeGenerated.getQualifiedSourceName() + ";\n");
  pw.append("import " + poolableType.getQualifiedSourceName() + ";\n");
  pw.append("import org.jbox2d.pooling.PoolingStack.PoolContainer;\n");
  pw.append("public class " + implName + " implements "
      + classToBeGenerated.getSimpleSourceName() + "{\n");

  pw.append("private " + poolableTypeName + "[] pool;\n");
  pw.append("private int index;\n");
  pw.append("private int size;\n");
  pw.append("private PoolContainer<" + poolableTypeName + "> container;\n");

  pw.append("public void initPool(int argStackSize) {\n");
  pw.append("size = argStackSize;\n");
  pw.append("pool = new " + poolableTypeName + "[argStackSize];\n");
  pw.append("for(int i=0; i<argStackSize; i++){\n");
  pw.append("pool[i] = new " + poolableTypeName + "();\n");
  pw.append("}\n");
  pw.append("index = 0;\n");
  pw.append("container = new PoolContainer<" + poolableTypeName + ">();\n");
  pw.append("}\n");

  pw.append("public " + poolableTypeName + " pop() {\n");
  pw.append("return pool[index++];\n");
  pw.append("}\n");

  pw.append("public void push(int argNum) {\n");
  pw.append("index -= argNum;\n");
  pw.append("}\n");

  pw.append("public PoolContainer<" + poolableTypeName + "> pop(int argNum) {\n");
  pw.append("switch(argNum){");
  pw.append("case 9:");
  pw.append("container.p8 = pool[index++];");
  pw.append("case 8:");
  pw.append("container.p7 = pool[index++];");
  pw.append("case 7:");
  pw.append("container.p6 = pool[index++];");
  pw.append("case 6:");
  pw.append("container.p5 = pool[index++];");
  pw.append("case 5:");
  pw.append("container.p4 = pool[index++];");
  pw.append("case 4:");
  pw.append("container.p3 = pool[index++];");
  pw.append("case 3:");
  pw.append("container.p2 = pool[index++];");
  pw.append("case 2:");
  pw.append("container.p1 = pool[index++];");
  pw.append("case 1:");
  pw.append("container.p0 = pool[index++];");
  pw.append("break;");
  pw.append("default:");
  pw.append("assert(false);");
  pw.append("}");
  pw.append("return container;");
  pw.append("}\n");

  pw.append("}\n");
  context.commit(logger, pw);
  return generatedImplFullName;
}
 
開發者ID:fredsa,項目名稱:forplay,代碼行數:82,代碼來源:PoolingStackGenerator.java

示例8: generate

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
    throws UnableToCompleteException {

  // The TypeOracle knows about all types in the type system
  TypeOracle typeOracle = context.getTypeOracle();

  // Get a reference to the type that the generator should implement
  JClassType sourceType = typeOracle.findType(typeName);

  // Ensure that the requested type exists
  if (sourceType == null) {
    logger.log(TreeLogger.ERROR, "Could not find requested typeName", null);
    throw new UnableToCompleteException();
  }

  // Make sure the Gadget type is correctly defined
  validateType(logger, sourceType);

  // Pick a name for the generated class to not conflict.
  String generatedSimpleSourceName = sourceType.getSimpleSourceName() + "PluginImpl";

  // Begin writing the generated source.
  ClassSourceFileComposerFactory f =
      new ClassSourceFileComposerFactory(
          sourceType.getPackage().getName(), generatedSimpleSourceName);
  f.addImport(GWT.class.getName());
  f.setSuperclass(typeName);

  // All source gets written through this Writer
  PrintWriter out =
      context.tryCreate(logger, sourceType.getPackage().getName(), generatedSimpleSourceName);

  // If an implementation already exists, we don't need to do any work
  if (out != null) {

    // We really use a SourceWriter since it's convenient
    SourceWriter sw = f.createSourceWriter(context, out);
    sw.commit(logger);
  }

  return f.getCreatedClassName();
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:44,代碼來源:PluginGenerator.java

示例9: create

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
private RebindResult create(JClassType originalType,
                            TreeLogger logger,
                            GeneratorContext context,
                            String typeName)
  throws UnableToCompleteException {

  Date start = new Date();

  String packageName = originalType.getPackage()
                                   .getName();
  String originalClassName           = originalType.getSimpleSourceName();
  String generatedClassName          = originalClassName + "Impl";
  String generatedClassQualifiedName = packageName + "." + generatedClassName;

  // check weather there is a usual version or not.
  if (checkAlreadyGenerated(logger,
                            context,
                            generatedClassQualifiedName)) {
    // Log
    logger.log(TreeLogger.INFO,
               "reuse already generated files",
               null);
    // stop generating
    return new RebindResult(RebindMode.USE_EXISTING,
                            generatedClassQualifiedName);
  }

  logger.log(TreeLogger.INFO,
             "Generating writer for " + packageName + "." + generatedClassName,
             null);

  PrintWriter printWriter = context.tryCreate(logger,
                                              packageName,
                                              generatedClassName);

  ClassSourceFileComposerFactory classFactory = new ClassSourceFileComposerFactory(packageName,
                                                                                   generatedClassName);

  classFactory.addImplementedInterface(originalType.getName());
  String[] classesToImport = getClassesToImport();
  for (String classToImport : classesToImport) {
    classFactory.addImport(classToImport);
  }

  if (printWriter != null) {
    SourceWriter sourceWriter = classFactory.createSourceWriter(context,
                                                                printWriter);
    logger.log(TreeLogger.INFO,
               "Generating source for " + generatedClassQualifiedName + " ",
               null);
    writeClass(sourceWriter,
               getRunAsync(originalType));
    sourceWriter.commit(logger);
  }

  Date end = new Date();

  logger.log(TreeLogger.INFO,
             "Mvp4g Module Cretor: " + (end.getTime() - start.getTime()) + "ms.");

  return new RebindResult(RebindMode.USE_ALL_NEW_WITH_NO_CACHING,
                          generatedClassQualifiedName);
}
 
開發者ID:mvp4g,項目名稱:mvp4g,代碼行數:64,代碼來源:Mvp4gRunAsyncGenerator.java

示例10: generate

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    TypeOracle typeOracle = context.getTypeOracle();
    JClassType componentExtensionManager = typeOracle.findType(typeName);
    if (componentExtensionManager == null) {
        logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null);
        throw new UnableToCompleteException();
    }
    if (componentExtensionManager.isInterface() == null) {
        logger.log(TreeLogger.ERROR, componentExtensionManager.getQualifiedSourceName() + " is not an interface",
                null);
        throw new UnableToCompleteException();
    }

    JClassType componentProvider = typeOracle.findType(ComponentProvider.class.getCanonicalName());
    if (componentProvider == null) {
        logger.log(TreeLogger.ERROR, "Unable to find metadata for type 'ComponentProvider'", null);
        throw new UnableToCompleteException();
    }

    List<JClassType> componentExtensionClasses = new ArrayList<JClassType>();
    for (JClassType type : typeOracle.getTypes()) {
        if (type.isAnnotationPresent(ComponentExtension.class)) {
            if (type.isClass() == null || type.isAbstract()) {
                // type must be a class that can be instantiated
                logger.log(TreeLogger.ERROR, "ComponentExtension type '" + type.getQualifiedSourceName()
                        + "' cannot be instantiated.", null);
                throw new UnableToCompleteException();
            } else if (!type.isDefaultInstantiable()) {
                // type must have default constructor
                logger.log(TreeLogger.ERROR, "ComponentExtension type '" + type.getQualifiedSourceName()
                        + "' does not provide a default constructor.", null);
                throw new UnableToCompleteException();
            } else if (!type.isAssignableTo(componentProvider)) {
                // type must implement ComponentProvider
                logger.log(TreeLogger.ERROR, "ComponentExtension type '" + type.getQualifiedSourceName()
                        + "' does not implement ComponentProvider.", null);
                throw new UnableToCompleteException();
            }
            componentExtensionClasses.add(type);
        }
    }

    String packageName = componentExtensionManager.getPackage().getName();
    String className = componentExtensionManager.getSimpleSourceName() + "Impl";

    generateClass(logger, context, packageName, className, componentExtensionClasses);

    return packageName + "." + className;
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:52,代碼來源:ComponentExtensionManagerGenerator.java


注:本文中的com.google.gwt.core.ext.typeinfo.JClassType.getSimpleSourceName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。