Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2004, 2010 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 package org.eclipse.osgi.service.datalocation;
 
 import java.net.URL;

A Location represents a URL which may have a default value, may be read only, may or may not have a current value and may be cascaded on to a parent location.

This interface is not intended to be implemented by clients.

Since:
3.0
Noimplement:
This interface is not intended to be implemented by clients.
 
 public interface Location {

Constant which defines the filter string for acquiring the service which specifies the instance location.

Since:
3.2
 
 	public static final String INSTANCE_FILTER = "(&(objectClass=" + Location.class.getName() + ")(type=osgi.instance.area))"//$NON-NLS-1$ //$NON-NLS-2$
 
Constant which defines the filter string for acquiring the service which specifies the install location.

Since:
3.2
 
 	public static final String INSTALL_FILTER = "(&(objectClass=" + Location.class.getName() + ")(type=osgi.install.area))"//$NON-NLS-1$ //$NON-NLS-2$
 
Constant which defines the filter string for acquiring the service which specifies the configuration location.

Since:
3.2
 
 	public static final String CONFIGURATION_FILTER = "(&(objectClass=" + Location.class.getName() + ")(type=osgi.configuration.area))"//$NON-NLS-1$ //$NON-NLS-2$
 
Constant which defines the filter string for acquiring the service which specifies the user location.

Since:
3.2
 
 	public static final String USER_FILTER = "(&(objectClass=" + Location.class.getName() + ")(type=osgi.user.area))"//$NON-NLS-1$ //$NON-NLS-2$
 
Constant which defines the filter string for acquiring the service which specifies the eclipse home location.

Since:
3.4
 
 	public static final String ECLIPSE_HOME_FILTER = "(&(objectClass=" + Location.class.getName() + ")(type=eclipse.home.location))"//$NON-NLS-1$ //$NON-NLS-2$
 
Returns true if this location allows a default value to be assigned and false otherwise.

Returns:
whether or not this location can have a default value assigned
 
 	public boolean allowsDefault();

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.

Returns:
the default value for this location or null
 
 	public URL getDefault();

Returns the parent of this location or null if none is available.

Returns:
the parent of this location or null
 
Returns the actual java.net.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.

Returns:
the URL for this location or null if none
 
	public URL getURL();

Returns true if this location has a value and false otherwise.

Returns:
boolean value indicating whether or not the value is set
	public boolean isSet();

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.

Returns:
boolean value indicating whether the location is read only
	public boolean isReadOnly();

Sets and optionally locks the location's value to the given java.net.URL. If the location already has a value an exception is thrown. If locking is requested and fails, false is returned and the java.net.URL of this location is not set.

Deprecated:
use set(java.net.URL,boolean) instead.
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
	public boolean setURL(URL valueboolean lockthrows IllegalStateException;

Sets and optionally locks the location's value to the given java.net.URL. If the location already has a value an exception is thrown. If locking is requested and fails, false is returned and the java.net.URL of this location is not set.

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
Since:
3.4
	public boolean set(URL valueboolean lockthrows IllegalStateExceptionIOException;

Sets and optionally locks the location's value to the given java.net.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 java.net.URL of this location is not set.

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
Since:
3.5
	public boolean set(URL valueboolean lockString lockFilePaththrows IllegalStateExceptionIOException;

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

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
	public boolean lock() throws IOException;

Releases the lock on this location. If the location is not already locked, no action is taken.
	public void release();

Returns true if this location is locked and false otherwise.

Returns:
boolean value indicating whether or not this location is locked
Throws:
java.io.IOException if there was an unexpected problem reading the lock
Since:
3.4
	public boolean isLocked() throws IOException;

Constructs a new location.

Parameters:
parent the parent location. A null value is allowed.
defaultValue the default value of the location. A null value is allowed.
readonly true if the location is read-only.
Returns:
a new location.
Since:
3.4
	public Location createLocation(Location parentURL defaultValueboolean readonly);

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.

Parameters:
path 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
Since:
3.6
	public URL getDataArea(String paththrows IOException;
New to GrepCode? Check out our FAQ X