org.netbeans.modules.java.api.common/0 1.37

org.netbeans.modules.java.api.common
Class SourceRoots

java.lang.Object
  extended by org.netbeans.modules.java.api.common.Roots
      extended by org.netbeans.modules.java.api.common.SourceRoots

public final class SourceRoots
extends Roots

Represents a project source roots. It can be used to obtain source roots as Ant properties, FileObject's or URLs. This class is thread safe and listens to the changes in Ant project metadata (see PROP_ROOT_PROPERTIES) as well as in project properties (see PROP_ROOTS).


Field Summary
static String DEFAULT_SOURCE_LABEL
          Default label for sources node used in LogicalViewProvider.
static String DEFAULT_TEST_LABEL
          Default label for tests node used in LogicalViewProvider.
static String PROP_ROOT_PROPERTIES
          Property name of a event that is fired when Ant project metadata change.
static String PROP_ROOTS
          Property name of a event that is fired when project properties change.
 
Method Summary
static SourceRoots create(UpdateHelper helper, PropertyEvaluator evaluator, ReferenceHelper refHelper, String projectConfigurationNamespace, String elementName, boolean isTest, String newRootNameTemplate)
           
 String createInitialDisplayName(File sourceRoot)
          Creates initial display name of source/test root.
 String getRootDisplayName(String rootName, String propName)
          Translates root name into display name of source/test root.
 String[] getRootDisplayNames()
          Returns root's display names
 String[] getRootNames()
          Returns the display names of source roots.
 String[] getRootProperties()
          Returns names of Ant properties in the project.properties file holding the roots.
 FileObject[] getRoots()
          Returns the source roots in the form of absolute paths.
 URL[] getRootURLs()
          Returns the source roots as URLs.
 boolean isTest()
          Returns true if the current SourceRoots instance represents source roots belonging to the test compilation unit.
 void putRoots(URL[] roots, String[] labels)
          Replaces the current roots by the given ones.
 
Methods inherited from class org.netbeans.modules.java.api.common.Roots
addPropertyChangeListener, nonSourceRoots, propertyBased, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_ROOT_PROPERTIES

public static final String PROP_ROOT_PROPERTIES
Property name of a event that is fired when Ant project metadata change.


PROP_ROOTS

public static final String PROP_ROOTS
Property name of a event that is fired when project properties change.


DEFAULT_SOURCE_LABEL

public static final String DEFAULT_SOURCE_LABEL
Default label for sources node used in LogicalViewProvider.


DEFAULT_TEST_LABEL

public static final String DEFAULT_TEST_LABEL
Default label for tests node used in LogicalViewProvider.

Method Detail

create

public static SourceRoots create(UpdateHelper helper,
                                 PropertyEvaluator evaluator,
                                 ReferenceHelper refHelper,
                                 String projectConfigurationNamespace,
                                 String elementName,
                                 boolean isTest,
                                 String newRootNameTemplate)

getRootNames

public String[] getRootNames()
Returns the display names of source roots. The returned array has the same length as an array returned by the getRootProperties(). It may contain empty Strings but not null.

Returns:
an array of source roots names.

getRootDisplayNames

public String[] getRootDisplayNames()
Description copied from class: Roots
Returns root's display names

Specified by:
getRootDisplayNames in class Roots
Returns:
an array of String

getRootProperties

public String[] getRootProperties()
Description copied from class: Roots
Returns names of Ant properties in the project.properties file holding the roots.

Specified by:
getRootProperties in class Roots
Returns:
an array of String.

getRoots

public FileObject[] getRoots()
Returns the source roots in the form of absolute paths.

Returns:
an array of FileObjects.

getRootURLs

public URL[] getRootURLs()
Returns the source roots as URLs.

Returns:
an array of URL.

putRoots

public void putRoots(URL[] roots,
                     String[] labels)
Replaces the current roots by the given ones.

Parameters:
roots - the URLs of the new roots.
labels - the names of the new roots.

getRootDisplayName

public String getRootDisplayName(String rootName,
                                 String propName)
Translates root name into display name of source/test root.

Parameters:
rootName - the name of root got from getRootNames().
propName - the name of a property the root is stored in.
Returns:
the label to be displayed.

createInitialDisplayName

public String createInitialDisplayName(File sourceRoot)
Creates initial display name of source/test root.

Parameters:
sourceRoot - the source root.
Returns:
the label to be displayed.

isTest

public boolean isTest()
Returns true if the current SourceRoots instance represents source roots belonging to the test compilation unit.

Returns:
boolean true if the instance belongs to the test compilation unit, false otherwise.

org.netbeans.modules.java.api.common/0 1.37

Built on May 22 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.