protected Node recordPackage( final CompilationUnit compilationUnit,
                                  final Node outputNode ) throws Exception {
        final PackageDeclaration pkg = compilationUnit.getPackage();

        if (pkg == null) {
            return outputNode;
        }

        Node pkgNode = outputNode;

        { // create node for each segment of the package name
            final String pkgName = pkg.getName().getFullyQualifiedName();
            final String[] packagePath = pkgName.split("\\.");

            if (pkgName.length() > 0) {
                for (final String segment : packagePath) {
                    pkgNode = pkgNode.addNode(segment);
                    pkgNode.addMixin(ClassFileSequencerLexicon.PACKAGE);
                }
            }
        }

        { // Javadocs
            final Javadoc javadoc = pkg.getJavadoc();

            if (javadoc != null) {
                record(javadoc, pkgNode);
            }
        }

        { // annotations
            @SuppressWarnings( "unchecked" )
            final List<Annotation> annotations = pkg.annotations();

            if ((annotations != null) && !annotations.isEmpty()) {
                for (final Annotation annotation : annotations) {
                    record(annotation, pkgNode);
                }
            }
        }

        recordSourceReference(pkg, pkgNode);
        return pkgNode;
    }
protected Node recordPackage ( final CompilationUnit compilationUnit , final Node outputNode ) throws Exception { final PackageDeclaration pkg = compilationUnit . getPackage ( ) ; if ( pkg == null ) { return outputNode ; } Node pkgNode = outputNode ; { final String pkgName = pkg . getName ( ) . getFullyQualifiedName ( ) ; final String [ ] packagePath = pkgName . split ( "\\." ) ; if ( pkgName . length ( ) > 0 ) { for ( final String segment : packagePath ) { pkgNode = pkgNode . addNode ( segment ) ; pkgNode . addMixin ( ClassFileSequencerLexicon . PACKAGE ) ; } } } { final Javadoc javadoc = pkg . getJavadoc ( ) ; if ( javadoc != null ) { record ( javadoc , pkgNode ) ; } } { @ SuppressWarnings ( "unchecked" ) final List < Annotation > annotations = pkg . annotations ( ) ; if ( ( annotations != null ) && ! annotations . isEmpty ( ) ) { for ( final Annotation annotation : annotations ) { record ( annotation , pkgNode ) ; } } } recordSourceReference ( pkg , pkgNode ) ; return pkgNode ; }
<pre>
PackageDeclaration:
[ Javadoc ] { Annotation } package Name ;
</pre>

@param compilationUnit the {@link CompilationUnit compilation unit} whose package is being recorded (cannot be
<code>null</code>)
@param outputNode the output node (cannot be <code>null</code>)
@return the package {@link Node node} or the passed in <code>outputNode</code> if a package is not found
@throws Exception if there is a problem