Package com.sun.codemodel

Examples of com.sun.codemodel.JVar


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


    // out.closeEntry();
    // }
    //   
    createAddToKmzFile = cc.implClass.method(JMod.PRIVATE, cc.implClass.owner().VOID, "addKmzFile");
    createAddToKmzFile._throws(IOException.class);
    final JVar varKmzFile = createAddToKmzFile.param(kmlClass, "kmzFile");
    final JVar varOut = createAddToKmzFile.param(zipOutputStreamClass, "out");
    final JVar varMainFile = createAddToKmzFile.param(cc.implClass.owner().BOOLEAN, "mainfile");
    createAddToKmzFile.javadoc().add("Internal method");
    final JVar varFileName = createAddToKmzFile.body().decl(stringClass, "fileName", JExpr._null());
    final JConditional if1 = createAddToKmzFile.body()._if(
        varKmzFile.invoke("getFeature").eq(JExpr._null()).cor(varKmzFile.invoke("getFeature").invoke("getName").eq(JExpr._null())).cor(
            varKmzFile.invoke("getFeature").invoke("getName").invoke("length").eq(JExpr.lit(0))));
    if1._then().assign(varFileName, JExpr.lit("noFeatureNameSet").plus(varMissingNameCounter.incr()).plus(JExpr.lit(".kml")));
    if1._else().assign(varFileName, varKmzFile.invoke("getFeature").invoke("getName"));
    if1._else()._if(varFileName.invoke("endsWith").arg(".kml").not())._then().assignPlus(varFileName, JExpr.lit(".kml"));

    createAddToKmzFile.body()._if(varMainFile)._then().assign(varFileName, JExpr.lit("doc.kml"));
    createAddToKmzFile.body().add(
        varOut.invoke("putNextEntry").arg(
            JExpr._new(zipEntryClass).arg(UrlEncoderClass.boxify().staticInvoke("encode").arg(varFileName).arg(JExpr.lit("UTF-8")))));
View Full Code Here

    namespacebeautyfiergetpreferredprefix.javadoc().append("<p>namespaceUri: urn:oasis:names:tc:ciq:xsdschema:xAL:2.0 prefix: xal</p>");
    namespacebeautyfiergetpreferredprefix.javadoc().append("<p>namespaceUri: http://www.google.com/kml/ext/2.2        prefix: gx</p>");

    namespacebeautyfiergetpreferredprefix.javadoc().append("<p>namespaceUri: anything else prefix: null</p>");
    namespacebeautyfiergetpreferredprefix.javadoc().trimToSize();
    final JVar namespaceuri = namespacebeautyfiergetpreferredprefix.param(stringClass, "namespaceUri");
    namespacebeautyfiergetpreferredprefix.param(stringClass, "suggestion");
    namespacebeautyfiergetpreferredprefix.param(cc.implClass.owner().BOOLEAN, "requirePrefix");

    namespacebeautyfiergetpreferredprefix.body()._if(namespaceuri.invoke("matches").arg("http://www.w3.org/\\d{4}/Atom"))._then()._return(
        JExpr.lit("atom"));
    namespacebeautyfiergetpreferredprefix.body()._if(namespaceuri.invoke("matches").arg("urn:oasis:names:tc:ciq:xsdschema:xAL:.*?"))
        ._then()._return(JExpr.lit("xal"));
    namespacebeautyfiergetpreferredprefix.body()._if(namespaceuri.invoke("matches").arg("http://www.google.com/kml/ext/.*?"))._then()
    ._return(JExpr.lit("gx"));
    //namespacebeautyfiergetpreferredprefix.body()._if(namespaceuri.invoke("matches").arg("http://www.opengis.net/kml/.*?"))._then()
    //._return(JExpr.lit("kml"));
    namespacebeautyfiergetpreferredprefix.body()._return(JExpr._null());
    return namespacebeautyfier;
View Full Code Here

    comment.add("@see marshalKmz(String, Kml...)");
    final JMethod generateMarshallFilenameWithZIP = cc.implClass.method(JMod.PUBLIC, cc.implClass.owner().BOOLEAN, "marshal");
    generateMarshallFilenameWithZIP._throws(FileNotFoundException.class);
    generateMarshallFilenameWithZIP.javadoc().append(comment);

    final JVar filenameVar = generateMarshallFilenameWithZIP.param(JMod.FINAL, File.class, "filename");
    // final JVar zippedVar = generateMarshallFilenameWithZIP.param(JMod.FINAL, boolean.class, "zipped");
    final JVar outVar = generateMarshallFilenameWithZIP.body().decl(outputStreamClass, "out", JExpr._new(fileOutputStreamClass).arg(filenameVar));
    // final JConditional ifBlockFilename = generateMarshallFilenameWithZIP.body()._if(zippedVar.eq(JExpr.TRUE));
    // ifBlockFilename._then().assign(outVar, JExpr._new(zipOutputStreamClass).arg(outVar));
    generateMarshallFilenameWithZIP.body()._return(JExpr._this().invoke(generateMarshalOutputStream).arg(outVar));
    comment.clear();
View Full Code Here

    final JMethod generateMarshalOutputStream = cc.implClass.method(JMod.PUBLIC, cc.implClass.owner().BOOLEAN, "marshal");
    if (argumentType.equals(outputStreamClass)) {
      generateMarshalOutputStream._throws(FileNotFoundException.class);
    }
    generateMarshalOutputStream.javadoc().append(comment);
    final JVar value = generateMarshalOutputStream.param(JMod.FINAL, argumentType, argumentType.name().toLowerCase());

    // try {
    final JTryBlock tryBlock = generateMarshalOutputStream.body()._try();
    // m = this.createMarshaller();
    tryBlock.body().assign(mVar, JExpr._this().invoke(createMashaller));
View Full Code Here

    generateUnMarshallerFromString.javadoc().add("reads legacy kml files. \n");
    generateUnMarshallerFromString.javadoc().add("Supported are KML 2.0 (namespace: http://earth.google.com/kml/2.0) \n");
    generateUnMarshallerFromString.javadoc().add("          and KML 2.1 (namespace: http://earth.google.com/kml/2.1) \n");
    generateUnMarshallerFromString.javadoc().trimToSize();
   
    final JVar fileunmarshallVar = generateUnMarshallerFromString.param(JMod.FINAL, fileClass, "file");
    generateUnMarshallerFromString._throws(FileNotFoundException.class);
    final JTryBlock tryBlock = generateUnMarshallerFromString.body()._try();
    final JVar localUnmarshallerFile = tryBlock.body().decl(jaxbUnmarshallerClass, "unmarshaller",
        jaxbContextClass.boxify().staticInvoke("newInstance").arg(JExpr.direct("Kml.class")).invoke("createUnmarshaller"));
   
    final JVar inputsource = tryBlock.body().decl(inputsourceClass, "input", JExpr._new(inputsourceClass).arg(JExpr._new(fileReaderClass).arg(fileunmarshallVar)));
    final JVar saxsource = tryBlock.body().decl(saxsourceClass, "saxSource", JExpr._new(saxsourceClass).arg(JExpr._new(namespaceFilterXMLReaderclass).arg(JExpr.FALSE)).arg(inputsource));
    final JVar decl = tryBlock.body().decl(kmlClass, "jaxbRootElement", JExpr.cast(kmlClass, JExpr.invoke(localUnmarshallerFile, "unmarshal").arg(saxsource)));
    tryBlock.body()._return(decl);
    tryBlock._catch(saxExceptionClass.boxify()).body().directStatement("_x.printStackTrace();");
    tryBlock._catch(parserConfigurationExceptionClass.boxify()).body().directStatement("_x.printStackTrace();");
    tryBlock._catch(jaxbExceptionClass.boxify()).body().directStatement("_x.printStackTrace();");
    generateUnMarshallerFromString.body()._return(JExpr._null());
View Full Code Here

    final JMethod unmarshalFromKMZ = cc.implClass.method(JMod.PUBLIC | JMod.STATIC, kmlClass.array(), "unmarshalFromKmz");
    unmarshalFromKMZ.javadoc().add("KMZ to Java\n");
    unmarshalFromKMZ.javadoc().add("Similar to the other unmarshal methods\n\n");
    unmarshalFromKMZ.javadoc().add("with the exception that it transforms a KMZ-file into a graph of Java objects. \n")
    unmarshalFromKMZ._throws(IOException.class);
    final JVar varFile = unmarshalFromKMZ.param(fileClass, "file");
    varFile.annotate(NotNull.class);
    final JVar varEMPTY_KML_ARRAY = unmarshalFromKMZ.body().decl(kmlClass.array(), "EMPTY_KML_ARRAY", JExpr.direct("new Kml[0]"));// JExpr._new(kmlClass.array().)..arg("0"));
    unmarshalFromKMZ.body()._if(varFile.invoke("getName").invoke("endsWith").arg(".kmz").not())._then()._return(varEMPTY_KML_ARRAY);
    final JVar varZip = unmarshalFromKMZ.body().decl(zipFileClass, "zip",JExpr._new(zipFileClass).arg(varFile) );
    final JVar varEntries = unmarshalFromKMZ.body().decl(enumerationClass.boxify().narrow(zipEntryClass.boxify().wildcard()), "entries", varZip.invoke("entries"));
    unmarshalFromKMZ.body()._if(varFile.invoke("exists").not())._then()._return(varEMPTY_KML_ARRAY);
    final JVar varKmlFiles = unmarshalFromKMZ.body().decl(arrayListClass.boxify().narrow(kmlClass.boxify()), "kmlfiles", JExpr._new(arrayListClass.boxify().narrow(kmlClass.boxify())));
    final JBlock while1 = unmarshalFromKMZ.body()._while(varEntries.invoke("hasMoreElements")).body();
    final JVar varEntry = while1.decl(zipEntryClass, "entry",JExpr.cast(zipEntryClass, varEntries.invoke("nextElement")));
    while1._if(varEntry.invoke("getName").invoke("contains").arg("__MACOSX").cor(varEntry.invoke("getName").invoke("contains").arg(".DS_STORE")))._then()._continue();
    final JVar entryName = while1.decl(stringClass, "entryName", urlDecoderClass.boxify().staticInvoke("decode").arg(varEntry.invoke("getName")).arg("UTF-8"));
    while1._if(entryName.invoke("endsWith").arg(".kml").not())._then()._continue();
    final JVar varIn = while1.decl(inputStreamClass, "in", varZip.invoke("getInputStream").arg(varEntry));
    final JVar varUnmarshal = while1.decl(kmlClass, "unmarshal", kmlClass.boxify().staticInvoke("unmarshal").arg(varIn));
    while1.add(varKmlFiles.invoke("add").arg(varUnmarshal));
    unmarshalFromKMZ.body().add(varZip.invoke("close"));
    unmarshalFromKMZ.body()._return(varKmlFiles.invoke("toArray").arg(varEMPTY_KML_ARRAY));
   
//    JVar varOut = unmarshalFromKMZ.body().decl(zipEntryClass, "out", JExpr._new(zipOutputStreamClass).arg(varName));
View Full Code Here

    // out.close();
    // missingNameCounter = 1;
    // return false;
    // }
    final JMethod generateMarshalKmz = cc.implClass.method(JMod.PUBLIC, cc.implClass.owner().BOOLEAN, "marshalAsKmz");
    final JVar varName = generateMarshalKmz.param(stringClass, "name");
    varName.annotate(NotNull.class);
    final JVar varAdditionalFiles = generateMarshalKmz.varParam(kmlClass.boxify(), "additionalFiles");
    generateMarshalKmz._throws(IOException.class);
    final JVar varOut = generateMarshalKmz.body().decl(zipOutputStreamClass, "out", JExpr._new(zipOutputStreamClass).arg(JExpr._new(fileOutputStreamClass).arg(varName)));
    generateMarshalKmz.body().add(varOut.invoke("setComment").arg("KMZ-file created with Java API for KML. Visit us: http://code.google.com/p/javaapiforkml/"));
    generateMarshalKmz.body().add(JExpr._this().invoke(createAddToKmzFile).arg(JExpr._this()).arg(varOut).arg(JExpr.TRUE));
    final JForEach forEach = generateMarshalKmz.body().forEach(kmlClass, "kml", varAdditionalFiles);
    forEach.body().add(JExpr._this().invoke(createAddToKmzFile).arg(forEach.var()).arg(varOut).arg(JExpr.FALSE));
    generateMarshalKmz.body().add(varOut.invoke("close"));
    generateMarshalKmz.body().assign(varMissingNameCounter,JExpr.lit(1));
    generateMarshalKmz.body()._return(JExpr.FALSE);
  }
View Full Code Here

    generateUnMarshallerFromString.javadoc().add("KML to Java\n");
    generateUnMarshallerFromString.javadoc().add("Similar to the other unmarshal methods \n\n");
    generateUnMarshallerFromString.javadoc().add(
        "with the exception that it transforms a " + invokeMarshalWith.name() + " into a graph of Java objects. \n");
    generateUnMarshallerFromString.javadoc().trimToSize();
    final JVar stringunmarshallVar = generateUnMarshallerFromString.param(JMod.FINAL, invokeMarshalWith, "content");

    final JTryBlock tryStringBlock = generateUnMarshallerFromString.body()._try();
    final JVar localUnmarshaller = tryStringBlock.body().decl(jaxbUnmarshallerClass, "unmarshaller",
        jaxbContextClass.boxify().staticInvoke("newInstance").arg(JExpr.direct("Kml.class")).invoke("createUnmarshaller"));
   
    final JVar inputsource = tryStringBlock.body().decl(inputsourceClass, "input", JExpr._new(inputsourceClass).arg(stringunmarshallVar));
    final JVar saxsource = tryStringBlock.body().decl(saxsourceClass, "saxSource", JExpr._new(saxsourceClass).arg(JExpr._new(namespaceFilterXMLReaderclass).arg(JExpr.FALSE)).arg(inputsource));
    final JVar decl = tryStringBlock.body().decl(kmlClass, "jaxbRootElement", JExpr.cast(kmlClass, JExpr.invoke(localUnmarshaller, "unmarshal").arg(saxsource)));
    tryStringBlock.body()._return(decl);
    tryStringBlock._catch(saxExceptionClass.boxify()).body().directStatement("_x.printStackTrace();");
    tryStringBlock._catch(parserConfigurationExceptionClass.boxify()).body().directStatement("_x.printStackTrace();");
    tryStringBlock._catch(jaxbExceptionClass.boxify()).body().directStatement("_x.printStackTrace();");
    generateUnMarshallerFromString.body()._return(JExpr._null());   
View Full Code Here

    final JMethod generateUnMarshallerFromString = cc.implClass.method(JMod.PUBLIC | JMod.STATIC, kmlClass, "unmarshal");
    generateUnMarshallerFromString.javadoc().add("KML to Java\n");
    generateUnMarshallerFromString.javadoc().add("Similar to the other unmarshal methods \n\n");
    generateUnMarshallerFromString.javadoc().add("with the exception that it transforms a String into a graph of Java objects. \n");
    generateUnMarshallerFromString.javadoc().trimToSize();
    final JVar stringunmarshallVar = generateUnMarshallerFromString.param(JMod.FINAL, stringClass, "content");

    final JTryBlock tryStringBlock = generateUnMarshallerFromString.body()._try();
    final JVar localUnmarshaller = tryStringBlock.body().decl(jaxbUnmarshallerClass, "unmarshaller",
        jaxbContextClass.boxify().staticInvoke("newInstance").arg(JExpr.direct("Kml.class")).invoke("createUnmarshaller"));
   
    final JVar inputsource = tryStringBlock.body().decl(inputsourceClass, "input", JExpr._new(inputsourceClass).arg(JExpr._new(stringReaderClass).arg(stringunmarshallVar)));
    final JVar saxsource = tryStringBlock.body().decl(saxsourceClass, "saxSource", JExpr._new(saxsourceClass).arg(JExpr._new(namespaceFilterXMLReaderclass).arg(JExpr.FALSE)).arg(inputsource));
    final JVar decl = tryStringBlock.body().decl(kmlClass, "jaxbRootElement", JExpr.cast(kmlClass, JExpr.invoke(localUnmarshaller, "unmarshal").arg(saxsource)));
    tryStringBlock.body()._return(decl);
    tryStringBlock._catch(saxExceptionClass.boxify()).body().directStatement("_x.printStackTrace();");
    tryStringBlock._catch(parserConfigurationExceptionClass.boxify()).body().directStatement("_x.printStackTrace();");
    tryStringBlock._catch(jaxbExceptionClass.boxify()).body().directStatement("_x.printStackTrace();");
    generateUnMarshallerFromString.body()._return(JExpr._null());   
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JVar

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.