JavaPropertiesObject

Extends\org\turbocommons\src\main\php\model\HashMapObject

Object that stores java properties file format data

package

Default

Methods

An Object that defines a sorted collection of key/value pairs and all their related operations.

__construct(array $data = null)
inherited

Arguments

$data

array

A value that will be used to initialize the HashMapObject. It can be an associative array (where each key/value will be directly assigned to the HashMap), or a plain array in which case the keys will be copied from each element numeric index

Get the value that is associated to a key from an existing key/value pair

get(string $key): mixed
inherited
Throws
\InvalidArgumentException

If key does not exist or is invalid

Arguments

$key

string

The key we are looking for

Response

mixed

The value that is associated to the provided key

Get the value that is located at a certain position at the ordered list of key/pair values

getAt(integer $index): mixed
inherited
Throws
\InvalidArgumentException

If index does not exist or is invalid

Arguments

$index

integer

The position we are looking for

Response

mixed

The value that is located at the specified position

Get a list with all the keys from the HashMapObject with the same order as they are stored.

getKeys(): array
inherited

Response

array

List of strings containing all the HashMapObject sorted keys.

Get a list with all the values from the HashMapObject with the same order as they are stored.

getValues(): array
inherited

Response

array

List of elements containing all the HashMapObject sorted values

Check if the provided java properties is identical to this instance Only data is compared: Any comment that is found on both provided properties will be ignored.

isEqualTo(mixed $properties,boolean $strictOrder = false): boolean

Arguments

$properties

mixed

java properties value to compare (a string or a JavaPropertiesObject instance)

$strictOrder

boolean

If set to true, both properties elements must have the same keys with the same order. Otherwise differences in key sorting will be accepted

Response

boolean

true if both java properties data is exactly the same, false if not

Tells if the given value contains valid Java Properties data information or not

isJavaProperties(mixed $value): boolean
static

Arguments

$value

mixed

A value to check (a string or a JavaPropertiesObject instance)

Response

boolean

true if the given value contains valid Java Properties data, false otherwise

Tells if the provided value matches a key that's stored inside the HashMapObject

isKey(mixed $key): boolean
inherited

Arguments

$key

mixed

A value to find on the currently stored keys.

Response

boolean

True if the provided value is a valid HashMap key, false in any other case

Get the number of key/value pairs that are currently stored on this HashMapObject instance

length(): integer
inherited

Response

integer

The number of items inside the collection

Remove and get the last element value from the HashMapObject sorted list

pop(): mixed
inherited
Throws
\UnexpectedValueException

If the HashMapObject is empty

Response

mixed

The value on the last element of the list

Delete a key/value pair from the HashMapObject, given it's key.

remove(string $key): mixed
inherited
Throws
\InvalidArgumentException

Arguments

$key

string

The key for the key/value pair we want to delete

Response

mixed

The value from the key/value pair that's been deleted.

Change the name for an existing key

rename(string $key,string $newKey): boolean
inherited
Throws
\InvalidArgumentException

Arguments

$key

string

The name we want to change

$newKey

string

The new name that will replace the previous one

Response

boolean

True if rename was successful

Reverse the order of the HashMapObject elements

reverse(): void
inherited

Define a key / value pair and add it to the collection.

set(string $key,mixed $value): mixed
inherited

If the key already exists, value will be replaced.

Throws
\InvalidArgumentException

If invalid key is provided

Arguments

$key

string

A string that labels the provided value

$value

mixed

A value to be stored with the provided key

Response

mixed

The value after being stored to the collection

Remove and get the first element value from the HashMapObject sorted list

shift(): mixed
inherited
Throws
\UnexpectedValueException

If the HashMapObject is empty

Response

mixed

The value on the first element of the list

Sort the key/value pairs inside the HashMapObject by their key values.

sortByKey(string $method = self::SORT_METHOD_STRING,string $order = self::SORT_ORDER_ASCENDING): boolean
inherited
Throws
\InvalidArgumentException

Arguments

$method

string

Defines sort mode: HashMapObject::SORT_STRING or HashMapObject::SORT_NUMERIC

$order

string

Defines the order for the sorted elements: self::SORT_ORDER_ASCENDING (default) or self::SORT_ORDER_DESCENDING

Response

boolean

True if sort was successful false on failure

Exchange the positions for two key/value pairs on the HashMapObject sorted elements list

swap(string $key1,string $key2): boolean
inherited
Throws
\InvalidArgumentException

If any of the two provided keys does not exist or is invalid

Arguments

$key1

string

The first key to exchange

$key2

string

The second key to exchange

Response

boolean

True if the two key/value pairs positions were correctly exchanged

Generate the textual representation for the java properties data stored on this object.

toString(): string

The output of this method is ready to be stored on a physical .properties file.

Response

string

A valid Java .properties string ready to be stored on a .properties file

Constants

Sort mode that compares values as strings (alphabetically)

SORT_METHOD_STRING
inherited

Sort mode that compares values as numbers (Avoid using it with non numeric values)

SORT_METHOD_NUMERIC
inherited

Defines that elements will be sorted upward

SORT_ORDER_ASCENDING
inherited

Defines that elements will be sorted downward

SORT_ORDER_DESCENDING
inherited