Class InsertAjavaAnnotations


  • public class InsertAjavaAnnotations
    extends java.lang.Object
    This program inserts annotations from an ajava file into a Java file. See main(java.lang.String[]).
    • Constructor Summary

      Constructors 
      Constructor Description
      InsertAjavaAnnotations​(javax.lang.model.util.Elements elements)
      Constructs an InsertAjavaAnnotations using the given Elements instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String insertAnnotations​(java.io.InputStream annotationFile, java.lang.String javaFileContents, java.lang.String lineSeparator)
      Inserts all annotations from the ajava file read from annotationFile into a Java file with contents javaFileContents that uses the given line separator and returns the resulting String.
      void insertAnnotations​(java.lang.String annotationFilePath, java.lang.String javaFilePath)
      Inserts all annotations from the ajava file at annotationFilePath into javaFilePath.
      static void main​(java.lang.String[] args)
      Inserts annotations from ajava files into Java files in place.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InsertAjavaAnnotations

        public InsertAjavaAnnotations​(javax.lang.model.util.Elements elements)
        Constructs an InsertAjavaAnnotations using the given Elements instance.
        Parameters:
        elements - an instance of Elements
    • Method Detail

      • insertAnnotations

        public java.lang.String insertAnnotations​(java.io.InputStream annotationFile,
                                                  java.lang.String javaFileContents,
                                                  java.lang.String lineSeparator)
        Inserts all annotations from the ajava file read from annotationFile into a Java file with contents javaFileContents that uses the given line separator and returns the resulting String.
        Parameters:
        annotationFile - input stream for an ajava file for javaFileContents
        javaFileContents - contents of a Java file to insert annotations into
        lineSeparator - the line separator javaFileContents uses
        Returns:
        a modified javaFileContents with annotations from annotationFile inserted
      • insertAnnotations

        public void insertAnnotations​(java.lang.String annotationFilePath,
                                      java.lang.String javaFilePath)
        Inserts all annotations from the ajava file at annotationFilePath into javaFilePath.
        Parameters:
        annotationFilePath - path to an ajava file
        javaFilePath - path to a Java file to insert annotation into
      • main

        public static void main​(java.lang.String[] args)
        Inserts annotations from ajava files into Java files in place.

        The first argument is an ajava file or a directory containing ajava files.

        The second argument is a Java file or a directory containing Java files to insert annotations into.

        For each Java file, checks if any ajava files from the first argument match it. For each such ajava file, inserts all its annotations into the Java file.

        Parameters:
        args - command line arguments: the first element should be a path to ajava files and the second should be the directory containing Java files to insert into