under construction under construction
Under construction

CStringProperties

StringProperties are maps of properties whose key and value consist of strings. A key-value pair is represented by the CStringProperty class.

The class keeps a dirty flag by which you can see if values have been changed, dropped or added.

The class implements the IReadOnlyStringProperties interface.

Constructors

The default constructor creates an empty property list.

public CStringProperties();

There is a copy constructor.

public CStringProperties(@Nullable final IReadOnlyStringProperties aValue);

This constructor fills the list using a string in the form "key1=value1,key2=value2".

public CStringProperties(@Nullable final String aProperties);

This factory method creates a Property List from a list of strings that have the form "key=value".

@NotNull
public static CStringProperties fromList(@Nullable final List<?> aList) throws CException;

Stream I/O

This static method creates a property list from a DataInput stream.

@NotNull
public static CStringProperties fromStream(@NotNull final DataInput aStream) throws IOException;

String I/O

This Method fills the list using a string in the form "key1=value1|key2=value2". String arrays use this notation with pipes when packing data into a single string.

@NotNull
public static CStringProperties fromStringArrayString(@Nullable final String aString) throws CException;

Test

For testing purposes you can generate a random list. You can specify the desired size of the list.

@NotNull
public static Object random(final int aSize);

Filling the list

Adds an entry. Returns true if the list has been modified.

public boolean put(@NotNull final String aKey,
                   @NotNull final String aValue);

Adds an entry. Returns true if the list has been modified.

public boolean put(@NotNull final CStringProperty aProperty);

Adds an entry in the form "key=value". Returns true if the list has been modified.

public boolean put(@NotNull final String aKeyValue) throws CException;

Take over all entries of the other list.

@NotNull
public CStringProperties addAll(@Nullable final CStringProperties aProperties);

Add all entries that are not included in this list.

public void addMissing(@NotNull final CStringProperties aDefaultProperties);

Check if all entries of the other list are present in this list.

public boolean contains(@NotNull final CStringProperties aFilter);

Includes the entry if it is not already in the list. If the key already exists in this list, the old value is not changed.

public void ensure(@NotNull final String aKey,
                   @NotNull final String aValue);

If the key aKey exists in the passed list, the value is copied to the own list.

public void takeOverIf(@NotNull final CStringProperties aAttributes,
                       @NotNull final String aKey);

Entfernen von Eintr├Ągen

Removes an entry.

public String remove(@NotNull final String aKey);

Get

Checks if the key already exists.

public boolean existKey(@NotNull final String aKey);

Fetches a value based on a key. If the key does not exist in the list, null is returned.

public String get(@NotNull final String aKey);

Fetches a value based on a key. If the key does not exist in the list, the default value is returned.

public String get(@NotNull final String aKey,
                  @Nullable final String aDefault);

Fetches a value. But before that the key is normalized. If the key does not exist in the list, null is returned.

public String getNormalized(@NotNull final String aKey);

Fetches a value. But before that the key is normalized. If the key does not exist in the list, the default value is returned.

public String getNormalized(@NotNull final String aKey,
                            @Nullable final String aDefault);

Searches the value using multiple keys. The first hit is returned. If no key exists in the list, the default value is returned.

public String get(@NotNull final String @NotNull [] aKeys,
                  @Nullable final String aDefault);

Searches for keys in this list that are also contained in the passed list. The properties with the values of the own list are returned. If aRemove==true, the keys are deleted from the own list.

@NotNull
public CStringProperties getDoubles(@NotNull final IReadOnlyStringProperties aCompare,
                                    final boolean aRemove);

Returns a list of all properties that exist in both lists. If aValueFromCompare==true, the values of the passed list are returned, otherwise the values of the own list.

@NotNull
public CStringProperties getExisting(@NotNull final IReadOnlyStringProperties aCompare,
                                     final boolean aValueFromCompare);

Returns a list of all properties that exist in both lists. If aValueFromCompare==true, the values of the passed list are returned, otherwise the values of the own list. If aRemove==true, the keys are deleted from the own list.

public CStringProperties getExisting(@NotNull final IReadOnlyStringProperties aCompare,
                                     final boolean aRemove,
                                     final boolean aValueFromCompare);

Fetches a list of all keys.

@NotNull
public Collection<String> getKeys();

Returns the number of entries in the list.

public int size();

Returns a copy of the list.

@NotNull
public CStringProperties copy();

Checks

Checks if the list is empty.

public boolean isEmpty();

Checks if all keys of the passed list are present in the own list.

public boolean match(@Nullable final IReadOnlyStringProperties aProperties);

Stream I/O

Writes the list to a DataOutput stream.

public void toStream(@NotNull final DataOutput aStream) throws IOException;

String I/O

Generates a list of strings in the form "key=value".

public void valueToList(@NotNull final List<String> aList);

Creates a string containing the properties of the list in the form "key1=value1|key2=value2".

@NotNull
public String valueToString();

Dirty flag

Checks if the list has been modified.

public boolean isDirty();

Resets the dirty flag.

public void resetDirtyFlag();

Homepage of nyssr.net and RemoteSkin