Package com.sun.tools.xjc.model

Examples of com.sun.tools.xjc.model.CClassInfo



  public static void findSubclasses(final CClassInfo cc, final ArrayList<CClassInfo> listSubclasses) {
    final Iterator<CClassInfo> subclasses = cc.listSubclasses();
    while (subclasses.hasNext()) {
      final CClassInfo s = subclasses.next();
      if (s.isAbstract()) {
        findSubclasses(s, listSubclasses);
        continue;
      }
      listSubclasses.add(s);
    }
View Full Code Here


  private final List<Command> mCommand = new ArrayList<Command>();

  @Override
  public void postProcessModel(final Model model, final ErrorHandler errorHandler) {
    JPackage mainPackage = null;
    CClassInfo classLink = null;
    CEnumLeafInfo altitudeModeKML = null;
    CEnumLeafInfo altitudeModeGX = null;

    for (final CClassInfo classInfo : model.beans().values()) {
      if (classInfo.shortName.equals("Kml")) {
        LOG.info("Found KML package: " + classInfo.getOwnerPackage().name());
        mainPackage = classInfo.getOwnerPackage();
        break;
      }
    }

    for (final CClassInfo classInfo : model.beans().values()) {
      if (classInfo.shortName.equals("Link") && classInfo.getOwnerPackage().name().equals(mainPackage.name())) {
        classLink = classInfo;
//        for (iterable_type iterable_element : classLink.getProperties()) {
//         
//        }
        Util.logInfo("Found Link class, prepare creation of Icon class");
        break;
      }
    }
   
    for (final CClassInfo classInfo : model.beans().values()) {
      if (classInfo.fullName().equals(PACKAGE_GX + ".TourPrimitive") && !classInfo.isAbstract()) {
        classInfo.setAbstract();
        LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " Found gxTourPrimtive class, set abstract!");
        break;
      }
    }
   
//    for (final CClassInfo classInfo : model.beans().values()) {
//      LOG.info("++++++ " + classInfo.fullName());
//      for (CPropertyInfo p : classInfo.getProperties()) {
//        String fullName = p.baseType.fullName();
//        LOG.info("++++++ " + fullName);
//      }
//    }
//   
//    for (CClassInfo classInfo : model.beans().values()) {
//      if (classInfo.fullName().equals(PACKAGE_GX + ".Playlist")) {
//        LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " Found Playlist class!");
//        List<CPropertyInfo> properties = classInfo.getProperties();
//        for (CPropertyInfo cPropertyInfo : properties) {
//          LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " > " + cPropertyInfo.kind(). + " " + cPropertyInfo.getName(true));
//        }
//        break;
//      }
//    }

    for (final CEnumLeafInfo classInfo : model.enums().values()) {
      if (classInfo.fullName().equals(PACKAGE_KML + ".AltitudeMode")) {
        altitudeModeKML = classInfo;
        LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " Found AltitudeMode in KML package");
        continue;
      }
      if (classInfo.fullName().equals(PACKAGE_GX + ".AltitudeMode")) {
        altitudeModeGX = classInfo;
        LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " Found AltitudeMode in GX package");
        continue;
      }
     
     
    }
    assert mainPackage != null;
    assert classLink != null;
    assert altitudeModeKML != null;
    assert altitudeModeGX != null;
    final CBuiltinLeafInfo doubleValue = CBuiltinLeafInfo.DOUBLE;

    final XSSchema schema = model.schemaComponent.getSchema("http://www.opengis.net/kml/2.2");

    LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " -------Icon properties ------------------");
    final CClassInfoParent cClassInfoParentLink = classLink.parent();

    final CClassInfo iconClass = new CClassInfo(model, cClassInfoParentLink, "Icon", null, new QName("Icon"), null, schema, new CCustomizations());
    iconClass.setBaseClass(classLink.getBaseClass());

    //fill icon class with the properties defined in link class
    final List<CPropertyInfo> properties = classLink.getProperties();
    for (final CPropertyInfo c : properties) {
      iconClass.addProperty(c);
    }
   
    final Collection<CEnumConstant> constants = altitudeModeGX.getConstants();
    for (final CEnumConstant cEnumConstant : constants) {
      altitudeModeKML.members.add( new CEnumConstant(cEnumConstant.getName(), null, cEnumConstant.getLexicalValue(), null, null, null));
    }
   
    //model.enums().remove(altitudeModeGX.fullName());
   
//    altitudeModeKML.javadoc
    final Collection<CEnumConstant> constantsKML = altitudeModeKML.getConstants();
    for (final CEnumConstant cEnumConstant : constantsKML) {
      LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " altitudeMode property: " + cEnumConstant.getLexicalValue());
    }
   
//    altitudeModeGX.parent.getOwnerPackage().remove(altitudeModeGX.);
   
   
    final QName qNameCoordinate = new QName("http://www.opengis.net/kml/2.2", "Coordinate");
    final QName qNameLongitude = new QName("PerlPleaseRemoveMeLongitude");
    final QName qNameLatitude = new QName("PerlPleaseRemoveMeLatitude");
    final QName qNameAltitude = new QName("PerlPleaseRemoveMeAltitude");
    final CClassInfo cc4 = new CClassInfo(model, cClassInfoParentLink, "Coordinate", null, qNameCoordinate, null, schema, new CCustomizations());

    //LOG.info(":::::::::::::::::::::::::::::::::: " + doubleValue.getType().fullName());

    final CAttributePropertyInfo cAttributeLongitude = new CAttributePropertyInfo("longitude", null, new CCustomizations(), null, qNameLongitude,
        doubleValue, null, false);
    final CAttributePropertyInfo cAttributeLatitude = new CAttributePropertyInfo("latitude", null, null, null, qNameLatitude, doubleValue, null,
        false);
    final CAttributePropertyInfo cAttributeAltitude = new CAttributePropertyInfo("altitude", null, new CCustomizations(), null, qNameAltitude,
        doubleValue, null, false);

    cc4.addProperty(cAttributeLongitude);
    cc4.addProperty(cAttributeLatitude);
    cc4.addProperty(cAttributeAltitude);
  }
View Full Code Here

    if (implClass.fields().isEmpty()) {
      return;
    }

    final CClassInfo target = classOutline.target;
    final ArrayList<String> props = new ArrayList<String>();
    if (target.isOrdered()) {
      for (final CPropertyInfo p : target.getProperties()) {
        if (!(p instanceof CAttributePropertyInfo)) {
          if (!((p instanceof CReferencePropertyInfo) && ((CReferencePropertyInfo) p).isDummy())) {
            props.add(p.getName(false));
          }
        }
View Full Code Here

     * Returns the super class of this class, if it has the
     * super class and it is also a JAXB-bound class.
     * Otherwise null.
     */
    public final ClassOutline getSuperClass() {
        CClassInfo s = target.getBaseClass();
        if(s==null)     return null;
        return parent().getClazz(s);
    }
View Full Code Here

            }
        };


        for (ClassOutlineImpl co : classes) {
            CClassInfo ci = co.target;
            countURI(uriCountMap, ci.getTypeName());
            countURI(uriCountMap, ci.getElementName());

            for( CPropertyInfo p : ci.getProperties() )
                p.accept(propVisitor);
        }
        mostUsedNamespaceURI = getMostUsedURI(uriCountMap);
        elementFormDefault = getFormDefault();
View Full Code Here

        // inheritance relationship needs to be set before we generate fields, or otherwise
        // we'll fail to compute the correct type signature (namely the common base type computation)
        for( ClassOutlineImpl cc : getClasses() ) {

            // setup inheritance between implementation hierarchy.
            CClassInfo superClass = cc.target.getBaseClass();
            if(superClass!=null) {
                // use the specified super class
                model.strategy._extends(cc,getClazz(superClass));
            } else {
                CClassRef refSuperClass = cc.target.getRefBaseClass();
View Full Code Here

    /**
     * Generates the body of a class.
     *
     */
    private void generateClassBody( ClassOutlineImpl cc ) {
        CClassInfo target = cc.target;

        // if serialization support is turned on, generate
        // [RESULT]
        // class ... implements Serializable {
        //     private static final long serialVersionUID = <id>;
        //     ....
        // }
        if( model.serializable ) {
            cc.implClass._implements(Serializable.class);
            if( model.serialVersionUID!=null ) {
                cc.implClass.field(
                    JMod.PRIVATE|JMod.STATIC|JMod.FINAL,
                    codeModel.LONG,
                    "serialVersionUID",
                    JExpr.lit(model.serialVersionUID));
            }
        }

        // used to simplify the generated annotations
        String mostUsedNamespaceURI = cc._package().getMostUsedNamespaceURI();

        // [RESULT]
        // @XmlType(name="foo", targetNamespace="bar://baz")
        XmlTypeWriter xtw = cc.implClass.annotate2(XmlTypeWriter.class);
        writeTypeName(cc.target.getTypeName(), xtw, mostUsedNamespaceURI);

        if(model.options.target.isLaterThan(SpecVersion.V2_1)) {
            // @XmlSeeAlso
            Iterator<CClassInfo> subclasses = cc.target.listSubclasses();
            if(subclasses.hasNext()) {
                XmlSeeAlsoWriter saw = cc.implClass.annotate2(XmlSeeAlsoWriter.class);
                while (subclasses.hasNext()) {
                    CClassInfo s = subclasses.next();
                    saw.value(getClazz(s).implRef);
                }
            }
        }

View Full Code Here

        }

        String name = name();
        QName tagName = new QName("",name);

        this.clazz = new CClassInfo(parent.model,parent.getTargetPackage(),className,getLocation(),null,tagName,null,null/*TODO*/);
    }
View Full Code Here

        void build() {
            if(!(this.bean instanceof CClassInfo))
                return; // no need to "build"

            CClassInfo bean = (CClassInfo)this.bean;

            if(!built.add(bean))
                return; // already built

            for( String reservedClassName : reservedClassNames ) {
                if( bean.getName().equals(reservedClassName) ) {
                    getErrorReporter().error( sc.getLocator(),
                        Messages.ERR_RESERVED_CLASS_NAME, reservedClassName );
                    break;
                }
            }

            // if this schema component is an element declaration
            // and it satisfies a set of conditions specified in the spec,
            // this class will receive a constructor.
            if(needValueConstructor(sc)) {
                // TODO: fragile. There is no guarantee that the property name
                // is in fact "value".
                bean.addConstructor("value");
            }

            if(bean.javadoc==null)
                addSchemaFragmentJavadoc(bean,sc);

            // build the body
            if(builder.getGlobalBinding().getFlattenClasses()==LocalScoping.NESTED)
                pushClassScope(bean);
            else
                pushClassScope(bean.parent());
            XSComponent oldRoot = currentRoot;
            CClassInfo oldBean = currentBean;
            currentRoot = sc;
            currentBean = bean;
            sc.visit(Ring.get(BindRed.class));
            currentBean = oldBean;
            currentRoot = oldRoot;
View Full Code Here

    private CClassInfo createDefaultClass() {
        String className = owner.model.getNameConverter().toClassName(name);
        QName tagName = new QName("",name);

        return new CClassInfo(owner.model,owner.getTargetPackage(),className,locator,null,tagName,null,null/*TODO*/);
    }
View Full Code Here

TOP

Related Classes of com.sun.tools.xjc.model.CClassInfo

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.