Package org.codehaus.janino.util.resource

Examples of org.codehaus.janino.util.resource.ResourceCreator


                        }

                        return new JciResource(pResourceName, bytes);
                    }
                },
                new ResourceCreator() {
                    public OutputStream createResource( final String pResourceName ) throws IOException {
                        return new JciOutputStream(pResourceName, pStore);
                    }

                    public boolean deleteResource( final String pResourceName ) {
View Full Code Here


     */
    public void storeClassFile(ClassFile classFile, final File sourceFile) throws IOException {
        String classFileResourceName = ClassFile.getClassFileResourceName(classFile.getThisClassName());

        // Determine where to create the class file.
        ResourceCreator rc;
        if (this.classFileCreator != Compiler.CREATE_NEXT_TO_SOURCE_FILE) {
            rc = this.classFileCreator;
        } else {

            // If the JAVAC option "-d" is given, place the class file next
            // to the source file, irrespective of the package name.
            rc = new FileResourceCreator() {
                protected File getFile(String resourceName) {
                    return new File(
                        sourceFile.getParentFile(),
                        resourceName.substring(resourceName.lastIndexOf('/') + 1)
                    );
                }
            };
        }
        OutputStream os = rc.createResource(classFileResourceName);
        try {
            if (DEBUG) {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                classFile.store(baos);
                byte[] ba = baos.toByteArray();
                System.out.println("*** Disassembly of class \"" + classFile.getThisClassName() + "\":");
                try {
                    new Disassembler().disasm(new ByteArrayInputStream(ba));
                    System.out.flush();
                } catch (IOException ex) {
                    throw new JaninoRuntimeException("SNO: IOException despite ByteArrayInputStream");
                }
                os.write(ba);
            } else
            {
                classFile.store(os);
            }
        } catch (IOException ex) {
            try { os.close(); } catch (IOException e) { }
            os = null;
            if (!rc.deleteResource(classFileResourceName)) {
                throw new IOException(
                    "Could not delete incompletely written class file \""
                    + classFileResourceName
                    + "\""
                );
View Full Code Here

            log.debug("reading " + pResourceName + " (" + bytes.length + ")");
           
            return new JciResource(pResourceName, bytes);
          }       
          },
          new ResourceCreator() {
          public OutputStream createResource( final String pResourceName ) throws IOException {
            return new JciOutputStream(pResourceName, pStore);
          }

          public boolean deleteResource( final String pResourceName ) {
View Full Code Here

                        }

                        return new JciResource(pResourceName, bytes);
                    }
                },
                new ResourceCreator() {
                    public OutputStream createResource( final String pResourceName ) throws IOException {
                        return new JciOutputStream(pResourceName, pStore);
                    }

                    public boolean deleteResource( final String pResourceName ) {
View Full Code Here

            }
           
            return new JciResource(pResourceName, bytes);
          }       
          },
          new ResourceCreator() {
          public OutputStream createResource( final String pResourceName ) throws IOException {
            return new JciOutputStream(pResourceName, pStore);
          }

          public boolean deleteResource( final String pResourceName ) {
View Full Code Here

TOP

Related Classes of org.codehaus.janino.util.resource.ResourceCreator

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.