Package com.sun.codemodel

Examples of com.sun.codemodel.JMethod.body()


    if (mods == JMod.PRIVATE) {
      defaultConstructor.annotate(Deprecated.class);
      defaultConstructor.javadoc().add("Default no-arg constructor is private. Use overloaded constructor instead! ");
      defaultConstructor.javadoc().add("(Temporary solution, till a better and more suitable ObjectFactory is created.) ");
    }
    defaultConstructor.body().invoke("super");
  }

  private void createArgConstructor(final ClassOutlineImpl cc, final Collection<JFieldVar> required) {
    final StringBuffer debugOut = new StringBuffer();
    final Map<String, FieldOutline> fieldOutlineasMap = Util.getRequiredFieldsAsMap(cc);
View Full Code Here


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

    final StringBuffer debugOut = new StringBuffer();
    final Map<String, FieldOutline> fieldOutlineasMap = Util.getRequiredFieldsAsMap(cc);

    final JMethod defaultConstructor = cc.implClass.constructor(JMod.PUBLIC);
    defaultConstructor.javadoc().add("Value constructor with only mandatory fields");
    defaultConstructor.body().invoke("super");

    for (final JFieldVar field : required) {
      // FieldOutline fo = fieldOutlineasMap.get(field.name());
      // if (fo == null) {
      // continue;
View Full Code Here

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

      // continue;
      // }

      final JVar arg = defaultConstructor.param(JMod.FINAL, Util.removeJAXBElement(cm, field.type()), field.name());
      defaultConstructor.javadoc().addParam(arg).append("required parameter");
      defaultConstructor.body().assign(JExpr.refthis(field.name()), arg);
    }

    debugOut.append("c> " + cc.implRef.name() + " :: public " + cc.target.shortName + "(");
    for (final JFieldVar field : required) {
      debugOut.append(field.type().name() + ", ");
View Full Code Here

    for (final JFieldVar jFieldVar : fields) {
      LOG.info("!!!!!!!!!!!!!!!!!!!!! " + jFieldVar.name());
    }

   
    toString.body()._return(JExpr.lit("null"));
  }

  /*
   * check if a superclass exist and if it defines some hashCode- and equals-worthy fields
   */
 
View Full Code Here

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

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

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

      jaxbElementClass = codeModel.ref(ArrayList.class).narrow(annotateCoordinates);
    }
    // cClassInfo
    final String createAndSetCoordinatesName = "createAndSetCoordinates";
    final JMethod m = implClass.method(JMod.PUBLIC, fieldVar.type(), createAndSetCoordinatesName);
    final JVar newValue = m.body().decl(fieldVar.type(), "newValue", JExpr._new(jaxbElementClass));
    final JInvocation methodInvoke = JExpr._this().invoke("set" + Util.upperFirst(fieldVar.name())).arg(newValue);
    m.body().add(methodInvoke);
    m.body()._return(newValue);

    m.javadoc().append("Creates a new instance of ");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.