org.eclipse.core.runtime.internal.adaptor
Class BasicLocation

java.lang.Object
  extended by org.eclipse.core.runtime.internal.adaptor.BasicLocation
All Implemented Interfaces:
Location

public class BasicLocation
extends java.lang.Object
implements Location

Internal class.


Field Summary
static boolean DEBUG
           
static java.lang.String PROP_OSGI_LOCKING
           
 
Fields inherited from interface org.eclipse.osgi.service.datalocation.Location
CONFIGURATION_FILTER, ECLIPSE_HOME_FILTER, INSTALL_FILTER, INSTANCE_FILTER, USER_FILTER
 
Constructor Summary
BasicLocation(java.lang.String property, java.net.URL defaultValue, boolean isReadOnly, java.lang.String dataAreaPrefix)
           
 
Method Summary
 boolean allowsDefault()
          Returns true if this location allows a default value to be assigned and false otherwise.
 Location createLocation(Location parentLocation, java.net.URL defaultLocation, boolean readonly)
          Constructs a new location.
static Locker createLocker(java.io.File lock, java.lang.String lockMode)
           
 java.net.URL getDataArea(java.lang.String filename)
          Returns a URL to the specified path within this location.
 java.net.URL getDefault()
          Returns the default value of this location if any.
 Location getParentLocation()
          Returns the parent of this location or null if none is available.
 java.net.URL getURL()
          Returns the actual URL of this location.
 boolean isLocked()
          Returns true if this location is locked and false otherwise.
 boolean isReadOnly()
          Returns true if this location represents a read only location and false otherwise.
 boolean isSet()
          Returns true if this location has a value and false otherwise.
 boolean lock()
          Attempts to lock this location with a canonical locking mechanism and return true if the lock could be acquired.
 void release()
          Releases the lock on this location.
 boolean set(java.net.URL value, boolean lock)
          Sets and optionally locks the location's value to the given URL.
 boolean set(java.net.URL value, boolean lock, java.lang.String lockFilePath)
          Sets and optionally locks the location's value to the given URL using the given lock file.
 void setParent(Location value)
           
 boolean setURL(java.net.URL value, boolean lock)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_OSGI_LOCKING

public static final java.lang.String PROP_OSGI_LOCKING
See Also:
Constant Field Values

DEBUG

public static boolean DEBUG
Constructor Detail

BasicLocation

public BasicLocation(java.lang.String property,
                     java.net.URL defaultValue,
                     boolean isReadOnly,
                     java.lang.String dataAreaPrefix)
Method Detail

createLocker

public static Locker createLocker(java.io.File lock,
                                  java.lang.String lockMode)

allowsDefault

public boolean allowsDefault()
Description copied from interface: Location
Returns true if this location allows a default value to be assigned and false otherwise.

Specified by:
allowsDefault in interface Location
Returns:
whether or not this location can have a default value assigned

getDefault

public java.net.URL getDefault()
Description copied from interface: Location
Returns the default value of this location if any. If no default is available then null is returned. Note that even locations which allow defaults may still return null.

Specified by:
getDefault in interface Location
Returns:
the default value for this location or null

getParentLocation

public Location getParentLocation()
Description copied from interface: Location
Returns the parent of this location or null if none is available.

Specified by:
getParentLocation in interface Location
Returns:
the parent of this location or null

getURL

public java.net.URL getURL()
Description copied from interface: Location
Returns the actual URL of this location. If the location's value has been set, that value is returned. If the value is not set and the location allows defaults, the value is set to the default and returned. In all other cases null is returned.

Specified by:
getURL in interface Location
Returns:
the URL for this location or null if none

isSet

public boolean isSet()
Description copied from interface: Location
Returns true if this location has a value and false otherwise.

Specified by:
isSet in interface Location
Returns:
boolean value indicating whether or not the value is set

isReadOnly

public boolean isReadOnly()
Description copied from interface: Location
Returns true if this location represents a read only location and false otherwise. The read only character of a location is not in enforced in any way but rather expresses the intention of the location's creator.

Specified by:
isReadOnly in interface Location
Returns:
boolean value indicating whether the location is read only

setURL

public boolean setURL(java.net.URL value,
                      boolean lock)
               throws java.lang.IllegalStateException
Deprecated. 

Description copied from interface: Location
Sets and optionally locks the location's value to the given URL. If the location already has a value an exception is thrown. If locking is requested and fails, false is returned and the URL of this location is not set.

Specified by:
setURL in interface Location
Parameters:
value - the value of this location
lock - whether or not to lock this location
Returns:
whether or not the location was successfully set and, if requested, locked.
Throws:
java.lang.IllegalStateException - if the location's value is already set

set

public boolean set(java.net.URL value,
                   boolean lock)
            throws java.lang.IllegalStateException,
                   java.io.IOException
Description copied from interface: Location
Sets and optionally locks the location's value to the given URL. If the location already has a value an exception is thrown. If locking is requested and fails, false is returned and the URL of this location is not set.

Specified by:
set in interface Location
Parameters:
value - the value of this location
lock - whether or not to lock this location
Returns:
whether or not the location was successfully set and, if requested, locked.
Throws:
java.lang.IllegalStateException - if the location's value is already set
java.io.IOException - if there was an unexpected problem while acquiring the lock

set

public boolean set(java.net.URL value,
                   boolean lock,
                   java.lang.String lockFilePath)
            throws java.lang.IllegalStateException,
                   java.io.IOException
Description copied from interface: Location
Sets and optionally locks the location's value to the given URL using the given lock file. If the location already has a value an exception is thrown. If locking is requested and fails, false is returned and the URL of this location is not set.

Specified by:
set in interface Location
Parameters:
value - the value of this location
lock - whether or not to lock this location
lockFilePath - the path to the lock file. This path will be used to establish locks on this location. The path may be an absolute path or it may be relative to the given URL. If a null value is used then a default lock path will be used for this location.
Returns:
whether or not the location was successfully set and, if requested, locked.
Throws:
java.lang.IllegalStateException - if the location's value is already set
java.io.IOException - if there was an unexpected problem while acquiring the lock

setParent

public void setParent(Location value)

lock

public boolean lock()
             throws java.io.IOException
Description copied from interface: Location
Attempts to lock this location with a canonical locking mechanism and return true if the lock could be acquired. Not all locations can be locked.

Locking a location is advisory only. That is, it does not prevent other applications from modifying the same location

Specified by:
lock in interface Location
Returns:
true if the lock could be acquired; otherwise false is returned
Throws:
java.io.IOException - if there was an unexpected problem while acquiring the lock

isLocked

public boolean isLocked()
                 throws java.io.IOException
Description copied from interface: Location
Returns true if this location is locked and false otherwise.

Specified by:
isLocked in interface Location
Returns:
boolean value indicating whether or not this location is locked
Throws:
java.io.IOException - if there was an unexpected problem reading the lock

release

public void release()
Description copied from interface: Location
Releases the lock on this location. If the location is not already locked, no action is taken.

Specified by:
release in interface Location

createLocation

public Location createLocation(Location parentLocation,
                               java.net.URL defaultLocation,
                               boolean readonly)
Description copied from interface: Location
Constructs a new location.

Specified by:
createLocation in interface Location
Parameters:
parentLocation - the parent location. A null value is allowed.
defaultLocation - the default value of the location. A null value is allowed.
readonly - true if the location is read-only.
Returns:
a new location.

getDataArea

public java.net.URL getDataArea(java.lang.String filename)
                         throws java.io.IOException
Description copied from interface: Location
Returns a URL to the specified path within this location. The path of the returned URL may not exist yet. It is the responsibility of the client to create the content of the data area returned if it does not exist.

This method can be used to obtain a private area within the given location. For example use the symbolic name of a bundle to obtain a data area specific to that bundle.

Clients should check if the location is read only before writing anything to the returned data area. An IOException will be thrown if this method is called and the location URL has not been set and there is no default value for this location.

Specified by:
getDataArea in interface Location
Parameters:
filename - the name of the path to get from this location
Returns:
the URL to the data area with the specified path.
Throws:
java.io.IOException - if the location URL is not already set


Copyright © 2007-2012 FuseSource, Corp.. All Rights Reserved.