Java Code Examples for javax.lang.model.element.PackageElement#getQualifiedName()

The following examples show how to use javax.lang.model.element.PackageElement#getQualifiedName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MementoProcessor.java    From memento with Apache License 2.0 6 votes vote down vote up
private void generateMemento(Set<? extends Element> elements, Element hostActivity, TypeElement activityType)
        throws IOException {
    PackageElement packageElement = processingEnv.getElementUtils().getPackageOf(hostActivity);
    final String simpleClassName = hostActivity.getSimpleName() + "$Memento";
    final String qualifiedClassName = packageElement.getQualifiedName() + "." + simpleClassName;

    log("writing class " + qualifiedClassName);
    JavaFileObject sourceFile = processingEnv.getFiler().createSourceFile(
            qualifiedClassName, elements.toArray(new Element[elements.size()]));

    JavaWriter writer = new JavaWriter(sourceFile.openWriter());

    emitClassHeader(packageElement, activityType, writer);

    writer.beginType(qualifiedClassName, "class", EnumSet.of(Modifier.PUBLIC, Modifier.FINAL),
            "Fragment", LIB_PACKAGE + ".MementoMethods");

    emitFields(elements, writer);
    emitConstructor(simpleClassName, writer);
    emitReaderMethod(elements, hostActivity, writer);
    emitWriterMethod(elements, hostActivity, writer);

    writer.endType();
    writer.close();
}
 
Example 2
Source File: Hinter.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Converts a (possibly) localized string attribute in a layer into a value suitable for {@link org.openide.filesystems.annotations.LayerBuilder.File#bundlevalue(String,String)}.
 * @param attribute the result of {@link FileObject#getAttribute} on a {@code literal:*} key
 * @param declaration the declaring element (used to calculate package)
 * @return a string referring to the same (possibly) localized value (may be null)
 */
public @CheckForNull String bundlevalue(@NullAllowed Object attribute, Element declaration) {
    if (attribute instanceof String) {
        String val = (String) attribute;
        if (val.startsWith("bundle:")) {
            PackageElement pkg = findPackage(declaration);
            if (pkg != null) {
                String expected = "bundle:" + pkg.getQualifiedName() + ".Bundle#";
                if (val.startsWith(expected)) {
                    return val.substring(expected.length() - 1); // keep '#'
                }
            }
            return val.substring(7);
        }
        return val;
    } else {
        return null;
    }
}
 
Example 3
Source File: DaoProcessor.java    From doma with Apache License 2.0 6 votes vote down vote up
protected String prefix() {
  String daoPackage = ctx.getOptions().getDaoPackage();
  if (daoPackage != null) {
    return daoPackage + ".";
  }
  PackageElement packageElement = ctx.getMoreElements().getPackageOf(typeElement);
  Name packageName = packageElement.getQualifiedName();
  String base = "";
  if (packageName.length() > 0) {
    base = packageName + ".";
  }
  String daoSubpackage = ctx.getOptions().getDaoSubpackage();
  if (daoSubpackage != null) {
    return base + daoSubpackage + ".";
  }
  return base;
}
 
Example 4
Source File: WebServiceVisitor.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
Example 5
Source File: AutoServiceProcessor.java    From auto with Apache License 2.0 5 votes vote down vote up
private String getBinaryNameImpl(TypeElement element, String className) {
  Element enclosingElement = element.getEnclosingElement();

  if (enclosingElement instanceof PackageElement) {
    PackageElement pkg = (PackageElement) enclosingElement;
    if (pkg.isUnnamed()) {
      return className;
    }
    return pkg.getQualifiedName() + "." + className;
  }

  TypeElement typeElement = (TypeElement) enclosingElement;
  return getBinaryNameImpl(typeElement, typeElement.getSimpleName() + "$" + className);
}
 
Example 6
Source File: Processor.java    From immutables with Apache License 2.0 5 votes vote down vote up
private String getTemplateText(
    Filer filer,
    TypeElement templateType,
    PackageElement packageElement) throws IOException {
  CharSequence relativeName = templateType.getSimpleName() + ".generator";
  CharSequence packageName = packageElement.getQualifiedName();
  List<Exception> suppressed = Lists.newArrayList();
  try {
    return filer.getResource(StandardLocation.SOURCE_PATH, packageName, relativeName)
        .getCharContent(true)
        .toString();
  } catch (Exception cannotGetFromSourcePath) {
    suppressed.add(cannotGetFromSourcePath);
    try {
      return filer.getResource(StandardLocation.CLASS_OUTPUT, packageName, relativeName)
          .getCharContent(true)
          .toString();
    } catch (Exception cannotGetFromOutputPath) {
      suppressed.add(cannotGetFromOutputPath);
      try {
        return filer.getResource(StandardLocation.CLASS_PATH,
            "",
            packageName.toString().replace('.', '/') + '/' + relativeName)
            .getCharContent(true)
            .toString();
      } catch (IOException cannotGetFromClasspath) {
        for (Exception e : suppressed) {
          cannotGetFromClasspath.addSuppressed(e);
        }
        throw cannotGetFromClasspath;
      }
    }
  }
}
 
Example 7
Source File: MyAnnotationProcessor.java    From takari-lifecycle with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
  for (Element element : roundEnv.getElementsAnnotatedWith(MyAnnotation.class)) {
    try {
      TypeElement cls = (TypeElement) element;
      PackageElement pkg = (PackageElement) cls.getEnclosingElement();
      String clsSimpleName = "My" + cls.getSimpleName();
      String clsQualifiedName = pkg.getQualifiedName() + "." + clsSimpleName;
      JavaFileObject sourceFile =
          processingEnv.getFiler().createSourceFile(clsQualifiedName, element);
      OutputStream ios = sourceFile.openOutputStream();
      OutputStreamWriter writer = new OutputStreamWriter(ios, "UTF-8");
      BufferedWriter w = new BufferedWriter(writer);
      try {
        w.append("package ").append(pkg.getQualifiedName()).append(";");
        w.newLine();
        w.append("public class ").append(clsSimpleName).append(" { }");
      } finally {
        w.close();
        writer.close();
        ios.close();
      }
    } catch (IOException e) {
      e.printStackTrace();
    } 
  }
  return true;
}
 
Example 8
Source File: LightCycleProcessor.java    From lightcycle with Apache License 2.0 5 votes vote down vote up
private void generateBinder(Set<String> erasedTargetNames, List<? extends Element> elements, Element hostElement)
        throws IOException {
    PackageElement packageElement = processingEnv.getElementUtils().getPackageOf(hostElement);
    final String simpleClassName = binderName(hostElement.getSimpleName().toString());
    final String qualifiedClassName = packageElement.getQualifiedName() + "." + simpleClassName;

    JavaFileObject sourceFile = processingEnv.getFiler().createSourceFile(
            qualifiedClassName, elements.toArray(new Element[elements.size()]));

    ClassName hostElementName = ClassName.bestGuess(hostElement.getSimpleName().toString());
    MethodSpec bindMethod = MethodSpec.methodBuilder(METHOD_BIND_NAME)
            .addModifiers(Modifier.PUBLIC, Modifier.STATIC)
            .returns(void.class)
            .addParameter(hostElementName, METHOD_BIND_ARGUMENT_NAME)
            .addCode(generateBindMethod(erasedTargetNames, hostElement, elements))
            .build();

    TypeSpec classType = TypeSpec.classBuilder(simpleClassName)
            .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
            .addMethod(bindMethod)
            .build();

    final Writer writer = sourceFile.openWriter();
    JavaFile.builder(packageElement.getQualifiedName().toString(), classType)
            .build()
            .writeTo(writer);
    writer.close();
}
 
Example 9
Source File: ExternalAnnotationInjector.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Override
public boolean visit(PackageDeclaration node) {
  PackageElement element = node.getPackageElement();
  String elementName = element.getQualifiedName() + ".package-info";
  AClass annotatedElement = annotatedAst.classes.get(elementName);
  if (annotatedElement != null) {
    recordAnnotations(element, annotatedElement.tlAnnotationsHere);
  }
  return false;
}
 
Example 10
Source File: WebServiceVisitor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
Example 11
Source File: WebServiceVisitor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
Example 12
Source File: WebServiceVisitor.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
Example 13
Source File: WebServiceVisitor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
Example 14
Source File: WebServiceVisitor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
Example 15
Source File: WebServiceVisitor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
Example 16
Source File: WebServiceVisitor.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
Example 17
Source File: GenericTypeElementImpl.java    From FreeBuilder with Apache License 2.0 4 votes vote down vote up
@Override
public Name visitPackage(PackageElement e, Void p) {
  return e.getQualifiedName();
}
 
Example 18
Source File: CompositeTypeConstructorGenerator.java    From qpid-broker-j with Apache License 2.0 4 votes vote down vote up
private void generateCompositeTypeConstructor(final Filer filer, final TypeElement typeElement)
{
    String objectQualifiedClassName = typeElement.getQualifiedName().toString();
    String objectSimpleName = typeElement.getSimpleName().toString();
    String compositeTypeConstructorNameSimpleName = objectSimpleName + "Constructor";
    PackageElement packageElement = (PackageElement) typeElement.getEnclosingElement();
    final String compositeTypeConstructorPackage = packageElement.getQualifiedName() + ".codec";
    String compositeTypeConstructorName = compositeTypeConstructorPackage + "." + compositeTypeConstructorNameSimpleName;
    final CompositeType annotation = typeElement.getAnnotation(CompositeType.class);

    processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Generating composite constructor file for " + objectQualifiedClassName);

    try
    {
        JavaFileObject factoryFile = filer.createSourceFile(compositeTypeConstructorName);
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(factoryFile.openOutputStream(), "UTF-8"));
        pw.println("/*");
        for(String headerLine : License.LICENSE)
        {
            pw.println(" *" + headerLine);
        }
        pw.println(" */");
        pw.println();
        pw.print("package ");
        pw.print(compositeTypeConstructorPackage);
        pw.println(";");
        pw.println();

        pw.println("import java.util.List;");
        pw.println();
        pw.println("import org.apache.qpid.server.protocol.v1_0.codec.AbstractCompositeTypeConstructor;");
        pw.println("import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;");
        pw.println("import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;");
        pw.println("import org.apache.qpid.server.protocol.v1_0.type.Symbol;");
        pw.println("import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;");
        pw.println("import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;");
        pw.println("import org.apache.qpid.server.protocol.v1_0.type.transport.Error;");
        pw.println("import " + objectQualifiedClassName + ";");
        pw.println();

        pw.println("public final class " + compositeTypeConstructorNameSimpleName + " extends AbstractCompositeTypeConstructor<"+ objectSimpleName +">");
        pw.println("{");
        pw.println("    private static final " + compositeTypeConstructorNameSimpleName + " INSTANCE = new " + compositeTypeConstructorNameSimpleName + "();");
        pw.println();

        pw.println("    public static void register(DescribedTypeConstructorRegistry registry)");
        pw.println("    {");
        pw.println("        registry.register(Symbol.valueOf(\"" + annotation.symbolicDescriptor() + "\"), INSTANCE);");
        pw.println(String.format("        registry.register(UnsignedLong.valueOf(%#016x), INSTANCE);", annotation.numericDescriptor()));
        pw.println("    }");
        pw.println();

        pw.println("    @Override");
        pw.println("    protected String getTypeName()");
        pw.println("    {");
        pw.println("        return " + objectSimpleName + ".class.getSimpleName();");
        pw.println("    }");
        pw.println();

        pw.println("    @Override");
        pw.println("    protected " + objectSimpleName + " construct(final FieldValueReader fieldValueReader) throws AmqpErrorException");
        pw.println("    {");
        pw.println("        " + objectSimpleName + " obj = new " + objectSimpleName + "();");
        pw.println();
        generateAssigners(pw, typeElement);
        pw.println("        return obj;");
        pw.println("    }");
        pw.println("}");
        pw.close();
    }
    catch (IOException e)
    {
        processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
                                                 "Failed to write composite constructor file: "
                                                 + compositeTypeConstructorName
                                                 + " - "
                                                 + e.getLocalizedMessage());
    }
}
 
Example 19
Source File: CachingElements.java    From immutables with Apache License 2.0 4 votes vote down vote up
CachingPackageElement(PackageElement delegate) {
  super(delegate);
  this.delegate = delegate;
  this.qualifiedName = delegate.getQualifiedName();
}
 
Example 20
Source File: HtmlDocWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Get the enclosed name of the package
 *
 * @param te  TypeElement
 * @return the name
 */
public String getEnclosingPackageName(TypeElement te) {

    PackageElement encl = configuration.utils.containingPackage(te);
    return (encl.isUnnamed()) ? "" : (encl.getQualifiedName() + ".");
}