org.sonar.api.resources
Class JavaPackage

java.lang.Object
  extended by org.sonar.api.resources.JavaPackage
All Implemented Interfaces:
Resource

public class JavaPackage
extends Object
implements Resource

A class that represents a Java package in Sonar

Since:
1.10

Field Summary
static String DEFAULT_PACKAGE_NAME
          Default package name for classes without package definition
 
Fields inherited from interface org.sonar.api.resources.Resource
QUALIFIER_CLASS, QUALIFIER_DIRECTORY, QUALIFIER_FILE, QUALIFIER_MODULE, QUALIFIER_PACKAGE, QUALIFIER_PROJECT, QUALIFIER_PROJECT_BRANCH, QUALIFIER_PROJECT_TRUNK, QUALIFIER_SUBVIEW, QUALIFIER_UNIT_TEST_CLASS, QUALIFIER_VIEW, SCOPE_DIRECTORY, SCOPE_ENTITY, SCOPE_FILE, SCOPE_PROJECT, SCOPE_SET, SCOPE_SPACE
 
Constructor Summary
JavaPackage()
          Defaul constructor
JavaPackage(String key)
          Creates a JavaPackage from its key.
 
Method Summary
 boolean equals(Object obj)
           
 String getDescription()
          
 String getKey()
          
 Language getLanguage()
           
 String getLongName()
          
 String getName()
          
 Resource<?> getParent()
          The parent is used to build the resources tree, for example for relations between classes, packages and projects.
 String getQualifier()
           
 String getScope()
           
 int hashCode()
           
 boolean isDefault()
           
 boolean matchFilePattern(String antPattern)
          Check resource against an Ant pattern, like mypackag?/*Foo.java.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PACKAGE_NAME

public static final String DEFAULT_PACKAGE_NAME
Default package name for classes without package definition

See Also:
Constant Field Values
Constructor Detail

JavaPackage

public JavaPackage()
Defaul constructor


JavaPackage

public JavaPackage(String key)
Creates a JavaPackage from its key. Will use DEFAULT_PACKAGE_NAME if key is null

Method Detail

isDefault

public boolean isDefault()
Returns:
whether the JavaPackage key is the defult key

matchFilePattern

public boolean matchFilePattern(String antPattern)
Check resource against an Ant pattern, like mypackag?/*Foo.java. It's used for example to match resource exclusions.

Specified by:
matchFilePattern in interface Resource
Parameters:
antPattern - Ant-like pattern (with **, * and ?). It includes file suffixes.
Returns:
true if the resource matches the Ant pattern

getKey

public String getKey()

Specified by:
getKey in interface Resource
Returns:
the resource key

getDescription

public String getDescription()

Specified by:
getDescription in interface Resource
Returns:
the resource description

getScope

public String getScope()
Specified by:
getScope in interface Resource
Returns:
SCOPE_SPACE

getQualifier

public String getQualifier()
Specified by:
getQualifier in interface Resource
Returns:
QUALIFIER_PACKAGE

getName

public String getName()

Specified by:
getName in interface Resource
Returns:
the resource name

getParent

public Resource<?> getParent()
The parent is used to build the resources tree, for example for relations between classes, packages and projects.

Return null if the parent is the project.

Specified by:
getParent in interface Resource

getLongName

public String getLongName()

Specified by:
getLongName in interface Resource
Returns:
the resource long name

getLanguage

public Language getLanguage()
Specified by:
getLanguage in interface Resource
Returns:
Java

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009 SonarSource SA. All Rights Reserved.