Package org.codehaus.jam

Examples of org.codehaus.jam.JProperty


     */
    public List getProperties() {
        List answer = new ArrayList();
        JProperty[] properties = jclass.getDeclaredProperties();
        for (int i = 0; i < properties.length; i++) {
            JProperty property = properties[i];
            if (isValidProperty(property)) {
                answer.add(property);
            }
        }
        return answer;
View Full Code Here


            StringWriter buffer = new StringWriter();
            PrintWriter out = new PrintWriter(buffer);
            out.println("            int answer = 0;");
            Iterator iter = getProperties().iterator();
            while (iter.hasNext()) {
                JProperty property = (JProperty) iter.next();
                out.println("            answer = (answer * 37) + HashCode(" + property.getSimpleName() + ");");
            }
            out.println("            return answer;");
            return buffer.toString();
        }
        return null;
View Full Code Here

            StringWriter buffer = new StringWriter();
            PrintWriter out = new PrintWriter(buffer);
           
            Iterator iter = getProperties().iterator();
            while (iter.hasNext()) {
                JProperty property = (JProperty) iter.next();
                String name = property.getSimpleName();
                out.println("            if (! Equals(this." + name + ", that." + name + ")) return false;");
            }
            out.println("            return true;");
            return buffer.toString();
        }
View Full Code Here

            StringWriter buffer = new StringWriter();
            PrintWriter out = new PrintWriter(buffer);
            out.println("            return GetType().Name + \"[\"");
            Iterator iter = getProperties().iterator();
            while (iter.hasNext()) {
                JProperty property = (JProperty) iter.next();
                String name = property.getSimpleName();
                out.println("                + \" " + name + "=\" + " + name);
            }
            out.println("                + \" ]\";");
            return buffer.toString();
    }
View Full Code Here

    List properties = getProperties();
    String type;
    Object name;
    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      JProperty property = (JProperty) iter.next();
          type = toCSharpType(property.getType());
          name = decapitalize(property.getSimpleName());
out.println("        "+type+" "+name+";");
    }

  String text = makeHashCodeBody();
  if (text != null) {
out.println("");
out.println("    public override int GetHashCode() {");
out.println(""+text+"");
out.println("    }");
  }

  text = makeEqualsBody();
  if (text != null) {
out.println("");
out.println("    public override bool Equals(object that) {");
out.println("        if (that is "+className+") {");
out.println("            return Equals(("+className+") that);");
out.println("      }");
out.println("      return false;");
out.println("      }");
out.println("");   
out.println("    public virtual bool Equals("+className+" that) {");
out.println(""+text+"");
out.println("    }");
  }
     
  text = makeToStringBody();
  if (text != null) {
out.println("")
out.println("    public override string ToString() {");
out.println(""+text+"");
out.println("    }");
  }
     
out.println("");
out.println("        public override byte GetDataStructureType() {");
out.println("            return ID_"+jclass.getSimpleName()+";");
out.println("        }");
out.println("");
out.println("");
out.println("        // Properties");

        for (Iterator iter = properties.iterator(); iter.hasNext();) {
          JProperty property = (JProperty) iter.next();
                    type = toCSharpType(property.getType());
                    name = decapitalize(property.getSimpleName());
                    String propertyName = property.getSimpleName();
                    String getter = capitalize(property.getGetter().getSimpleName());
                    String setter = capitalize(property.getSetter().getSimpleName());

out.println("");
out.println("        public "+type+" "+propertyName+"");
out.println("        {");
out.println("            get { return "+name+"; }");
View Full Code Here

        if (name.startsWith("get")) {
          name = name.substring(3);
        } else {
          name = name.substring(2);
        }
        JProperty prop = (JProperty)name2prop.get(name);
        if (prop == null) {
          prop = declared ? clazz.addNewDeclaredProperty(name,methods[i],null) :
            clazz.addNewProperty(name,methods[i],null);
          name2prop.put(name,prop);
        } else {
          if (typ.equals(prop.getType())) {
            ((PropertyImpl)prop).setGetter(methods[i]); // cheater
          }
        }
      }

      //
      // process setters
      //
      if (name.startsWith("set") && name.length() > 3) {
        if (methods[i].getParameters().length != 1) continue; //1 param reqd
        JClass type = methods[i].getParameters()[0].getType();
        name = name.substring(3);
        JProperty prop = (JProperty)name2prop.get(name);
        if (prop == null) {
          prop = declared ? clazz.addNewDeclaredProperty(name,null,methods[i]) :
            clazz.addNewProperty(name,null,methods[i]);
          name2prop.put(name,prop);
        } else {
          if (type.equals(prop.getType())) {
            // if it's the same type, cool - just add the getter
            ((PropertyImpl)prop).setSetter(methods[i]); // with a sneaky cast
          }
        }
      }
View Full Code Here

            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();
View Full Code Here

                beanExcludeInfo = axisService.getExcludeInfo().getBeanExcludeInfoForClass(
                        jClass.getQualifiedName());
            }
            // properties from JAM
            ArrayList propertyList = new ArrayList();
            JProperty properties [] = jClass.getDeclaredProperties();
            for (int i = 0; i < properties.length; i++) {
                JProperty property = properties[i];
                String propertyName = getCorrectName(property.getSimpleName());
                if ((beanExcludeInfo == null) || !beanExcludeInfo.isExcludedProperty(propertyName)){
                    propertyList.add(property);
                }

            }
            JClass supClass = jClass.getSuperclass();
            while (!supClass.getQualifiedName().startsWith("java.")) {
                properties = supClass.getDeclaredProperties();
                ExcludeInfo excludeInfo = axisService.getExcludeInfo();
                if (excludeInfo != null) {
                    beanExcludeInfo = excludeInfo.getBeanExcludeInfoForClass(supClass.getQualifiedName());
                }
                for (int i = 0; i < properties.length; i++) {
                    JProperty property = properties[i];
                    String propertyName = getCorrectName(property.getSimpleName());
                    if ((beanExcludeInfo == null) || !beanExcludeInfo.isExcludedProperty(propertyName)) {
                        propertyList.add(property);
                    }
                }
                supClass = supClass.getSuperclass();
            }
            properties = new JProperty[propertyList.size()];
            for (int i = 0; i < propertyList.size(); i++) {
                JProperty jProperty = (JProperty)propertyList.get(i);
                properties[i] = jProperty;
            }
            Arrays.sort(properties);
            BeanInfo beanInfo = Introspector.getBeanInfo(beanObject.getClass());
            PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
            HashMap propertMap = new HashMap();
            for (int i = 0; i < propDescs.length; i++) {
                PropertyDescriptor propDesc = propDescs[i];
                if (propDesc.getName().equals("class")) {
                    continue;
                }
                propertMap.put(propDesc.getName(), propDesc);
            }
            ArrayList object = new ArrayList();
            for (int i = 0; i < properties.length; i++) {
                JProperty property = properties[i];
                PropertyDescriptor propDesc = (PropertyDescriptor)propertMap.get(
                        getCorrectName(property.getSimpleName()));
                if (propDesc == null) {
                    propDesc = (PropertyDescriptor)propertMap.get(
                        (property.getSimpleName()));
                }
                 if (propDesc == null) {
                    continue;
                }
                Class ptype = propDesc.getPropertyType();
                if (propDesc.getName().equals("class")) {
                    continue;
                }
                if (SimpleTypeMapper.isSimpleType(ptype)) {
                    Method readMethod = propDesc.getReadMethod();
                    Object value;
                    if(readMethod!=null){
                        if (property.getGetter() !=null && property.getGetter().isPublic()){
                            readMethod.setAccessible(true);
                        }
                        value = readMethod.invoke(beanObject, null);
                    } else {
                        throw new AxisFault("can not find read method for : "  + propDesc.getName());
                    }

                    addTypeQname(elemntNameSpace, object, propDesc, beanName,processingDocLitBare);
                    object.add(value == null ? null : SimpleTypeMapper.getStringValue(value));
                } else if (ptype.isArray()) {
                    if (SimpleTypeMapper.isSimpleType(ptype.getComponentType())) {
                        Method readMethod = propDesc.getReadMethod();
                        Object value;
                        if(readMethod!=null){
                            if (property.getGetter() !=null && property.getGetter().isPublic()){
                                readMethod.setAccessible(true);
                            }
                            value = readMethod.invoke(beanObject,null);
                        } else {
                            throw new AxisFault("can not find read method for : "  + propDesc.getName());
                        }
                        if (value != null) {
                            if("byte".equals(ptype.getComponentType().getName())) {
                                addTypeQname(elemntNameSpace, object, propDesc, beanName,processingDocLitBare);
                                object.add(Base64.encode((byte[]) value));
                            } else {
                                int i1 = Array.getLength(value);
                                for (int j = 0; j < i1; j++) {
                                    Object o = Array.get(value, j);
                                    addTypeQname(elemntNameSpace, object, propDesc, beanName,processingDocLitBare);
                                    object.add(o == null ? null : SimpleTypeMapper.getStringValue(o));
                                }
                            }
                        } else {
                            addTypeQname(elemntNameSpace, object, propDesc, beanName,processingDocLitBare);
                            object.add(value);
                        }
                    } else {
                        Method readMethod = propDesc.getReadMethod();
                        Object value [] = null;
                        if(readMethod!=null){
                            if (property.getGetter() !=null && property.getGetter().isPublic()){
                                readMethod.setAccessible(true);
                            }
                            value = (Object[])propDesc.getReadMethod().invoke(beanObject,
                                    null);
                        }

                        if (value != null) {
                            for (int j = 0; j < value.length; j++) {
                                Object o = value[j];
                                addTypeQname(elemntNameSpace, object, propDesc, beanName,processingDocLitBare);
                                object.add(o);
                            }
                        } else {
                            addTypeQname(elemntNameSpace, object, propDesc, beanName,processingDocLitBare);
                            object.add(value);
                        }
                    }
                } else if (SimpleTypeMapper.isCollection(ptype)) {
                    Method readMethod = propDesc.getReadMethod();
                    if (property.getGetter() !=null && property.getGetter().isPublic()){
                        readMethod.setAccessible(true);
                    }
                    Object value = readMethod.invoke(beanObject,
                                                                   null);
                    Collection objList = (Collection)value;
                    if (objList != null && objList.size() > 0) {
                        //this was given error , when the array.size = 0
                        // and if the array contain simple type , then the ADBPullParser asked
                        // PullParser from That simpel type
                        for (Iterator j = objList.iterator(); j.hasNext();) {
                            Object o = j.next();
                            if (SimpleTypeMapper.isSimpleType(o)) {
                                addTypeQname(elemntNameSpace, object, propDesc, beanName,processingDocLitBare);
                                object.add(o);
                            } else {
                                addTypeQname(elemntNameSpace, object, propDesc, beanName ,processingDocLitBare);
                                object.add(o);
                            }
                        }

                    } else {
                        addTypeQname(elemntNameSpace, object, propDesc, beanName,processingDocLitBare);
                        object.add(value);
                    }
                } else {
                    addTypeQname(elemntNameSpace, object, propDesc, beanName,processingDocLitBare);
                    Method readMethod = propDesc.getReadMethod();
                    if (property.getGetter() !=null && property.getGetter().isPublic()){
                        readMethod.setAccessible(true);
                    }
                    Object value = readMethod.invoke(beanObject,
                            null);
                    if ("java.lang.Object".equals(ptype.getName())){
View Full Code Here

                beanExcludeInfo = service.getExcludeInfo().getBeanExcludeInfoForClass(
                        javaType.getQualifiedName());
            }
            JProperty[] tempProperties = javaType.getDeclaredProperties();
            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();
View Full Code Here

            //  typeTable.addComplexScheam(name, complexType.getQName());
            typeTable.addComplexScheam(name, eltOuter.getQName());

            JProperty [] properties = javaType.getDeclaredProperties();
            for (int i = 0; i < properties.length; i++) {
                JProperty property = properties[i];
                String propertyName = property.getType().getQualifiedName();
                boolean isArryType = property.getType().isArrayType();
                if (isArryType) {
                    propertyName = property.getType().getArrayComponentType().getQualifiedName();
                }
                if (typeTable.isSimpleType(propertyName)) {
                    XmlSchemaElement elt1 = new XmlSchemaElement();
                    elt1.setName(property.getSimpleName());
                    elt1.setSchemaTypeName(typeTable.getSimpleSchemaTypeName(propertyName));
                    sequence.getItems().add(elt1);
                    if (isArryType) {
                        elt1.setMaxOccurs(Long.MAX_VALUE);
//                        elt1.setMinOccurs(2);
                    }
                } else {
                    if (isArryType) {
                        generateSchema(property.getType().getArrayComponentType());
                    } else {
                        generateSchema(property.getType());
                    }
                    XmlSchemaElement elt1 = new XmlSchemaElement();
                    elt1.setName(property.getSimpleName());
                    elt1.setSchemaTypeName(typeTable.getComplexScheamType(propertyName));
                    sequence.getItems().add(elt1);
                    if (isArryType) {
                        elt1.setMaxOccurs(Long.MAX_VALUE);
                    }
View Full Code Here

TOP

Related Classes of org.codehaus.jam.JProperty

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.