Package com.sun.tools.xjc.model

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


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


        CClassInfoParent scope;
        if(type.isGlobal())
            scope = new CClassInfoParent.Package(getClassSelector().getPackage(type.getTargetNamespace()));
        else
            scope = getClassSelector().getClassScope();
        CEnumLeafInfo xducer = new CEnumLeafInfo( model, BGMBuilder.getName(type), scope,
            className, baseDt, memberList, type,
            builder.getBindInfo(type).toCustomizationList(), loc );
        xducer.javadoc = javadoc;

        BIConversion conv = new BIConversion.Static( type.getLocator(),xducer);
View Full Code Here

        };
    }

    private void generateEnumBody(EnumOutline eo) {
        JDefinedClass type = eo.clazz;
        CEnumLeafInfo e = eo.target;

        XmlTypeWriter xtw = type.annotate2(XmlTypeWriter.class);
        writeTypeName(e.getTypeName(), xtw,
                eo._package().getMostUsedNamespaceURI());

        JCodeModel codeModel = model.codeModel;

        // since constant values are never null, no point in using the boxed types.
        JType baseExposedType = e.base.toType(this, EXPOSED).unboxify();
        JType baseImplType = e.base.toType(this,Aspect.IMPLEMENTATION).unboxify();


        XmlEnumWriter xew = type.annotate2(XmlEnumWriter.class);
        xew.value(baseExposedType);
       

        boolean needsValue = e.needsValueField();

        // for each member <m>,
        // [RESULT]
        //    <EnumName>(<deserializer of m>(<value>));

        Set<String> enumFieldNames = new HashSet<String>();    // record generated field names to detect collision

        for( CEnumConstant mem : e.members ) {
            String constName = mem.getName();

            if(!JJavaName.isJavaIdentifier(constName)) {
                // didn't produce a name.
                getErrorReceiver().error( e.getLocator(),
                    Messages.ERR_UNUSABLE_NAME.format(mem.getLexicalValue(), constName ) );
            }

            if( !enumFieldNames.add(constName) )
                getErrorReceiver().error( e.getLocator(), Messages.ERR_NAME_COLLISION.format(constName));

            // [RESULT]
            // <Const>(...)
            // ASSUMPTION: datatype is outline-independent
            JEnumConstant constRef = type.enumConstant(constName);
View Full Code Here

                    TypeUse use = lib.get(vp.getType());
                    if(use instanceof CNonElement)
                        base = (CNonElement)use;
                }

                CEnumLeafInfo xducer = new CEnumLeafInfo(model, null,
                        new CClassInfoParent.Package(pkg), def.getName(), base,
                        new ArrayList<CEnumConstant>(members),
                        null, null/*TODO*/, cp.getLocation());

                classes.put(cp,new CTypeInfo[]{xducer});
View Full Code Here

    /** Creates a global enumeration declaration. */
    static BIEnumeration create( Element dom, BindInfo parent ) {
        // create a class in the target package.
        return new BIEnumeration(
            dom,
            new CEnumLeafInfo(
                parent.model,
                null,
                new CClassInfoParent.Package(parent.getTargetPackage()),
                DOMUtil.getAttribute(dom,"name"),
                CBuiltinLeafInfo.STRING,
View Full Code Here

    /** Creates an element-local enumeration declaration. */
    static BIEnumeration create( Element dom, BIElement parent ) {
        // create a class as a nested class
        return new BIEnumeration(
            dom,
            new CEnumLeafInfo(
                parent.parent.model,
                null,
                parent.clazz,
                DOMUtil.getAttribute(dom,"name"),
                CBuiltinLeafInfo.STRING,
View Full Code Here

        CClassInfoParent scope;
        if(type.isGlobal())
            scope = new CClassInfoParent.Package(getClassSelector().getPackage(type.getTargetNamespace()));
        else
            scope = getClassSelector().getClassScope();
        CEnumLeafInfo xducer = new CEnumLeafInfo( model, BGMBuilder.getName(type), scope,
            className, baseDt, memberList, type,
            builder.getBindInfo(type).toCustomizationList(), loc );
        xducer.javadoc = javadoc;

        BIConversion conv = new BIConversion.Static( type.getLocator(),xducer);
View Full Code Here

        };
    }

    private void generateEnumBody(EnumOutline eo) {
        JDefinedClass type = eo.clazz;
        CEnumLeafInfo e = eo.target;

        XmlTypeWriter xtw = type.annotate2(XmlTypeWriter.class);
        writeTypeName(e.getTypeName(), xtw,
                eo._package().getMostUsedNamespaceURI());

        JCodeModel codeModel = model.codeModel;

        // since constant values are never null, no point in using the boxed types.
        JType baseExposedType = e.base.toType(this, EXPOSED).unboxify();
        JType baseImplType = e.base.toType(this,Aspect.IMPLEMENTATION).unboxify();


        XmlEnumWriter xew = type.annotate2(XmlEnumWriter.class);
        xew.value(baseExposedType);
       

        boolean needsValue = e.needsValueField();

        // for each member <m>,
        // [RESULT]
        //    <EnumName>(<deserializer of m>(<value>));

        Set<String> enumFieldNames = new HashSet<String>();    // record generated field names to detect collision

        for( CEnumConstant mem : e.members ) {
            String constName = mem.getName();

            if(!JJavaName.isJavaIdentifier(constName)) {
                // didn't produce a name.
                getErrorReceiver().error( e.getLocator(),
                    Messages.ERR_UNUSABLE_NAME.format(mem.getLexicalValue(), constName ) );
            }

            if( !enumFieldNames.add(constName) )
                getErrorReceiver().error( e.getLocator(), Messages.ERR_NAME_COLLISION.format(constName));

            // [RESULT]
            // <Const>(...)
            // ASSUMPTION: datatype is outline-independent
            JEnumConstant constRef = type.enumConstant(constName);
View Full Code Here

        CClassInfoParent scope;
        if(type.isGlobal())
            scope = new CClassInfoParent.Package(getClassSelector().getPackage(type.getTargetNamespace()));
        else
            scope = getClassSelector().getClassScope();
        CEnumLeafInfo xducer = new CEnumLeafInfo( model, BGMBuilder.getName(type), scope,
            className, baseDt, memberList, type,
            builder.getBindInfo(type).toCustomizationList(), loc );
        xducer.javadoc = javadoc;

        BIConversion conv = new BIConversion.Static( type.getLocator(),xducer);
View Full Code Here

    /** Creates a global enumeration declaration. */
    static BIEnumeration create( Element dom, BindInfo parent ) {
        // create a class in the target package.
        return new BIEnumeration(
            dom,
            new CEnumLeafInfo(
                parent.model,
                null,
                new CClassInfoParent.Package(parent.getTargetPackage()),
                DOMUtil.getAttribute(dom,"name"),
                CBuiltinLeafInfo.STRING,
View Full Code Here

TOP

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

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.