Udostępnij za pośrednictwem


Properties Class

Definition

The Properties class represents a persistent set of properties.

[Android.Runtime.Register("java/util/Properties", DoNotGenerateAcw=true)]
public class Properties : Java.Lang.Object
[<Android.Runtime.Register("java/util/Properties", DoNotGenerateAcw=true)>]
type Properties = class
    inherit Object
Inheritance
Properties
Derived
Attributes

Remarks

The Properties class represents a persistent set of properties. The Properties can be saved to a stream or loaded from a stream. Each key and its corresponding value in the property list is a string.

A property list can contain another property list as its "defaults"; this second property list is searched if the property key is not found in the original property list.

Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object. Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings. The setProperty method should be used instead. If the store or save method is called on a "compromised" Properties object that contains a non-String key or value, the call will fail. Similarly, the call to the propertyNames or list method will fail if it is called on a "compromised" Properties object that contains a non-String key.

The #load(java.io.Reader) load(Reader)/#store(java.io.Writer, java.lang.String) store(Writer, String) methods load and store properties from and to a character based stream in a simple line-oriented format specified below.

The #load(java.io.InputStream) load(InputStream)/#store(java.io.OutputStream, java.lang.String) store(OutputStream, String) methods work the same way as the load(Reader)/store(Writer, String) pair, except the input/output stream is encoded in ISO 8859-1 character encoding. Characters that cannot be directly represented in this encoding can be written using Unicode escapes as defined in section 3.3 of <cite>The Java&trade; Language Specification</cite>; only a single 'u' character is allowed in an escape sequence. The native2ascii tool can be used to convert property files to and from other character encodings.

The #loadFromXML(InputStream) and #storeToXML(OutputStream, String, String) methods load and store properties in a simple XML format. By default the UTF-8 character encoding is used, however a specific encoding may be specified if required. Implementations are required to support UTF-8 and UTF-16 and may support other encodings. An XML properties document has the following DOCTYPE declaration:

&lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt;

Note that the system URI (http://java.sun.com/dtd/properties.dtd) is not accessed when exporting or importing properties; it merely serves as a string to uniquely identify the DTD, which is:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;

               &lt;!-- DTD for properties --&gt;

               &lt;!ELEMENT properties ( comment?, entry* ) &gt;

               &lt;!ATTLIST properties version CDATA #FIXED "1.0"&gt;

               &lt;!ELEMENT comment (#PCDATA) &gt;

               &lt;!ELEMENT entry (#PCDATA) &gt;

               &lt;!ATTLIST entry key CDATA #REQUIRED&gt;

This class is thread-safe: multiple threads can share a single Properties object without the need for external synchronization.

Added in JDK1.0.

Java documentation for java.util.Properties.

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

Properties()

Creates an empty property list with no default values.

Properties(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Properties(Properties)

Creates an empty property list with the specified defaults.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Defaults

A property list that contains default values for any keys not found in this property list.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
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

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)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetProperty(String, String)

Searches for the property with the specified key in this property list.

GetProperty(String)

Searches for the property with the specified key in this property list.

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)
List(PrintStream)

Prints this property list out to the specified output stream.

List(PrintWriter)

Prints this property list out to the specified output stream.

Load(Reader)

Reads a property list (key and element pairs) from the input character stream in a simple line-oriented format.

Load(Stream)

Reads a property list (key and element pairs) from the input byte stream.

LoadFromXML(Stream)

Loads all of the properties represented by the XML document on the specified input stream into this properties table.

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)
PropertyNames()

Returns an enumeration of all the keys in this property list, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.

Save(Stream, String)
Obsolete.

Calls the store(OutputStream out, String comments) method and suppresses IOExceptions that were thrown.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetProperty(String, String)

Calls the Hashtable method put.

Store(Stream, String)

Writes this property list (key and element pairs) in this Properties table to the output stream in a format suitable for loading into a Properties table using the #load(InputStream) load(InputStream) method.

Store(Writer, String)

Writes this property list (key and element pairs) in this Properties table to the output character stream in a format suitable for using the #load(java.io.Reader) load(Reader) method.

StoreToXML(Stream, String, String)

Emits an XML document representing all of the properties contained in this table, using the specified encoding.

StoreToXML(Stream, String)

Emits an XML document representing all of the properties contained in this table.

StringPropertyNames()

Returns a set of keys in this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
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