Udostępnij za pośrednictwem


AbstractPreferences Class

Definition

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
AbstractPreferences
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 childSpishould 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 Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsRemoved

Returns true iff this node (or an ancestor) has been removed with the #removeNode() method.

IsUserNode

Implements the isUserNode method as per the specification in Preferences#isUserNode().

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
Lock

An object whose monitor is used to lock this node.

NewNode

This field should be true if this node did not exist in the backing store prior to the creation of this object.

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 absolutePath method as per the specification in Preferences#absolutePath().

AddNodeChangeListener(INodeChangeListener)

Registers a NodeChangeListener instance for this node, which will handle NodeChangeEvents.

AddPreferenceChangeListener(IPreferenceChangeListener)

Registers a PreferenceChangeListener instance for this node, which will handle PreferenceChangeEvents.

CachedChildren()

Returns all known unremoved children of this node.

ChildrenNames()

Implements the children method as per the specification in Preferences#childrenNames().

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 clear method as per the specification in Preferences#clear().

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 exportNode method as per the specification in Preferences#exportNode(OutputStream).

ExportNodeAsync(Stream) (Inherited from Preferences)
ExportSubtree(Stream)

Implements the exportSubtree method as per the specification in Preferences#exportSubtree(OutputStream).

ExportSubtreeAsync(Stream) (Inherited from Preferences)
Flush()

Implements the flush method as per the specification in Preferences#flush().

FlushAsync() (Inherited from Preferences)
FlushSpi()

This method is invoked with this node locked.

Get(String, String)

Implements the get method as per the specification in Preferences#get(String,String).

GetBoolean(String, Boolean)

Implements the getBoolean method as per the specification in Preferences#getBoolean(String,boolean).

GetByteArray(String, Byte[])

Implements the getByteArray method as per the specification in Preferences#getByteArray(String,byte[]).

GetChild(String)

Returns the named child if it exists, or null if it does not.

GetDouble(String, Double)

Implements the getDouble method as per the specification in Preferences#getDouble(String,double).

GetFloat(String, Single)

Implements the getFloat method as per the specification in Preferences#getFloat(String,float).

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetInt(String, Int32)

Implements the getInt method as per the specification in Preferences#getInt(String,int).

GetLong(String, Int64)

Implements the getLong method as per the specification in Preferences#getLong(String,long).

GetSpi(String)

Return the value associated with the specified key at this preference node, or null if there is no association for this key, or the association cannot be determined at this time.

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 keys method as per the specification in Preferences#keys().

KeysSpi()

Returns all of the keys that have an associated value in this preference node.

Name()

Implements the name method as per the specification in Preferences#name().

Node(String)

Implements the node method as per the specification in Preferences#node(String).

NodeExists(String)

Implements the nodeExists method as per the specification in Preferences#nodeExists(String).

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 parent method as per the specification in Preferences#parent().

Put(String, String)

Implements the put method as per the specification in Preferences#put(String,String).

PutBoolean(String, Boolean)

Implements the putBoolean method as per the specification in Preferences#putBoolean(String,boolean).

PutByteArray(String, Byte[])

Implements the putByteArray method as per the specification in Preferences#putByteArray(String,byte[]).

PutDouble(String, Double)

Implements the putDouble method as per the specification in Preferences#putDouble(String,double).

PutFloat(String, Single)

Implements the putFloat method as per the specification in Preferences#putFloat(String,float).

PutInt(String, Int32)

Implements the putInt method as per the specification in Preferences#putInt(String,int).

PutLong(String, Int64)

Implements the putLong method as per the specification in Preferences#putLong(String,long).

PutSpi(String, String)

Put the given key-value association into this preference node.

Remove(String)

Implements the remove(String) method as per the specification in Preferences#remove(String).

RemoveNode()

Implements the removeNode() method as per the specification in Preferences#removeNode().

RemoveNodeChangeListener(INodeChangeListener)

Removes the given NodeChangeListener instance from this node.

RemoveNodeSpi()

Removes this preference node, invalidating it and any preferences that it contains.

RemovePreferenceChangeListener(IPreferenceChangeListener)

Removes the given PreferenceChangeListener instance from this node.

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 sync method as per the specification in Preferences#sync().

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)

Applies to