Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (C) 2011 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.codehaus.gmavenplus.util;
This class exists solely to trick JavaStubCompilationUnit.addSource(java.io.File) into letting us use files that don't end in ".groovy".

Author(s):
Keegan Witt
public class DotGroovyFile extends File {
    // TODO: make this class unnecessary?

    
Constructs a new DotGroovyFile object with the specified parameters.

Parameters:
pathname pathname to use to create DotGroovyFile
    public DotGroovyFile(String pathname) {
        super(pathname);
    }

    
Constructs a new DotGroovyFile object with the specified parameters.

Parameters:
parent parent pathname to use to create DotGroovyFile
child child pathname to use to create DotGroovyFile
    public DotGroovyFile(String parentString child) {
        super(parentchild);
    }

    
Constructs a new DotGroovyFile object with the specified parameters.

Parameters:
parent parent file to use to create DotGroovyFile
child child pathname to use to create DotGroovyFile
    public DotGroovyFile(File parentString child) {
        super(parentchild);
    }

    
Constructs a new DotGroovyFile object with the specified parameters.

Parameters:
uri URI to use to create DotGroovyFile
    public DotGroovyFile(URI uri) {
        super(uri);
    }

    
A convenience constructor to turn a regular file into a DotGroovyFile.

Parameters:
file File to use to create DotGroovyFile
    public DotGroovyFile(File file) {
        this(file.getAbsolutePath());
    }

    
A method to lie about the file extension and say it is ".groovy" (as long as the original extension was not ".java").

Returns:
filename with forced .groovy extension.
    public String getName() {
        if (!super.getName().toLowerCase().endsWith(".java")) {
            return super.getName().replaceAll("\\.[A-z]+$"".groovy");
        } else {
            return super.getName();
        }
    }
New to GrepCode? Check out our FAQ X