Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2012 Sonatype, Inc. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: Stuart McCulloch /
 
 
 package org.kohsuke.stapler;
 
 
 
APT6-based support for loading/storing generated content.

Author(s):
Stuart McCulloch
 
 public abstract class AbstractAPT6
     extends AbstractProcessor
 {
    

Returns:
Javadoc text for the given program element
 
     protected final String javadocfinal Element element )
     {
         return .getElementUtils().getDocCommentelement );
     }

    
Represents content to be loaded from or stored to a specific location.
 
     public interface Content
     {
         String location();
 
         void loadInputStream is )
             throws IOException;
 
         void storeOutputStream os )
             throws IOException;
     }

    
Loads the given content from a location under the class output directory.
 
     protected final Content loadfinal Content content )
     {
         InputStream is = null;
         try
         {
             final String path = content.location();
             final FileObject f = .getFiler().getResource.""path );
             content.loadis = f.openInputStream() );
         }
         catch ( final FilerException e )
         {
             // someone else is already processing this file!
         }
         catch ( final FileNotFoundException e )
         {
             // nothing to load
         }
         catch ( final Exception e )
         {
             .getMessager().printMessage.e.toString() );
         }
         finally
         {
             Closeables.closeQuietlyis );
         }
         return content;
     }

    
Stores the given content to a location under the class output directory.
 
     protected final void storefinal Content content )
     {
         OutputStream os = null;
         try
        {
            final String path = content.location();
            final FileObject f = .getFiler().createResource.""path );
            content.storeos = f.openOutputStream() );
        }
        catch ( final FilerException e )
        {
            // someone else is already processing this file!
        }
        catch ( final Exception e )
        {
            .getMessager().printMessage.e.toString() );
        }
        finally
        {
            Closeables.closeQuietlyos );
        }
    }
New to GrepCode? Check out our FAQ X