Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.netbeans.modules.project.ant/1 1.12.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.netbeans.spi.project.support.ant
Class PropertyUtils

    java.lang.Object
      org.netbeans.spi.project.support.ant.PropertyUtils

    public class PropertyUtils

extends Object

Support for working with Ant properties and property files.

Method Summary
`static PropertyProvider` | `fixedPropertyProvider(Map defs)` Create a trivial property producer using only a fixed list of property definitions.
`static EditableProperties` | `getGlobalProperties()` Load global properties defined by the IDE in the user directory.
`static String` | `getUsablePropertyName(String name)` Returns name usable as Ant property which is based on the given name.
`static PropertyProvider` | `globalPropertyProvider()` Create a property evaluator based on `getGlobalProperties()` and `putGlobalProperties(org.netbeans.spi.project.support.ant.EditableProperties)`.
`static boolean` | `isUsablePropertyName(String name)` Checks whether the name is usable as Ant property name.
`static PropertyProvider` | `propertiesFilePropertyProvider(File propertiesFile)` Create a property provider based on a properties file.
`static void` | `putGlobalProperties(EditableProperties properties)` Edit global properties defined by the IDE in the user directory.
`static String` | `relativizeFile(File basedir, File file)` Produce a machine-independent relativized version of a filename from a basedir.
`static File` | `resolveFile(File basedir, String filename)` Find an absolute file path from a possibly relative path.
`static PropertyEvaluator` | `sequentialPropertyEvaluator(PropertyProvider preprovider, PropertyProvider[] providers)` Create a property evaluator based on a series of definitions.
`static String[]` | `tokenizePath(String path)` Split an Ant-style path specification into components.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getGlobalProperties

    public static EditableProperties getGlobalProperties()

  Load global properties defined by the IDE in the user directory. Currently loads ${netbeans.user}/build.properties if it exists.

  Acquires read access.

  To listen to changes use `globalPropertyProvider()`.

  Returns:
    user properties (empty if missing or malformed)

### putGlobalProperties

    public static void putGlobalProperties(EditableProperties properties)
                                    throws IOException

  Edit global properties defined by the IDE in the user directory.

  Acquires write access.

  Parameters:
    `properties` - user properties to set
  Throws:
    `IOException` - if they could not be stored
  See Also:
    `getGlobalProperties()`

### globalPropertyProvider

    public static PropertyProvider globalPropertyProvider()

  Create a property evaluator based on `getGlobalProperties()` and `putGlobalProperties(org.netbeans.spi.project.support.ant.EditableProperties)`. It will supply global properties and fire changes when this file is changed.

  Returns:
    a property producer

### propertiesFilePropertyProvider

    public static PropertyProvider propertiesFilePropertyProvider(File propertiesFile)

  Create a property provider based on a properties file. The file need not exist at the moment; if it is created or deleted an appropriate change will be fired. If its contents are changed on disk a change will also be fired.

  Parameters:
    `propertiesFile` - a path to a (possibly nonexistent) *.properties file
  Returns:
    a supplier of properties from such a file
  See Also:
    `Properties.load(java.io.InputStream)`

### resolveFile

    public static File resolveFile(File basedir,
                                   String filename)
                            throws IllegalArgumentException

  Find an absolute file path from a possibly relative path.

  Parameters:
    `basedir` - base file for relative filename resolving; must be an absolute path
    `filename` - a pathname which may be relative or absolute and may use / or \ as the path separator
  Returns:
    an absolute file corresponding to it
  Throws:
    `IllegalArgumentException` - if basedir is not absolute

### relativizeFile

    public static String relativizeFile(File basedir,
                                        File file)

  Produce a machine-independent relativized version of a filename from a basedir. Unlike `URI.relativize(java.net.URI)` this will produce "../" sequences as needed.

  Parameters:
    `basedir` - a directory to resolve relative to (need not exist on disk)
    `file` - a file or directory to find a relative path for
  Returns:
    a relativized path (slash-separated), or null if it is not possible (e.g. different DOS drives); just `.` in case the paths are the same
  Throws:
    `IllegalArgumentException` - if the basedir is known to be a file and not a directory

### tokenizePath

    public static String[] tokenizePath(String path)

  Split an Ant-style path specification into components. Tokenizes on `:` and `;`, paying attention to DOS-style components such as `C:\FOO`. Also removes any empty components.

  Parameters:
    `path` - an Ant-style path (elements arbitrary) using DOS or Unix separators
  Returns:
    a tokenization of that path into components

### isUsablePropertyName

    public static boolean isUsablePropertyName(String name)

  Checks whether the name is usable as Ant property name.

  Parameters:
    `name` - name to check for usability as Ant property
  Returns:
    true if name is usable otherwise false

### getUsablePropertyName

    public static String getUsablePropertyName(String name)

  Returns name usable as Ant property which is based on the given name. All forbidden characters are either removed or replaced with suitable ones.

  Parameters:
    `name` - name to use as base for Ant property name
  Returns:
    name usable as Ant property name

### fixedPropertyProvider

    public static PropertyProvider fixedPropertyProvider(Map defs)

  Create a trivial property producer using only a fixed list of property definitions. Its values are constant, and it never fires changes.

  Parameters:
    `defs` - a map from property names to values (it is illegal to modify this map after passing it to this method)
  Returns:
    a matching property producer

### sequentialPropertyEvaluator

    public static PropertyEvaluator sequentialPropertyEvaluator(PropertyProvider preprovider,
                                                                PropertyProvider[] providers)

  Create a property evaluator based on a series of definitions.

  Each batch of definitions can refer to properties within itself (so long as there is no cycle) or any previous batch. However the special first provider cannot refer to properties within itself.

  This implementation acquires `ProjectManager.mutex()` for all operations, in read mode, and fires changes synchronously. It also expects changes to be fired from property providers in read (or write) access.

  Parameters:
    `preprovider` - an initial context (may be null)
    `providers` - a sequential list of property groups
  Returns:
    an evaluator

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.netbeans.modules.project.ant/1 1.12.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Built on December 7 2006. | Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.