Ir a la consola

MutableData

public class MutableData extends Object

Instances of this class encapsulate the data and priority at a location. It is used in transactions, and it is intended to be inspected and then updated to the desired data at that location.

Note that changes made to a child MutableData instance will be visible to the parent and vice versa.

Public Method Summary

MutableData
child(String path)
Used to obtain a MutableData instance that encapsulates the data and priority at the given relative path.
boolean
Iterable<MutableData>
getChildren()
Used to iterate over the immediate children at this location
for (MutableData child : parent.getChildren()) {
    ...
long
String
getKey()
Object
getPriority()
Gets the current priority at this location.
<T> T
getValue(GenericTypeIndicator<T> t)
Due to the way that Java implements generics, it takes an extra step to get back a properly-typed Collection.
Object
getValue()
getValue() returns the data contained in this instance as native types.
<T> T
getValue(Class<T> valueType)
This method is used to marshall the data contained in this instance into a class of your choosing.
boolean
boolean
void
setPriority(Object priority)
Sets the priority at this location
void
setValue(Object value)
Set the data at this location to the given value.
String

Inherited Method Summary

Public Methods

public MutableData child (String path)

Used to obtain a MutableData instance that encapsulates the data and priority at the given relative path.

Parameters
path A relative path
Returns
  • An instance encapsulating the data and priority at the given path

public boolean equals (Object o)

public Iterable<MutableData> getChildren ()

Used to iterate over the immediate children at this location
for (MutableData child : parent.getChildren()) {
    ...
}

Returns
  • The immediate children at this location

public long getChildrenCount ()

Returns
  • The number of immediate children at this location

public String getKey ()

Returns
  • The key name of this location, or null if it is the top-most location

public Object getPriority ()

Gets the current priority at this location. The possible return types are:

  • Double
  • String
Note that null is allowed
Returns
  • The priority at this location as a native type or null if no priority was set

public T getValue (GenericTypeIndicator<T> t)

Due to the way that Java implements generics, it takes an extra step to get back a properly-typed Collection. So, in the case where you want a List of Message instances, you will need to do something like the following:


     GenericTypeIndicator<List<Message>> t =
         new GenericTypeIndicator<List<Message>>() {};
     List<Message> messages = mutableData.getValue(t);
 
It is important to use a subclass of GenericTypeIndicator. See GenericTypeIndicator for more details
Parameters
t A subclass of GenericTypeIndicator indicating the type of generic collection to be returned.
Returns
  • A properly typed collection, populated with the data from this instance, or null if there is no data at this location.

public Object getValue ()

getValue() returns the data contained in this instance as native types. The possible types returned are:

  • Boolean
  • String
  • Long
  • Double