Package com.sun.codemodel

Examples of com.sun.codemodel.JFieldVar


                }

               
                if (xsType != null && xsType.isComplexType() && containsDefaultValue(outline, f)) {
                    String varName = f.getPropertyInfo().getName(false);
                    JFieldVar var = co.implClass.fields().get(varName);
                    if (var != null) {
                        co.implClass.removeField(var);

                        JFieldVar newVar = co.implClass.field(var.mods().getValue(),
                                                              var.type(),
                                                              var.name(),
                                                              JExpr._new(f.getRawType()));
                        newVar.javadoc().append(var.javadoc());
                    }
                }

                JExpression dvExpr = null;
                if (null != xmlDefaultValue && null != xmlDefaultValue.value) {
View Full Code Here


                }

               
                if (xsType != null && xsType.isComplexType() && containsDefaultValue(outline, f)) {
                    String varName = f.getPropertyInfo().getName(false);
                    JFieldVar var = co.implClass.fields().get(varName);
                    if (var != null) {
                        co.implClass.removeField(var);

                        JFieldVar newVar = co.implClass.field(var.mods().getValue(),
                                                              var.type(),
                                                              var.name(),
                                                              JExpr._new(f.getRawType()));
                        newVar.javadoc().append(var.javadoc());
                    }
                }

                JExpression dvExpr = null;
                if (null != xmlDefaultValue && null != xmlDefaultValue.value) {
View Full Code Here

        if (!(fo instanceof UntypedListField)) {
          continue;
        }
      }
     
      final JFieldVar var = fields.get(fo.getPropertyInfo().getName(false));
      if (var == null) {
        continue;
      }
      if (!isRelevantField(var)) {
        continue;
View Full Code Here

        if (isFieldMarkedAsRequiredOrMandatoryInXSDSchema(fo)) {
          continue;
        }
      }
     
      final JFieldVar var = fields.get(fo.getPropertyInfo().getName(false));
      if (var == null) {
        continue;
      }
      if (!isRelevantField(var)) {
        continue;
View Full Code Here

    final Collection<JFieldVar> fieldList = new ArrayList<JFieldVar>();
    for (final FieldOutline fo : classOutline.getDeclaredFields()) {
      if (!isFieldMarkedAsRequiredOrMandatoryInXSDSchema(fo)) {
        continue;
      }
      final JFieldVar var = fields.get(fo.getPropertyInfo().getName(false));
      if (var == null) {
        continue;
      }

      if (!isRelevantField(var)) {
View Full Code Here

    final Map<String, FieldOutline> fieldList = new HashMap<String, FieldOutline>();
    for (final FieldOutline fo : classOutline.getDeclaredFields()) {
      if (!isFieldMarkedAsRequiredOrMandatoryInXSDSchema(fo)) {
        continue;
      }
      final JFieldVar var = fields.get(fo.getPropertyInfo().getName(false));
      if (var == null) {
        continue;
      }

      if (!isRelevantField(var)) {
        continue;
      }
      fieldList.put(var.name(), fo);
    }
    return fieldList;
  }
View Full Code Here

    if (classOutline.implClass.fullName().equals(string)) {
      if (field == null) {
        classOutline.implClass.annotate(Deprecated.class);
        LOG.info("       1YY>>" + string);
      } else {
        final JFieldVar jFieldVar = classOutline.implClass.fields().get(field);
        jFieldVar.annotate(Deprecated.class);
        LOG.info("       1YY>>" + string + "#" + field);
      }
    }
  }
View Full Code Here

        if (fieldOutline instanceof FieldOutline) {
          final CPropertyInfo property = fieldOutline.getPropertyInfo();

          final JCodeModel codeModel = classOutline.parent().getCodeModel();

          final JFieldVar currentField = implClass.fields().get(property.getName(false));

          // LOG.info("fieldType: " + currentField.name());
          // find the common type
          final JType currentFieldType = TypeUtil
              .getCommonBaseType(codeModel, listPossibleTypes((ClassOutlineImpl) classOutline, property));
          String currentFieldTypeName = currentFieldType.name().trim().toLowerCase();
          // if found field-type equals object, then there is no need, to document it
          if (currentFieldTypeName.equals("object")) {
            continue;
          }
          currentFieldTypeName = eliminateTypeSuffix(currentFieldTypeName);
          final JaxbJavaDoc javadocForCurrentFieldName = kmlJavaDocElements.get(property.getName(false).trim().toLowerCase());
          if (javadocForCurrentFieldName != null) {
            // LOG.info("++C> " + currentFieldTypeName + " " + property.getName(false));
            currentField.javadoc().clear();
            currentField.javadoc().add(javadocForCurrentFieldName.getJavaDoc());
            continue;
          }

          final JaxbJavaDoc javadocForCurrentField = kmlJavaDocElements.get(currentFieldTypeName);
          if (javadocForCurrentField != null) {
            // LOG.info("+  > " + currentFieldTypeName + " " + property.getName(false));
            currentField.javadoc().clear();
            currentField.javadoc().add(javadocForCurrentField.getJavaDoc());
            continue;
          }
          // LOG.info("--C> " + currentFieldTypeName + " " + property.getName(false));
        }
      }
View Full Code Here

   
    final CodeModelClassFactory classFactory = outline.getClassFactory();
    final JPackage kmlpackage = Util.getKmlClassPackage(outline);
    namespaceFilterHandler = classFactory.createClass(kmlpackage, JMod.FINAL, "NamespaceFilterHandler", null, ClassType.CLASS);
    namespaceFilterHandler._implements(contentHandlerClass.boxify());
    final JFieldVar KML_20 = namespaceFilterHandler.field(JMod.PRIVATE | JMod.STATIC | JMod.FINAL, stringClass, "KML_20", JExpr.lit("http://earth.google.com/kml/2.0"));
    final JFieldVar KML_21 = namespaceFilterHandler.field(JMod.PRIVATE | JMod.STATIC | JMod.FINAL, stringClass, "KML_21", JExpr.lit("http://earth.google.com/kml/2.1"));
    final JFieldVar KML_22 = namespaceFilterHandler.field(JMod.PRIVATE | JMod.STATIC | JMod.FINAL, stringClass, "KML_22", JExpr.lit("http://www.opengis.net/kml/2.2"));
    final JFieldVar content = namespaceFilterHandler.field(JMod.PRIVATE, contentHandlerClass, "contentHandler");
    final JMethod constructor = namespaceFilterHandler.constructor(JMod.PUBLIC);
    final JVar constructorParam = constructor.param(contentHandlerClass, "contentHandler");
    constructor.body().assign(JExpr._this().ref(content), constructorParam);
   
    final JMethod startElement = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "startElement");
    startElement._throws(SAXException.class);
    final JVar uri = startElement.param(stringClass, "uri");
    final JVar localName = startElement.param(stringClass, "localName");
    final JVar qName = startElement.param(stringClass, "qName");
    final JVar atts = startElement.param(Attributes.class, "atts");
    final JConditional if1 = startElement.body()._if(uri.invoke("equals").arg(KML_20).cor(uri.invoke("equals").arg(KML_21)));
    if1._then().block().add(content.invoke("startElement").arg(KML_22).arg(localName).arg(qName).arg(atts));
    if1._else().block().add(content.invoke("startElement").arg(uri).arg(localName).arg(qName).arg(atts));
   
    final JMethod characters = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "characters");
    final JVar charCh = characters.param(cc.implClass.owner().CHAR.array(), "ch");
    final JVar charStart = characters.param(cc.implClass.owner().INT, "start");
    final JVar charLength = characters.param(cc.implClass.owner().INT, "length");
    characters._throws(saxExceptionClass.boxify());
    characters.body().add(content.invoke("characters").arg(charCh).arg(charStart).arg(charLength));
   
    final JMethod endDocument = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "endDocument");
    endDocument._throws(saxExceptionClass.boxify());
    endDocument.body().add(content.invoke("endDocument"));
   
    final JMethod endElement = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "endElement");
    final JVar endElementUri = endElement.param(stringClass, "uri");
    final JVar endElementLocalName = endElement.param(stringClass, "localName");
    final JVar endElementqName = endElement.param(stringClass, "qName");
    endElement._throws(saxExceptionClass.boxify());
    endElement.body().add(content.invoke("endElement").arg(endElementUri).arg(endElementLocalName).arg(endElementqName));
 
    final JMethod endPrefixMapping = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "endPrefixMapping");
    final JVar endPrefixMappingPrefix = endPrefixMapping.param(stringClass, "prefix");
    endPrefixMapping._throws(saxExceptionClass.boxify());
    endPrefixMapping.body().add(content.invoke("endPrefixMapping").arg(endPrefixMappingPrefix));
   
    final JMethod ignorableWhitespace = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "ignorableWhitespace");
    final JVar ignorableWhitespaceCh = ignorableWhitespace.param(cc.implClass.owner().CHAR.array(), "ch");
    final JVar ignorableWhitespaceStart = ignorableWhitespace.param(cc.implClass.owner().INT, "start");
    final JVar ignorableWhitespaceLength = ignorableWhitespace.param(cc.implClass.owner().INT, "length");
    ignorableWhitespace._throws(saxExceptionClass.boxify());
    ignorableWhitespace.body().add(content.invoke("ignorableWhitespace").arg(ignorableWhitespaceCh).arg(ignorableWhitespaceStart).arg(ignorableWhitespaceLength));
   
    final JMethod processingInstruction = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "processingInstruction");
    final JVar processingInstructionTarget = processingInstruction.param(stringClass, "target");
    final JVar processingInstructionData = processingInstruction.param(stringClass, "data");
    processingInstruction._throws(saxExceptionClass.boxify());
    processingInstruction.body().add(content.invoke("processingInstruction").arg(processingInstructionTarget).arg(processingInstructionData));
   
    final JMethod setDocumentLocator = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "setDocumentLocator");
    final JVar setDocumentLocatorLocator = setDocumentLocator.param(Locator.class, "locator");
    setDocumentLocator.body().add(content.invoke("setDocumentLocator").arg(setDocumentLocatorLocator));
   
    final JMethod skippedEntity = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "skippedEntity");
    final JVar skippedEntityName = skippedEntity.param(stringClass, "name");
    skippedEntity._throws(saxExceptionClass.boxify());
    skippedEntity.body().add(content.invoke("skippedEntity").arg(skippedEntityName));
   
    final JMethod startDocument = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "startDocument");
    startDocument._throws(saxExceptionClass.boxify());
    startDocument.body().add(content.invoke("startDocument"));
   
    final JMethod startPrefixMapping = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "startPrefixMapping");
    final JVar startPrefixMappingPrefix = startPrefixMapping.param(stringClass, "prefix");
    final JVar startPrefixMappingUri = startPrefixMapping.param(stringClass, "uri");
    startPrefixMapping._throws(saxExceptionClass.boxify());
    startPrefixMapping.body().add(content.invoke("startPrefixMapping").arg(startPrefixMappingPrefix).arg(startPrefixMappingUri));
 
    namespaceFilterXMLReaderclass = classFactory.createClass(kmlpackage, JMod.FINAL, "NamespaceFilterXMLReader", null, ClassType.CLASS);
    namespaceFilterXMLReaderclass._implements(xmlReaderClass.boxify());
    final JFieldVar xmlReader = namespaceFilterXMLReaderclass.field(JMod.PRIVATE, xmlReaderClass, "xmlReader");
    final JMethod namespaceFilterXMLReaderclassConstrutor = namespaceFilterXMLReaderclass.constructor(JMod.PUBLIC);
    final JVar paramValidate = namespaceFilterXMLReaderclassConstrutor.param(cc.implClass.owner().BOOLEAN, "validate");
    namespaceFilterXMLReaderclassConstrutor._throws(saxExceptionClass.boxify())._throws(parserConfigurationExceptionClass.boxify());
    final JVar parserFactory = namespaceFilterXMLReaderclassConstrutor.body().decl(saxParserFactoryClass, "parserFactory", saxParserFactoryClass.boxify().staticInvoke("newInstance"));
    namespaceFilterXMLReaderclassConstrutor.body().add(parserFactory.invoke("setNamespaceAware").arg(JExpr.TRUE));
    namespaceFilterXMLReaderclassConstrutor.body().add(parserFactory.invoke("setValidating").arg(paramValidate));
    namespaceFilterXMLReaderclassConstrutor.body().assign(xmlReader, parserFactory.invoke("newSAXParser").invoke("getXMLReader"));
   
    final JMethod getContentHandler = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, ContentHandler.class, "getContentHandler");
    getContentHandler.body()._return(xmlReader.invoke("getContentHandler"));
   
    final JMethod getDTDHandler = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, DTDHandler.class, "getDTDHandler");
    getDTDHandler.body()._return(xmlReader.invoke("getDTDHandler"));
   
    final JMethod getEntityResolver = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, EntityResolver.class, "getEntityResolver");
    getEntityResolver.body()._return(xmlReader.invoke("getEntityResolver"));
   
    final JMethod getErrorHandler = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, ErrorHandler.class, "getErrorHandler");
    getErrorHandler.body()._return(xmlReader.invoke("getErrorHandler"));
   
    final JMethod getFeature = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, cc.implClass.owner().BOOLEAN, "getFeature");
    final JVar getFeatureName = getFeature.param(stringClass, "name");
    getFeature._throws(SAXNotRecognizedException.class)._throws(SAXNotSupportedException.class);
    getFeature.body()._return(xmlReader.invoke("getFeature").arg(getFeatureName));
   
    final JMethod getProperty = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, Object.class, "getProperty");
    final JVar getPropertyName = getProperty.param(stringClass, "name");
    getProperty._throws(SAXNotRecognizedException.class)._throws(SAXNotSupportedException.class);
    getProperty.body()._return(xmlReader.invoke("getProperty").arg(getPropertyName));
   
    final JMethod parse = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, cc.implClass.owner().VOID, "parse");
    final JVar parseInput = parse.param(InputSource.class, "input");
    parse._throws(IOException.class)._throws(SAXException.class);
    parse.body().add(xmlReader.invoke("parse").arg(parseInput));
   
    final JMethod parse2 = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, cc.implClass.owner().VOID, "parse");
    final JVar parseSystemId = parse2.param(String.class, "systemId");
    parse2._throws(IOException.class)._throws(SAXException.class);
    parse2.body().add(xmlReader.invoke("parse").arg(parseSystemId));
   
    final JMethod setContentHandler = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, cc.implClass.owner().VOID, "setContentHandler");
    final JVar setContentHandlerHandler = setContentHandler.param(ContentHandler.class, "handler");
    setContentHandler.body().add(xmlReader.invoke("setContentHandler").arg(JExpr._new(namespaceFilterHandler).arg(setContentHandlerHandler)));
   
    final JMethod setDTDHandler = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, cc.implClass.owner().VOID, "setDTDHandler");
    final JVar setDTDHandlerHandler = setDTDHandler.param(DTDHandler.class, "handler");
    setDTDHandler.body().add(xmlReader.invoke("setDTDHandler").arg(setDTDHandlerHandler));
   
    final JMethod setEntityResolver = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, cc.implClass.owner().VOID, "setEntityResolver");
    final JVar setEntityResolverHandler = setEntityResolver.param(EntityResolver.class, "handler");
    setEntityResolver.body().add(xmlReader.invoke("setEntityResolver").arg(setEntityResolverHandler));
   
    final JMethod setErrorHandler = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, cc.implClass.owner().VOID, "setErrorHandler");
    final JVar setErrorHandlerHandler = setErrorHandler.param(ErrorHandler.class, "handler");
    setErrorHandler.body().add(xmlReader.invoke("setErrorHandler").arg(setErrorHandlerHandler));
   
    final JMethod setFeature = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, cc.implClass.owner().VOID, "setFeature");
    final JVar setFeatureName = setFeature.param(stringClass, "name");
    final JVar setFeatureValue = setFeature.param(cc.implClass.owner().BOOLEAN, "value");
    setFeature._throws(SAXNotRecognizedException.class)._throws(SAXNotSupportedException.class);
    setFeature.body().add(xmlReader.invoke("setFeature").arg(setFeatureName).arg(setFeatureValue));
   
    final JMethod setProperty = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, cc.implClass.owner().VOID, "setProperty");
    final JVar setPropertyName = setProperty.param(stringClass, "name");
    final JVar setPropertyValue = setProperty.param(Object.class, "value");
    setProperty._throws(SAXNotRecognizedException.class)._throws(SAXNotSupportedException.class);
    setProperty.body().add(xmlReader.invoke("setProperty").arg(setPropertyName).arg(setPropertyValue));
   
    generateHelperMethods(cc);
    generateMarshalMethods(cc);
    generateUnMarshalMethods(cc);
   
View Full Code Here

      return;
    }
    final String methodName = Util.calculateMethodName(cc, rootPackage);
    if (cc.implClass.name().equals("Coordinate")) {
      final Collection<JFieldVar> coordinateCreateMethods = new ArrayList<JFieldVar>();
      final JFieldVar longitude = cc.ref.fields().get("longitude");
      final JFieldVar latitude = cc.ref.fields().get("latitude");
     
     
      coordinateCreateMethods.add(longitude);
      coordinateCreateMethods.add(latitude);
      createArgFactoryMethod(cc, coordinateCreateMethods, sigType, methodName);
     
      final JFieldVar altitude = cc.ref.fields().get("altitude");
      coordinateCreateMethods.add(altitude);
      createArgFactoryMethod(cc, coordinateCreateMethods, sigType, methodName);
     
      coordinateCreateMethods.clear();
     
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JFieldVar

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.