Package org.codehaus.jam

Examples of org.codehaus.jam.JClass


  /**
   * Check to see if the unqualified name actually is already qualified.
   */
  private String checkSamePackage(String ucname) {
    String name = mContext.getPackageName()+"."+ucname;
    JClass clazz = mContext.getClassLoader().loadClass(name);
    if (VERBOSE) System.out.println(PREFIX+" checkSamePackage '"+name+"'  "+
                                    clazz.isUnresolvedType()+"  "+mContext.getClassLoader().getClass());
    return (clazz.isUnresolvedType()) ? null : clazz.getQualifiedName();
  }
View Full Code Here


  /**
   * Check to see if the unqualified name is in java.lang.
   */
  private String checkJavaLang(String ucname) {
    String name = "java.lang."+ucname;
    JClass clazz = mContext.getClassLoader().loadClass(name);
    if (VERBOSE) System.out.println(PREFIX+" checkJavaLang '"+name+"'  "+
                                    clazz.isUnresolvedType()+"  "+mContext.getClassLoader().getClass());
    return (clazz.isUnresolvedType()) ? null : clazz.getQualifiedName();
  }
View Full Code Here

  /**
   * Check to see if the unqualified name actually is already qualified.
   */
  private String checkAlreadyQualified(String ucname) {
    JClass clazz =
            mContext.getClassLoader().loadClass(ucname);
    return (clazz.isUnresolvedType()) ? null : clazz.getQualifiedName();
  }
View Full Code Here

  public String getQualifiedName() {
    StringWriter sbuf = new StringWriter();
    sbuf.write(Modifier.toString(getModifiers()));
    sbuf.write(' ');
    JClass returnJClass = getReturnType();
    if (returnJClass == null){
      sbuf.write("void ")// should not happen
    } else {
      sbuf.write(returnJClass.getQualifiedName());
      sbuf.write(' ');
    }
    sbuf.write(getSimpleName());
    sbuf.write('(');
    {
View Full Code Here

  public MAnnotation createNestedValue(String name, String annTypeName) {
    if (name == null) throw new IllegalArgumentException("null name");
    if (annTypeName == null) throw new IllegalArgumentException("null typename");
    AnnotationProxy p = getContext().createAnnotationProxy(annTypeName);
    AnnotationImpl out = new AnnotationImpl(getContext(),p,annTypeName);
    JClass type  = getContext().getClassLoader().loadClass(annTypeName);
    mProxy.setValue(name,out,type);
    return out;
  }
View Full Code Here

    MAnnotation[] out = new MAnnotation[dimensions];
    for(int i=0; i<out.length; i++) {
      AnnotationProxy p = getContext().createAnnotationProxy(annComponentTypeName);
      out[i] = new AnnotationImpl(getContext(),p,annComponentTypeName);
    }
    JClass type  = getContext().getClassLoader().loadClass("[L"+annComponentTypeName+";");
    mProxy.setValue(name,out,type);
    return out;
  }
View Full Code Here

  // ========================================================================
  // Factory methods

  public static void mapNameToPrimitive(ElementContext ctx, Map out) {
    for(int i=0; i<PrimitiveClassImpl.PRIMITIVES.length; i++) {
      JClass c = new PrimitiveClassImpl(ctx,(String)PRIMITIVES[i][0]);
      out.put(PrimitiveClassImpl.PRIMITIVES[i][0],c);
      out.put(PrimitiveClassImpl.PRIMITIVES[i][1],c);
      // REVIEW we map both the name and the fd to the class.  does that
      // seem ok?
    }
View Full Code Here

      MAnnotation ann = element.addLiteralAnnotation(assertCurrentString(NAME));
      while(ANNOTATIONVALUE.equals(getElementName())) {
        nextElement();
        String name = assertCurrentString(NAME);
        String type = assertCurrentString(TYPE);
        JClass jclass = mContext.getClassLoader().loadClass(type);
        if (jclass.isArrayType()) {
          Collection list = new ArrayList();
          while(VALUE.equals(getElementName())) {
            String value = assertCurrentString(VALUE);
            list.add(value);
          }
View Full Code Here

    assertStarted();
    mOut.writeStartElement(CLASS);
    writeValueElement(CLASS_NAME,clazz.getFieldDescriptor());
    writeValueElement(ISINTERFACE,clazz.isInterface());
    writeModifiers(clazz.getModifiers());
    JClass sc = clazz.getSuperclass();
    if (sc != null) writeValueElement(SUPERCLASS,sc.getFieldDescriptor());
    writeClassList(INTERFACE,clazz.getInterfaces());
    {
      JField[] f = clazz.getDeclaredFields();
      for(int i=0; i<f.length; i++) write(f[i]);
    }{
View Full Code Here

            XmlSchemaElement eltOuter = new XmlSchemaElement();
            schemaTypeName = new QName(targetNameSpace, simpleName, targetNamespacePrefix);
            eltOuter.setName(simpleName);
            eltOuter.setQName(schemaTypeName);

            JClass sup = javaType.getSuperclass();

            if ((sup != null) && !("java.lang.Object".compareTo(sup.getQualifiedName()) == 0) &&
                    !("org.apache.axis2".compareTo(sup.getContainingPackage().getQualifiedName()) == 0)
                    &&!("java.util".compareTo(sup.getContainingPackage().getQualifiedName()) == 0)) {
                String superClassName = sup.getQualifiedName();
                String superclassname = getSimpleName(sup);
                String tgtNamespace;
                String tgtNamespacepfx;
                QName qName = typeTable.getSimpleSchemaTypeName(superClassName);
                if (qName != null) {
                    tgtNamespace = qName.getNamespaceURI();
                    tgtNamespacepfx = qName.getPrefix();
                } else {
                    tgtNamespace =
                            resolveSchemaNamespace(sup.getContainingPackage().getQualifiedName());
                    tgtNamespacepfx = (String) targetNamespacePrefixMap.get(tgtNamespace);
                    QName superClassQname = generateSchema(sup);
                    if(superClassQname!=null){
                        tgtNamespacepfx = superClassQname.getPrefix();
                        tgtNamespace = superClassQname.getNamespaceURI();
                    }
                }

                if (tgtNamespacepfx == null) {
                    tgtNamespacepfx = generatePrefix();
                    targetNamespacePrefixMap.put(tgtNamespace, tgtNamespacepfx);
                }
                //if the parent class package name is differ from the child
                if (!((NamespaceMap) xmlSchema.getNamespaceContext()).values().
                        contains(tgtNamespace)) {
                    XmlSchemaImport importElement = new XmlSchemaImport();
                    importElement.setNamespace(tgtNamespace);
                    xmlSchema.getItems().add(importElement);
                    ((NamespaceMap) xmlSchema.getNamespaceContext()).
                            put(generatePrefix(),tgtNamespace);
                }

                QName basetype = new QName(tgtNamespace, superclassname, tgtNamespacepfx);


                complexExtension.setBaseTypeName(basetype);
                complexExtension.setParticle(sequence);

                XmlSchemaComplexContent contentModel = new XmlSchemaComplexContent();

                contentModel.setContent(complexExtension);

                complexType.setContentModel(contentModel);

            } else {
                complexType.setParticle(sequence);
            }

            complexType.setName(simpleName);

//            xmlSchema.getItems().add(eltOuter);
            xmlSchema.getElements().add(schemaTypeName, eltOuter);
            eltOuter.setSchemaTypeName(complexType.getQName());

            xmlSchema.getItems().add(complexType);
            xmlSchema.getSchemaTypes().add(schemaTypeName, complexType);

            // adding this type to the table
            typeTable.addComplexSchema(name, eltOuter.getQName());
            // adding this type's package to the table, to support inheritance.
            typeTable.addComplexSchema(javaType.getContainingPackage().getQualifiedName(),
                    eltOuter.getQName());


            Set propertiesSet = new HashSet();
            Set propertiesNames = new HashSet();

            JProperty[] tempProperties = javaType.getDeclaredProperties();
            BeanExcludeInfo beanExcludeInfo = null;
            if (service.getExcludeInfo() !=null) {
                beanExcludeInfo = service.getExcludeInfo().getBeanExcludeInfoForClass(
                        javaType.getQualifiedName());
            }
            for (int i = 0; i < tempProperties.length; i++) {
                JProperty tempProperty = tempProperties[i];
                String propertyName = getCorrectName(tempProperty.getSimpleName());
                if ((beanExcludeInfo == null) || !beanExcludeInfo.isExcludedProperty(propertyName)){
                    propertiesSet.add(tempProperty);
                }
            }

            JProperty[] properties = (JProperty[]) propertiesSet.toArray(new JProperty[0]);
            Arrays.sort(properties);
            for (int i = 0; i < properties.length; i++) {
                JProperty property = properties[i];
                boolean isArryType = property.getType().isArrayType();

                String propname = getCorrectName(property.getSimpleName());

                propertiesNames.add(propname);

                this.generateSchemaforFieldsandProperties(xmlSchema, sequence, property.getType(),
                        propname, isArryType);

            }

            JField[] tempFields = javaType.getDeclaredFields();
            HashMap FieldMap = new HashMap();


            for (int i = 0; i < tempFields.length; i++) {
                // create a element for the field only if it is public
                // and there is no property with the same name
                if (tempFields[i].isPublic()) {
                    if (tempFields[i].isStatic()){
//                        We do not need to expose static fields
                        continue;
                    }
                    String propertyName = getCorrectName(tempFields[i].getSimpleName());
                    if ((beanExcludeInfo == null) || !beanExcludeInfo.isExcludedProperty(propertyName)) {
                        // skip field with same name as a property
                        if (!propertiesNames.contains(tempFields[i].getSimpleName())) {

                            FieldMap.put(tempFields[i].getSimpleName(), tempFields[i]);
                        }
                    }
                   
                }

            }

            // remove fields from super classes patch for defect Annogen-21
            // getDeclaredFields is incorrectly returning fields of super classes as well
            // getDeclaredProperties used earlier works correctly
            JClass supr = javaType.getSuperclass();
            while (supr != null && supr.getQualifiedName().compareTo("java.lang.Object") != 0) {
                JField[] suprFields = supr.getFields();
                for (int i = 0; i < suprFields.length; i++) {
                    FieldMap.remove(suprFields[i].getSimpleName());
                }
                supr = supr.getSuperclass();
            }
            // end patch for Annogen -21

            JField[] froperties = (JField[]) FieldMap.values().toArray(new JField[0]);
            Arrays.sort(froperties);
View Full Code Here

TOP

Related Classes of org.codehaus.jam.JClass

Copyright © 2018 www.massapicom. 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.