org.modeshape.sequencer.javafile

## Class JdtRecorder

- java.lang.Object
- - org.modeshape.sequencer.javafile.JdtRecorder

- All Implemented Interfaces:
    SourceFileRecorder

      public class JdtRecorder
      extends Object
      implements SourceFileRecorder

  An Eclipse JDT DOM to JCR node recorder.

       CompilationUnit:
           [ PackageDeclaration ]
               { ImportDeclaration }
               { TypeDeclaration | EnumDeclaration | AnnotationTypeDeclaration | ; }

       PackageDeclaration:
           [ Javadoc ] { Annotation } package Name ;

       ImportDeclaration:
           import [ static ] Name [ . * ] ;

       TypeDeclaration:
           ClassDeclaration
           InterfaceDeclaration

       ClassDeclaration:
           [ Javadoc ] { ExtendedModifier } class Identifier
               [ < TypeParameter { , TypeParameter } > ]
               [ extends Type ]
               [ implements Type { , Type } ]
               { { ClassBodyDeclaration | ; } }

       InterfaceDeclaration:
           [ Javadoc ] { ExtendedModifier } interface Identifier
               [ < TypeParameter { , TypeParameter } > ]
               [ extends Type { , Type } ]
               { { InterfaceBodyDeclaration | ; } }

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JdtRecorder()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected String` | `getSourceCode(int startPosition, int length)`
    `protected String` | `getTypeName(org.eclipse.jdt.core.dom.Type type)`
    `protected String` | `getVisibility(int modifiers)`
    `protected void` | `record(org.eclipse.jdt.core.dom.Annotation annotation, Node parentNode)` Annotation: NormalAnnotation MarkerAnnotation SingleMemberAnnotation NormalAnnotation: \@ TypeName ( [ MemberValuePair { , MemberValuePair } ] ) MarkerAnnotation: \@ TypeName SingleMemberAnnotation: \@ TypeName ( Expression ) MemberValuePair: SimpleName = Expression
    `protected Node` | `record(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration annotationType, Node outputNode)` AnnotationTypeDeclaration: [ Javadoc ] { ExtendedModifier } @ interface Identifier { { AnnotationTypeBodyDeclaration | ; } } AnnotationTypeBodyDeclaration: AnnotationTypeMemberDeclaration FieldDeclaration TypeDeclaration EnumDeclaration AnnotationTypeDeclaration AnnotationTypeMemberDeclaration: [ Javadoc ] { ExtendedModifier } Type Identifier ( ) [ default Expression ] ;
    `protected void` | `record(org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration annotationTypeMember, Node parentNode)` AnnotationTypeMemberDeclaration: [ Javadoc ] { ExtendedModifier } Type Identifier ( ) [ default Expression ] ;
    `protected void` | `record(org.eclipse.jdt.core.dom.Block block, Node blockNode)` Block: { { Statement } }
    `protected void` | `record(org.eclipse.jdt.core.dom.Comment comment, Node parentNode)` Comment: LineComment BlockComment Javadoc
    `protected void` | `record(org.eclipse.jdt.core.dom.CompilationUnit unit, Node compilationUnitNode)` CompilationUnit: [ PackageDeclaration ] { ImportDeclaration } { TypeDeclaration | EnumDeclaration | AnnotationTypeDeclaration | ; }
    `protected void` | `record(org.eclipse.jdt.core.dom.EnumConstantDeclaration enumConstant, Node parentNode)` EnumConstantDeclaration: [ Javadoc ] { ExtendedModifier } Identifier [ ( [ Expression { , Expression } ] ) ] [ AnonymousClassDeclaration ]
    `protected Node` | `record(org.eclipse.jdt.core.dom.EnumDeclaration enumType, Node parentNode)` EnumDeclaration: [ Javadoc ] { ExtendedModifier } enum Identifier [ implements Type { , Type } ] { [ EnumConstantDeclaration { , EnumConstantDeclaration } ] [ , ] [ ; { ClassBodyDeclaration | ; } ] }
    `protected void` | `record(org.eclipse.jdt.core.dom.FieldDeclaration field, Node parentNode)` FieldDeclaration: [Javadoc] { ExtendedModifier } Type VariableDeclarationFragment { , VariableDeclarationFragment } ; VariableDeclarationFragment: Identifier { [] } [ = Expression ] A field container node will be created if one does not exist under `node.`
    `protected void` | `record(org.eclipse.jdt.core.dom.Initializer initializer, String nodeName, Node parentNode)` Initializer: [ static ] Block Block: { { Statement } }
    `protected void` | `record(org.eclipse.jdt.core.dom.MethodDeclaration method, Node parentNode)` MethodDeclaration: [ Javadoc ] { ExtendedModifier } [ < TypeParameter { , TypeParameter } > ] ( Type | void ) Identifier ( [ FormalParameter { , FormalParameter } ] ) {[ ] } [ throws TypeName { , TypeName } ] ( Block | ; ) ConstructorDeclaration: [ Javadoc ] { ExtendedModifier } [ < TypeParameter { , TypeParameter } > ] Identifier ( [ FormalParameter { , FormalParameter } ] ) [throws TypeName { , TypeName } ] Block
    `protected void` | `record(Sequencer.Context context, char[] sourceCode, Node outputNode)` Convert the compilation unit into JCR nodes.
    `void` | `record(Sequencer.Context context, InputStream inputStream, long length, String encoding, Node outputNode)` Records a source file.
    `protected void` | `record(org.eclipse.jdt.core.dom.SingleVariableDeclaration variable, Node parentNode)` SingleVariableDeclaration: { ExtendedModifier } Type [ ... ] Identifier { [] } [ = Expression ]
    `protected Node` | `record(org.eclipse.jdt.core.dom.TypeDeclaration type, Node parentNode)` TypeDeclaration: ClassDeclaration InterfaceDeclaration ClassDeclaration: [ Javadoc ] { ExtendedModifier } class Identifier [ < TypeParameter { , TypeParameter } > ] [ extends Type ] [ implements Type { , Type } ] { { ClassBodyDeclaration | ; } } InterfaceDeclaration: [ Javadoc ] { ExtendedModifier } interface Identifier [ < TypeParameter { , TypeParameter } > ] [ extends Type { , Type } ] { { InterfaceBodyDeclaration | ; } }
    `protected void` | `record(org.eclipse.jdt.core.dom.TypeParameter param, Node parentNode)` TypeParameter: TypeVariable [ extends Type { & Type } ]
    `protected void` | `record(org.eclipse.jdt.core.dom.Type type, String typeNodeName, Node parentNode)` Type: PrimitiveType ArrayType SimpleType QualifiedType ParameterizedType WildcardType PrimitiveType: byte short char int long float double boolean void ArrayType: Type [ ] SimpleType: TypeName ParameterizedType: Type < Type { , Type } > QualifiedType: Type .
    `protected void` | `recordAnnotationMember(String memberName, org.eclipse.jdt.core.dom.Expression expression, Node parentNode)`
    `protected void` | `recordAnnotations(List<org.eclipse.jdt.core.dom.IExtendedModifier> extendedModifiers, Node node)`
    `protected void` | `recordBodyDeclarations(org.eclipse.jdt.core.dom.AbstractTypeDeclaration type, Node typeNode)`
    `protected void` | `recordBodyDeclarations(org.eclipse.jdt.core.dom.AnonymousClassDeclaration anonClass, Node enumConstantNode)`
    `protected void` | `recordComments(org.eclipse.jdt.core.dom.CompilationUnit compilationUnit, Node outputNode)` Comment: LineComment BlockComment Javadoc
    `protected void` | `recordCompilerMessages(org.eclipse.jdt.core.dom.CompilationUnit unit, Node parentNode)`
    `protected void` | `recordExpression(org.eclipse.jdt.core.dom.Expression expression, String nodeName, Node parentNode)` Expression: Annotation, ArrayAccess, ArrayCreation, ArrayInitializer, Assignment, BooleanLiteral, CastExpression, CharacterLiteral, ClassInstanceCreation, ConditionalExpression, FieldAccess, InfixExpression, InstanceofExpression, MethodInvocation, Name, NullLiteral, NumberLiteral, ParenthesizedExpression, PostfixExpression, PrefixExpression, StringLiteral, SuperFieldAccess, SuperMethodInvocation, ThisExpression, TypeLiteral, VariableDeclarationExpression
    `protected void` | `recordImports(org.eclipse.jdt.core.dom.CompilationUnit compilationUnit, Node outputNode)` ImportDeclaration: import [ static ] Name [ . * ] ;
    `protected Node` | `recordPackage(org.eclipse.jdt.core.dom.CompilationUnit compilationUnit, Node outputNode)` PackageDeclaration: [ Javadoc ] { Annotation } package Name ;
    `protected void` | `recordSourceReference(org.eclipse.jdt.core.dom.ASTNode astNode, Node jcrNode)`
    `protected void` | `recordTypes(org.eclipse.jdt.core.dom.CompilationUnit unit, Node compilationUnitNode, Node pkgNode)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JdtRecorder

          public JdtRecorder()

  - ### Method Detail

    - #### getSourceCode

          protected String getSourceCode(int startPosition,
                             int length)

    - #### getTypeName

          protected String getTypeName(org.eclipse.jdt.core.dom.Type type)

    - #### getVisibility

          protected String getVisibility(int modifiers)

    - #### record

          protected void record(org.eclipse.jdt.core.dom.Annotation annotation,
                    Node parentNode)
                         throws Exception

           Annotation:
               NormalAnnotation
               MarkerAnnotation
               SingleMemberAnnotation

           NormalAnnotation:
               \@ TypeName ( [ MemberValuePair { , MemberValuePair } ] )

           MarkerAnnotation:
               \@ TypeName

           SingleMemberAnnotation:
               \@ TypeName ( Expression  )

           MemberValuePair:
               SimpleName = Expression

      Parameters:
        `annotation` - the `annotation` being recorded (cannot be `null`)
        `parentNode` - the parent `node` where the annotation will be created (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected Node record(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration annotationType,
                    Node outputNode)
                         throws Exception

           AnnotationTypeDeclaration:
               [ Javadoc ] { ExtendedModifier } @ interface Identifier
                    { { AnnotationTypeBodyDeclaration | ; } }

           AnnotationTypeBodyDeclaration:
                AnnotationTypeMemberDeclaration
                FieldDeclaration
                TypeDeclaration
                EnumDeclaration
                AnnotationTypeDeclaration

           AnnotationTypeMemberDeclaration:
               [ Javadoc ] { ExtendedModifier }
                   Type Identifier ( ) [ default Expression ] ;

      Parameters:
        `annotationType` - the `annotation type` being recorded (cannot be `null`)
        `outputNode` - the output node where the annotation type should be created (cannot be `null`)
      Returns:
        the node representing the annotation type (never `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected void record(org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration annotationTypeMember,
                    Node parentNode)
                         throws Exception

           AnnotationTypeMemberDeclaration:
               [ Javadoc ] { ExtendedModifier }
                   Type Identifier ( ) [ default Expression ] ;

      Parameters:
        `annotationTypeMember` - the `annotation type member` being recorded (cannot be `null`)
        `parentNode` - the parent `node` where the annotation type members will be added (cannot be `null` )
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected void record(org.eclipse.jdt.core.dom.Block block,
                    Node blockNode)
                         throws Exception

           Block:
               { { Statement } }

      Parameters:
        `block` - the `block` being recorded (cannot be `null`)
        `blockNode` - the parent `node` where the statements will be added (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected void record(org.eclipse.jdt.core.dom.Comment comment,
                    Node parentNode)
                         throws Exception

           Comment:
               LineComment
               BlockComment
               Javadoc

      Parameters:
        `comment` - the comment being recorded (cannot be `null`)
        `parentNode` - the `parent node` (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected void record(org.eclipse.jdt.core.dom.CompilationUnit unit,
                    Node compilationUnitNode)
                         throws Exception

           CompilationUnit:
               [ PackageDeclaration ]
                    { ImportDeclaration }
                    { TypeDeclaration | EnumDeclaration | AnnotationTypeDeclaration | ; }

      Parameters:
        `unit` - the `compilation unit` being recorded (cannot be `null`)
        `compilationUnitNode` - the output node associated with the compilation unit (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          public void record(Sequencer.Context context,
                    InputStream inputStream,
                    long length,
                    String encoding,
                    Node outputNode)
                      throws Exception

      Records a source file.
      Specified by:
        `record` in interface `SourceFileRecorder`
      Parameters:
        `context` - the sequencer context (cannot be `null`)
        `inputStream` - the stream being processed (cannot be `null`)
        `length` - the length of the java file
        `encoding` - the encoding to use (can be `null`)
        `outputNode` - the `Node` output (cannot be `null`)
      Throws:
        `Exception` - if anything fails during the sequencing process
      See Also:
        `SourceFileRecorder.record(org.modeshape.jcr.api.sequencer.Sequencer.Context, java.io.InputStream, long, java.lang.String, javax.jcr.Node)`

    - #### record

          protected void record(org.eclipse.jdt.core.dom.EnumConstantDeclaration enumConstant,
                    Node parentNode)
                         throws Exception

           EnumConstantDeclaration:
               [ Javadoc ] { ExtendedModifier } Identifier
                   [ ( [ Expression { , Expression } ] ) ]
                   [ AnonymousClassDeclaration ]

      Parameters:
        `enumConstant` - the enum constant being processed (cannot be `null`)
        `parentNode` - the `node` where the enum constant node will be created (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected Node record(org.eclipse.jdt.core.dom.EnumDeclaration enumType,
                    Node parentNode)
                         throws Exception

           EnumDeclaration:
           [ Javadoc ] { ExtendedModifier } enum Identifier
               [ implements Type { , Type } ]
               {
               [ EnumConstantDeclaration { , EnumConstantDeclaration } ] [ , ]
               [ ; { ClassBodyDeclaration | ; } ]
               }

      Parameters:
        `enumType` - the `enum` being recorded (cannot be `null`)
        `parentNode` - the parent `node` (cannot be `null`)
      Returns:
        the node representing the enum being recorded (never `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected void record(org.eclipse.jdt.core.dom.FieldDeclaration field,
                    Node parentNode)
                         throws Exception

           FieldDeclaration:
                [Javadoc] { ExtendedModifier } Type VariableDeclarationFragment
                     { , VariableDeclarationFragment } ;

           VariableDeclarationFragment:
               Identifier { [] } [ = Expression ]

      A field container node will be created if one does not exist under `node.`
      Parameters:
        `field` - the `field` being recorded {cannot be `null`
        `parentNode` - the parent `node` (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected void record(org.eclipse.jdt.core.dom.Initializer initializer,
                    String nodeName,
                    Node parentNode)
                         throws Exception

           Initializer:
               [ static ] Block

           Block:
               { { Statement } }

      Parameters:
        `initializer` - the `initializer` being recorded (cannot be `null`)
        `nodeName` - the name of the node being created that represents the initializer (cannot be `null` or empty)
        `parentNode` - the parent `node` (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected void record(org.eclipse.jdt.core.dom.MethodDeclaration method,
                    Node parentNode)
                         throws Exception

           MethodDeclaration:
               [ Javadoc ] { ExtendedModifier }
                    [ < TypeParameter { , TypeParameter } > ]
               ( Type | void ) Identifier (
               [ FormalParameter
                    { , FormalParameter } ] ) {[ ] }
               [ throws TypeName { , TypeName } ] ( Block | ; )

           ConstructorDeclaration:
               [ Javadoc ] { ExtendedModifier }
                    [ < TypeParameter { , TypeParameter } > ]
               Identifier (
                   [ FormalParameter
                       { , FormalParameter } ] )
               [throws TypeName { , TypeName } ] Block

      Parameters:
        `method` - the `method` being recorded (cannot be `null`)
        `parentNode` - the parent `node` (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected void record(Sequencer.Context context,
                    char[] sourceCode,
                    Node outputNode)
                         throws Exception

      Convert the compilation unit into JCR nodes.
      Parameters:
        `context` - the sequencer context
        `sourceCode` - the source code being recorded (can be `null` if there is no source code)
        `outputNode` - the `node` where the output will be saved (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected void record(org.eclipse.jdt.core.dom.SingleVariableDeclaration variable,
                    Node parentNode)
                         throws Exception

           SingleVariableDeclaration:
               { ExtendedModifier } Type [ ... ] Identifier { [] } [ = Expression ]

      Parameters:
        `variable` - the `variable` being recorded (cannot be `null`)
        `parentNode` - the parent `node` where the variable is being recorded (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected void record(org.eclipse.jdt.core.dom.Type type,
                    String typeNodeName,
                    Node parentNode)
                         throws Exception

           Type:
               PrimitiveType
               ArrayType
               SimpleType
               QualifiedType
               ParameterizedType
               WildcardType

           PrimitiveType:
               byte
               short
               char
               int
               long
               float
               double
               boolean
               void

           ArrayType:
               Type [ ]

           SimpleType:
               TypeName

           ParameterizedType:
               Type < Type { , Type } >

           QualifiedType:
               Type . SimpleName

           WildcardType:
               ? [ ( extends | super) Type ]

      Parameters:
        `type` - the type `type` being recorded (cannot be `null`)
        `typeNodeName` - the name of the type node being recorded (cannot be `null` or empty)
        `parentNode` - the parent `node` where the type will be recorded (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected Node record(org.eclipse.jdt.core.dom.TypeDeclaration type,
                    Node parentNode)
                         throws Exception

           TypeDeclaration:
               ClassDeclaration
               InterfaceDeclaration

           ClassDeclaration:
               [ Javadoc ] { ExtendedModifier } class Identifier
               [ < TypeParameter { , TypeParameter } > ]
               [ extends Type ]
               [ implements Type { , Type } ]
               { { ClassBodyDeclaration | ; } }

           InterfaceDeclaration:
               [ Javadoc ] { ExtendedModifier } interface Identifier
               [ < TypeParameter { , TypeParameter } > ]
               [ extends Type { , Type } ]
               { { InterfaceBodyDeclaration | ; } }

      Parameters:
        `type` - the `type` being recorded (cannot be `null`)
        `parentNode` - the parent `node` where the new type will be created (cannot be `null`)
      Returns:
        the node representing the type being recorded (never `null`)
      Throws:
        `Exception` - if there is a problem

    - #### record

          protected void record(org.eclipse.jdt.core.dom.TypeParameter param,
                    Node parentNode)
                         throws Exception

           TypeParameter:
               TypeVariable [ extends Type { & Type } ]

      Parameters:
        `param` - the `type parameter` being recorded (cannot be `null`)
        `parentNode` - the parent `node` where the type parameter will be recorded (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### recordAnnotationMember

          protected void recordAnnotationMember(String memberName,
                                    org.eclipse.jdt.core.dom.Expression expression,
                                    Node parentNode)
                                         throws Exception

      Throws:
        `Exception`

    - #### recordAnnotations

          protected void recordAnnotations(List<org.eclipse.jdt.core.dom.IExtendedModifier> extendedModifiers,
                               Node node)
                                    throws Exception

      Throws:
        `Exception`

    - #### recordBodyDeclarations

          protected void recordBodyDeclarations(org.eclipse.jdt.core.dom.AbstractTypeDeclaration type,
                                    Node typeNode)
                                         throws Exception

      Throws:
        `Exception`

    - #### recordBodyDeclarations

          protected void recordBodyDeclarations(org.eclipse.jdt.core.dom.AnonymousClassDeclaration anonClass,
                                    Node enumConstantNode)
                                         throws Exception

      Throws:
        `Exception`

    - #### recordComments

          protected void recordComments(org.eclipse.jdt.core.dom.CompilationUnit compilationUnit,
                            Node outputNode)
                                 throws Exception

           Comment:
               LineComment
               BlockComment
               Javadoc

      Parameters:
        `compilationUnit` - the `compilation unit` being recorded (cannot be `null`)
        `outputNode` - the parent `node` (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### recordCompilerMessages

          protected void recordCompilerMessages(org.eclipse.jdt.core.dom.CompilationUnit unit,
                                    Node parentNode)
                                         throws Exception

      Throws:
        `Exception`

    - #### recordExpression

          protected void recordExpression(org.eclipse.jdt.core.dom.Expression expression,
                              String nodeName,
                              Node parentNode)
                                   throws Exception

           Expression:

           Annotation,
           ArrayAccess,
           ArrayCreation,
           ArrayInitializer,
           Assignment,
           BooleanLiteral,
           CastExpression,
           CharacterLiteral,
           ClassInstanceCreation,
           ConditionalExpression,
           FieldAccess,
           InfixExpression,
           InstanceofExpression,
           MethodInvocation,
           Name,
           NullLiteral,
           NumberLiteral,
           ParenthesizedExpression,
           PostfixExpression,
           PrefixExpression,
           StringLiteral,
           SuperFieldAccess,
           SuperMethodInvocation,
           ThisExpression,
           TypeLiteral,
           VariableDeclarationExpression

      Parameters:
        `expression` - the `expression` being recorded (cannot be `null`)
        `nodeName` - the name of the expression node that is created (cannot be `null` or empty)
        `parentNode` - the parent `node` where the expression is being recorded (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### recordImports

          protected void recordImports(org.eclipse.jdt.core.dom.CompilationUnit compilationUnit,
                           Node outputNode)
                                throws Exception

           ImportDeclaration:
                import [ static ] Name [ . * ] ;

      Parameters:
        `compilationUnit` - the `compilation unit` being recorded (cannot be `null`)
        `outputNode` - the parent `node` (cannot be `null`)
      Throws:
        `Exception` - if there is a problem

    - #### recordPackage

          protected Node recordPackage(org.eclipse.jdt.core.dom.CompilationUnit compilationUnit,
                           Node outputNode)
                                throws Exception

           PackageDeclaration:
               [ Javadoc ] { Annotation } package Name ;

      Parameters:
        `compilationUnit` - the `compilation unit` whose package is being recorded (cannot be `null`)
        `outputNode` - the output node (cannot be `null`)
      Returns:
        the package `node` or the passed in `outputNode` if a package is not found
      Throws:
        `Exception` - if there is a problem

    - #### recordSourceReference

          protected void recordSourceReference(org.eclipse.jdt.core.dom.ASTNode astNode,
                                   Node jcrNode)
                                        throws Exception

      Throws:
        `Exception`

    - #### recordTypes

          protected void recordTypes(org.eclipse.jdt.core.dom.CompilationUnit unit,
                         Node compilationUnitNode,
                         Node pkgNode)
                              throws Exception

      Throws:
        `Exception`

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.