AbstractPreferences Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This class provides a skeletal implementation of the Preferences
class, greatly easing the task of implementing it.
[Android.Runtime.Register("java/util/prefs/AbstractPreferences", DoNotGenerateAcw=true)]
public abstract class AbstractPreferences : Java.Util.Prefs.Preferences
[<Android.Runtime.Register("java/util/prefs/AbstractPreferences", DoNotGenerateAcw=true)>]
type AbstractPreferences = class
inherit Preferences
- Inheritance
- Attributes
Remarks
This class provides a skeletal implementation of the Preferences
class, greatly easing the task of implementing it.
<strong>This class is for Preferences
implementers only. Normal users of the Preferences
facility should have no need to consult this documentation. The Preferences
documentation should suffice.</strong>
Implementors must override the nine abstract service-provider interface (SPI) methods: #getSpi(String)
, #putSpi(String,String)
, #removeSpi(String)
, #childSpi(String)
, #removeNodeSpi()
, #keysSpi()
, #childrenNamesSpi()
, #syncSpi()
and #flushSpi()
. All of the concrete methods specify precisely how they are implemented atop these SPI methods. The implementor may, at his discretion, override one or more of the concrete methods if the default implementation is unsatisfactory for any reason, such as performance.
The SPI methods fall into three groups concerning exception behavior. The getSpi
method should never throw exceptions, but it doesn't really matter, as any exception thrown by this method will be intercepted by #get(String,String)
, which will return the specified default value to the caller. The removeNodeSpi, keysSpi, childrenNamesSpi, syncSpi
and flushSpi
methods are specified to throw BackingStoreException
, and the implementation is required to throw this checked exception if it is unable to perform the operation. The exception propagates outward, causing the corresponding API method to fail.
The remaining SPI methods #putSpi(String,String)
, #removeSpi(String)
and #childSpi(String)
have more complicated exception behavior. They are not specified to throw BackingStoreException
, as they can generally obey their contracts even if the backing store is unavailable. This is true because they return no information and their effects are not required to become permanent until a subsequent call to Preferences#flush()
or Preferences#sync()
. Generally speaking, these SPI methods should not throw exceptions. In some implementations, there may be circumstances under which these calls cannot even enqueue the requested operation for later processing. Even under these circumstances it is generally better to simply ignore the invocation and return, rather than throwing an exception. Under these circumstances, however, all subsequent invocations of flush()
and sync
should return false
, as returning true
would imply that all previous operations had successfully been made permanent.
There is one circumstance under which putSpi, removeSpi and childSpi
should throw an exception: if the caller lacks sufficient privileges on the underlying operating system to perform the requested operation. This will, for instance, occur on most systems if a non-privileged user attempts to modify system preferences. (The required privileges will vary from implementation to implementation. On some implementations, they are the right to modify the contents of some directory in the file system; on others they are the right to modify contents of some key in a registry.) Under any of these circumstances, it would generally be undesirable to let the program continue executing as if these operations would become permanent at a later time. While implementations are not required to throw an exception under these circumstances, they are encouraged to do so. A SecurityException
would be appropriate.
Most of the SPI methods require the implementation to read or write information at a preferences node. The implementor should beware of the fact that another VM may have concurrently deleted this node from the backing store. It is the implementation's responsibility to recreate the node if it has been deleted.
Implementation note: In Sun's default Preferences
implementations, the user's identity is inherited from the underlying operating system and does not change for the lifetime of the virtual machine. It is recognized that server-side Preferences
implementations may have the user identity change from request to request, implicitly passed to Preferences
methods via the use of a static ThreadLocal
instance. Authors of such implementations are strongly encouraged to determine the user at the time preferences are accessed (for example by the #get(String,String)
or #put(String,String)
method) rather than permanently associating a user with each Preferences
instance. The latter behavior conflicts with normal Preferences
usage and would lead to great confusion.
Added in 1.4.
Java documentation for java.util.prefs.AbstractPreferences
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Constructors
AbstractPreferences(AbstractPreferences, String) |
Creates a preference node with the specified parent and the specified name relative to its parent. |
AbstractPreferences(IntPtr, JniHandleOwnership) |
A constructor used when creating managed representations of JNI objects; called by the runtime. |
Fields
MaxKeyLength |
Maximum length of string allowed as a key (80 characters). (Inherited from Preferences) |
MaxNameLength |
Maximum length of a node name (80 characters). (Inherited from Preferences) |
MaxValueLength |
Maximum length of string allowed as a value (8192 characters). (Inherited from Preferences) |
Properties
Class |
Returns the runtime class of this |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
IsRemoved |
Returns |
IsUserNode |
Implements the |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
Lock |
An object whose monitor is used to lock this node. |
NewNode |
This field should be |
PeerReference | (Inherited from Object) |
ThresholdClass |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
ThresholdType |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
Methods
AbsolutePath() |
Implements the |
AddNodeChangeListener(INodeChangeListener) |
Registers a |
AddPreferenceChangeListener(IPreferenceChangeListener) |
Registers a |
CachedChildren() |
Returns all known unremoved children of this node. |
ChildrenNames() |
Implements the |
ChildrenNamesSpi() |
Returns the names of the children of this preference node. |
ChildSpi(String) |
Returns the named child of this preference node, creating it if it does not already exist. |
Clear() |
Implements the |
Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
ExportNode(Stream) |
Implements the |
ExportNodeAsync(Stream) | (Inherited from Preferences) |
ExportSubtree(Stream) |
Implements the |
ExportSubtreeAsync(Stream) | (Inherited from Preferences) |
Flush() |
Implements the |
FlushAsync() | (Inherited from Preferences) |
FlushSpi() |
This method is invoked with this node locked. |
Get(String, String) |
Implements the |
GetBoolean(String, Boolean) |
Implements the |
GetByteArray(String, Byte[]) |
Implements the |
GetChild(String) |
Returns the named child if it exists, or |
GetDouble(String, Double) |
Implements the |
GetFloat(String, Single) |
Implements the |
GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
GetInt(String, Int32) |
Implements the |
GetLong(String, Int64) |
Implements the |
GetSpi(String) |
Return the value associated with the specified key at this preference
node, or |
JavaFinalize() |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
Keys() |
Implements the |
KeysSpi() |
Returns all of the keys that have an associated value in this preference node. |
Name() |
Implements the |
Node(String) |
Implements the |
NodeExists(String) |
Implements the |
Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
NotifyAll() |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
Parent() |
Implements the |
Put(String, String) |
Implements the |
PutBoolean(String, Boolean) |
Implements the |
PutByteArray(String, Byte[]) |
Implements the |
PutDouble(String, Double) |
Implements the |
PutFloat(String, Single) |
Implements the |
PutInt(String, Int32) |
Implements the |
PutLong(String, Int64) |
Implements the |
PutSpi(String, String) |
Put the given key-value association into this preference node. |
Remove(String) |
Implements the |
RemoveNode() |
Implements the |
RemoveNodeChangeListener(INodeChangeListener) |
Removes the given |
RemoveNodeSpi() |
Removes this preference node, invalidating it and any preferences that it contains. |
RemovePreferenceChangeListener(IPreferenceChangeListener) |
Removes the given |
RemoveSpi(String) |
Remove the association (if any) for the specified key at this preference node. |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
Sync() |
Implements the |
SyncAsync() | (Inherited from Preferences) |
SyncSpi() |
This method is invoked with this node locked. |
ToArray<T>() | (Inherited from Object) |
ToString() |
Returns the absolute path name of this preferences node. |
UnregisterFromRuntime() | (Inherited from Object) |
Wait() |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>. (Inherited from Object) |
Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Explicit Interface Implementations
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |