CPD Results

The following document contains the results of PMD's CPD 3.7.

Duplications

FileLine
org/millscript/millscript/render/XMLCDATARenderer.java53
org/millscript/millscript/render/HTMLCDATARenderer.java53
    public HTMLCDATARenderer( final HTMLRenderer hr ) {
        this.parentRenderer = hr;
    }

    /**
     * @see org.millscript.millscript.render.Renderer#append(char)
     */
    public void append( final char ch ) throws IOException {
        parentRenderer.append( ch );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#append(java.lang.CharSequence)
     */
    public void append( final CharSequence cs ) throws IOException {
        parentRenderer.append( cs );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#appendEscapeFor(char)
     */
    public void appendEscapeFor( final char ch ) throws IOException {
        parentRenderer.appendEscapeFor( ch );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#appendNoEscape(char)
     */
    public void appendNoEscape( final char ch ) throws IOException {
        parentRenderer.appendNoEscape( ch );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#appendNoEscape(java.lang.CharSequence)
     */
    public void appendNoEscape( final CharSequence cs ) throws IOException {
        parentRenderer.appendNoEscape( cs );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#canEncode(char)
     */
    public boolean canEncode( final char ch ) {
        return parentRenderer.canEncode( ch );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#render(java.lang.Object)
     */
    public void render( final Object o ) throws IOException {
        if ( o == null ) {
            return;
        } else if ( o instanceof Renderable ) {
            ((Renderable) o).render( this );
        } else if ( o instanceof IList ) {
            MapIterator it = ((IList) o).iterator( true );
            while ( it.hasNext() ) {
                this.render( it.nextValue() );
            }
        } else if ( o instanceof List ) {
            Iterator it = ((List)o).iterator();
            while ( it.hasNext() ) {
                this.render( it.next() );
            }
        } else {
            // FIXME - This code should use the standard
            // AbstractRenderer.append(CharSequence) but we need to provide a way to
            // parse database content into an XmlElement before we can change
            // it.
            this.renderObject( o );
        }
    }

    /**
     * @see org.millscript.millscript.render.Renderer#renderAsDocument(java.lang.Object)
     */
    public void renderAsDocument( final Object o ) {
        parentRenderer.renderAsDocument( o );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#renderAsFragment(org.millscript.commons.util.IList)
     */
    public void renderAsFragment( final IList l ) {
        parentRenderer.renderAsFragment( l );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#renderCDATA(org.millscript.millscript.datatypes.CDATA)
     */
    public void renderCDATA( final CDATA c ) throws IOException {
        // It's not clear we need to do anything special to render a
        // CDATA object in HTML, even though this is the CDATA renderer!
        parentRenderer.renderCDATA( c );

FileLine
org/millscript/millscript/loaders/XMLLoaderTokenVisitor.java173
org/millscript/millscript/loaders/BasicTemplateLoaderTokenVisitor.java98
        this.body = CommaExpr.make( this.body, e );
    }

    /**
     * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.AttListDeclToken)
     */
    public void visit( final AttListDeclToken token ) {
        // We don't handle processing instructions
        throw(
            Alerts.unimplemented(
                "Attribute list declarations cannot be compiled at the moment, sorry!"
            ).decorate( token ).mishap()
        );
    }

    /**
     * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.CharDataToken)
     */
    public void visit( final CharDataToken token ) {
        // TODO - In the future we might want to return this whitespace as part
        // of the XML document
        if ( ! token.isIgnorableWhitespace() ) {
            throw(
                Alerts.unimplemented(
                    "All character data must be within an element at the moment, sorry!"
                ).decorate( token ).mishap()
            );
        }
    }

    /**
     * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.CommentToken)
     */
    public void visit( final CommentToken token ) {
        throw(
            Alerts.unimplemented(
                "Comments must be within an element at the moment, sorry!"
            ).decorate( token ).mishap()
        );
    }

    /**
     * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.DTDToken)
     */
    public void visit( final DTDToken token ) {
        throw(
            Alerts.unimplemented(
                "Document type declarations cannot be compiled at the moment, sorry!"
            ).decorate( token ).mishap()
        );
    }

    /**
     * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.ElementDeclToken)
     */
    public void visit( final ElementDeclToken token ) {
        throw(
            Alerts.unimplemented(
                "Element declarations cannot be compiled at the moment, sorry!"
            ).decorate( token ).mishap()
        );
    }

    /**
     * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.EmptyElementToken)
     */
    public void visit( final EmptyElementToken token ) {
        // TODO - Keep it simple for now, we can make it a tiny bit faster soon
        this.visit( (StartTagToken) token );
        this.visit( (EndTagToken)token );

FileLine
org/millscript/millscript/functions/GroupFunction.java151
org/millscript/millscript/functions/GroupPreserveOrderFunction.java129
                    deepGroup( mc, needsGrouping, fields, idx, limit )
                );
            }
        }
        return map;
    }

    /**
     * @see org.millscript.millscript.functions.Function#apply(org.millscript.millscript.vm.Machine, int)
     */
    @Override
    public void apply( final Machine mc, final int nargs ) {
        if ( nargs <= 0 ) {
            checkNargsGT( mc, 1, nargs );
        } else if ( nargs == 2 ) {
            Object by = mc.popObject();
            IList list = mc.popIList();
            mc.pushObject( group( mc, list, by ) );
        } else if ( nargs >= 3 ) {
            // This list will hold the fields to group by
            EList< Object > fields = new ELinkedList< Object >();
            // Pop each field name off the stack and add it to the front of the
            // list. (arguments to a function are pushed onto the stack, hence
            // you pop them off in reverse order)
            for ( int i = 1; i < nargs; i++ ) {
                fields.addFirst( mc.popObject() );
            }
            // Pop the ungrouped list of maps off the stack
            IList list = mc.popIList();
            // Push the grouped data onto the stack, i.e. from the script point
            // of  view, return the grouped data
            mc.pushObject( deepGroup( mc, list, fields, 1, nargs ) );
        }
        /* otherwise nargs == 1 and we simply fall thru */
    }
}

FileLine
org/millscript/millscript/render/PropertiesRenderer.java65
org/millscript/millscript/render/PropertiesRenderer.java111
    public void appendEscapeFor( final char ch ) throws IOException {
        switch ( ch ) {
            case '\\':
                super.outputWriter.write( '\\' );
                super.outputWriter.write( '\\' );
                break;
            case '\f':
                super.outputWriter.write( '\\' );
                super.outputWriter.write( 'f' );
                break;
            case '\n':
                super.outputWriter.write( '\\' );
                super.outputWriter.write( 'n' );
                break;
            case '\r':
                super.outputWriter.write( '\\' );
                super.outputWriter.write( 'r' );
                break;
            case '\t':
                super.outputWriter.write( '\\' );
                super.outputWriter.write( 't' );
                break;
            case '#': case '!': case '=': case ':': case ' ':
                super.outputWriter.write( '\\' );
                super.outputWriter.write( ch );
                break;
            default:

FileLine
org/millscript/millscript/render/XMLCDATARenderer.java96
org/millscript/millscript/render/AbstractRenderer.java158
        return this.outputEncoder.canEncode( ch );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#render(java.lang.Object)
     */
    public void render( final Object o ) throws IOException {
        if ( o == null ) {
            return;
        } else if ( o instanceof Renderable ) {
            ((Renderable) o).render( this );
        } else if ( o instanceof IList ) {
            MapIterator it = ((IList) o).iterator( true );
            while ( it.hasNext() ) {
                this.render( it.nextValue() );
            }
        } else if ( o instanceof List ) {
            Iterator it = ((List)o).iterator();
            while ( it.hasNext() ) {
                this.render( it.next() );
            }
        } else {
            // FIXME - This code should use the standard
            // AbstractRenderer.append(CharSequence) but we need to provide a way to
            // parse database content into an XmlElement before we can change
            // it.
            this.renderObject( o );
        }
    }


    /**
     * @see org.millscript.millscript.render.Renderer#renderAsDocument(java.lang.Object)
     */
    public final void renderAsDocument( final Object o ) {

FileLine
org/millscript/millscript/render/LinesRenderer.java54
org/millscript/millscript/render/TXTRenderer.java49
    public TXTRenderer( final Configuration conf, final VFile file ) {
        super( conf, file );
        // Make a new print writer over the basic buffered writer
        this.outputPrintWriter = new PrintWriter( this.outputWriter );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#append(char)
     */
    public void append( final char ch ) {
        this.appendNoEscape( ch );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#append(java.lang.CharSequence)
     */
    @Override
    public void append( final CharSequence cs ) {
        this.appendNoEscape( cs );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#appendEscapeFor(char)
     */
    public void appendEscapeFor( final char ch ) {
        this.appendNoEscape( ch );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#appendNoEscape(char)
     */
    public void appendNoEscape( final char ch ) {
        FormatPrint.print1( this.outputPrintWriter, new Character( ch ) );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#appendNoEscape(java.lang.CharSequence)
     */
    @Override
    public void appendNoEscape( final CharSequence cs ) {
        FormatPrint.print1( this.outputPrintWriter, cs );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#render(java.lang.Object)
     */
    @Override
    public void render( final Object o ) {

FileLine
org/millscript/millscript/functions/JdbcExecuteUpdateFunction.java73
org/millscript/millscript/functions/JdbcExecuteQueryFunction.java79
    }

    /**
     * @see org.millscript.millscript.functions.Function#apply(org.millscript.millscript.vm.Machine, int)
     */
    @Override
    public void apply( final Machine mc, final int nargs ) {

        // Check that we received at least one argument
        this.checkNargsGT( mc, 1, nargs );

        // Get any prepared statement arguments
        final Object[] prepArgs = mc.popArgsArray( nargs - 1 );

        // Pop the DataSource we will use for executing the prepared statement
        final DatabaseSource source = mc.popDatabaseSource();

        try {

            // Obtain a connection from the supplied DataSource
            Connection conn = source.getConnection();

            // First check if the supplied DataSource is the same as the one we
            // have cached from previous applications of this function.
            if ( conn != cachedConn ) {
                // Close the existing prepared statement and connection.
                if ( cachedPrep != null ) {
                    cachedPrep.close();
                }

                // Using the new connection, prepare the SQL statement
                cachedPrep = conn.prepareStatement( sql );

                // Now we're fully initialised, store the supplied DataSource.
                cachedConn = conn;
            }

            // Initialise the parameters for the prepared statement by iterating
            // through each one and setting it.
            for ( int i = 0; i < prepArgs.length; i++ ) {
                this.cachedPrep.setObject( i + 1, prepArgs[ i ] );
            }

FileLine
org/millscript/millscript/render/XMLCDATARenderer.java179
org/millscript/millscript/render/HTMLCDATARenderer.java167
        parentRenderer.appendNoEscape( o.toString() );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#renderXMLComment(org.millscript.millscript.datatypes.XmlComment)
     */
    public void renderXMLComment( final XmlComment c ) throws IOException {
        parentRenderer.renderXMLComment( c );
    }

    /**
     * @see org.millscript.millscript.render.Renderer#renderXMLElement(org.millscript.millscript.datatypes.XmlElement)
     */
    public void renderXMLElement( final XmlElement x ) throws IOException {
        parentRenderer.appendNoEscape( '<' );
        parentRenderer.appendNoEscape( x.tagName() );

        MapIterator it = x.getAttributes().iterator( true );
        while ( it.hasNext() ) {
            Object key = it.nextKey();
            Object val = it.currentValue();
            if ( key != null ) {
                parentRenderer.appendNoEscape( ' ' );
                parentRenderer.appendNoEscape( key.toString() );

FileLine
org/millscript/millscript/loaders/XMLSkeletonLoader.java71
org/millscript/millscript/loaders/SkeletonLoader.java59
                new NoNamespacesName( "field" )
            },
            new SpecialTemplateName[] {
                new ItemName( this ),
                new FieldName( this )
            },
            true
        );
    }

    /**
     * @see org.millscript.millscript.loaders.BasicTemplateLoader#compAttributeValue(java.lang.String)
     */
    @Override
    public Expr compAttributeValue( final String value ) {
        if ( value.length() > 0 && value.charAt( 0 ) == '?' ) {
            // Compile everything but the leading '?'
            // arg[ s ]
            return IndexExpr.make(
                new NameExpr( "arg" ),
                new ConstantExpr( value.substring( 1, value.length() ) )
            );
        } else {
            return new ConstantExpr( value );
        }
    }

    /**
     * @see org.millscript.millscript.loaders.BasicTemplateLoader#compileEndTag(org.millscript.commons.xml.api.token.EndTagToken)
     */
    @Override
    public void compileEndTag( final EndTagToken token ) {

FileLine
org/millscript/millscript/functions/StringToXMLTokenVisitor.java260
org/millscript/millscript/loaders/BasicTemplateLoaderTokenVisitor.java176
        ).mishap();
    }

    /**
     * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.EntityDeclToken)
     */
    public void visit( final EntityDeclToken token ) {
        throw(
            Alerts.unimplemented(
                "Entity declarations cannot be compiled at the moment, sorry!"
            ).decorate( token ).mishap()
        );
    }

    /**
     * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.NotationDeclToken)
     */
    public void visit( final NotationDeclToken token ) {
        throw(
            Alerts.unimplemented(
                "Notation declarations cannot be compiled at the moment, sorry!"
            ).decorate( token ).mishap()
        );
    }

    /**
     * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.PIToken)
     */
    public void visit( final PIToken token ) {
        throw(
            Alerts.unimplemented(
                "Processing instructions cannot be compiled at the moment, sorry!"
            ).decorate( token ).mishap()
        );
    }

    /**
     * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.StartTagToken)
     */
    public void visit( final StartTagToken token ) {
        this.basicTemplateLoader.compileStartTag( token );