Package org.nuxeo.ecm.core.storage.sql
Class SimpleFragment
- java.lang.Object
-
- org.nuxeo.ecm.core.storage.sql.Fragment
-
- org.nuxeo.ecm.core.storage.sql.SimpleFragment
-
- All Implemented Interfaces:
Serializable
public final class SimpleFragment extends Fragment
A type of fragment corresponding to a single row in a table and its associated in-memory information (state, dirty fields, attached context).- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SimpleFragment.FieldComparator
Comparator ofSimpleFragment
s according to a field.-
Nested classes/interfaces inherited from class org.nuxeo.ecm.core.storage.sql.Fragment
Fragment.State
-
-
Constructor Summary
Constructors Constructor Description SimpleFragment(Row row, Fragment.State state, PersistenceContext context)
Constructs aSimpleFragment
from aRow
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Serializable
get(String key)
Gets a value by key.List<String>
getDirtyKeys()
Gets the dirty keys (keys of values changed since last clear).RowMapper.RowUpdate
getRowUpdate()
Returns the row update to do in the database to write this value.String
getString(String key)
Returns aString
value.void
put(String key, Serializable value)
Puts a value by key.protected Fragment.State
refetch()
Refetches this fragment from the database.protected Fragment.State
refetchDeleted()
Resets the data for a fragment that was invalidated by deletion.-
Methods inherited from class org.nuxeo.ecm.core.storage.sql.Fragment
accessed, clearDirty, getId, getState, markModified, setDeleted, setDetached, setId, setInvalidatedDeleted, setInvalidatedModified, setPristine, toString
-
-
-
-
Field Detail
-
UNKNOWN
public static final SimpleFragment UNKNOWN
-
-
Constructor Detail
-
SimpleFragment
public SimpleFragment(Row row, Fragment.State state, PersistenceContext context)
Constructs aSimpleFragment
from aRow
.- Parameters:
row
- the row, ornull
state
- the initial state for the fragmentcontext
- the persistence context to which the fragment is tied, ornull
-
-
Method Detail
-
refetch
protected Fragment.State refetch()
Description copied from class:Fragment
Refetches this fragment from the database. Needed when an invalidation has been received and the fragment is accessed again.- Specified by:
refetch
in classFragment
- Returns:
- the new state,
Fragment.State.PRISTINE
orFragment.State.ABSENT
-
refetchDeleted
protected Fragment.State refetchDeleted()
Description copied from class:Fragment
Resets the data for a fragment that was invalidated by deletion.- Specified by:
refetchDeleted
in classFragment
- Returns:
- the new state,
Fragment.State.PRISTINE
orFragment.State.ABSENT
-
get
public Serializable get(String key)
Gets a value by key.- Parameters:
key
- the key- Returns:
- the value
-
put
public void put(String key, Serializable value)
Puts a value by key.- Parameters:
key
- the keyvalue
- the value
-
getString
public String getString(String key)
Returns aString
value.- Parameters:
key
- the key- Returns:
- the value as a
String
- Throws:
ClassCastException
- if the value is not aString
-
getRowUpdate
public RowMapper.RowUpdate getRowUpdate()
Description copied from class:Fragment
Returns the row update to do in the database to write this value.- Specified by:
getRowUpdate
in classFragment
- Returns:
- a row update, or
null
if the value is unchanged since last clear
-
-