Package com.inductiveautomation.snap.web
Class Row
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<java.lang.String,java.lang.Object>
-
- com.inductiveautomation.snap.web.Row
-
- All Implemented Interfaces:
RMJSONArchiver.GetKeys
,RMJSONArchiver.GetValue
,RMJSONArchiver.SetValue
,java.beans.PropertyChangeListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,java.util.Map<java.lang.String,java.lang.Object>
- Direct Known Subclasses:
SnapRow
public class Row extends java.util.HashMap<java.lang.String,java.lang.Object> implements java.beans.PropertyChangeListener, RMJSONArchiver.GetKeys, RMJSONArchiver.GetValue, RMJSONArchiver.SetValue
Represents a data bearing object from a WebSite.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Row()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Property aProperty, Row aRow, int anIndex)
Adds an object to a list at given index.void
add(java.lang.String aKey, Row aRow, int anIndex)
Adds an object to a list at given index.void
addPropertyChangeListener(java.beans.PropertyChangeListener aListener)
Add a property change listener.protected Row
createOriginal()
Returns the row this row was loaded from or the original state of this row.void
delete()
Deletes this row.boolean
equals(java.lang.Object anObj)
Override to just check identity, since rows are unique.protected void
firePropertyChange(java.lang.String aPropName, java.lang.Object anOldVal, java.lang.Object aNewVal, int anIndex)
Fires a property change.java.lang.Object
get(Property aProperty)
Returns the current row value for key.java.lang.Object
get(java.lang.Object aKey)
Returns the current row value for key.java.lang.Object
get(java.lang.String aKey)
Returns the current row value for key.Entity
getEntity()
Returns the entity that describes the data in this row.boolean
getExists()
Returns whether file exists in data source (has been saved and, if so, not deleted).java.util.List<java.lang.String>
getJSONKeys()
RMJSONArchiver method to return keys in property order and, potentially, NewValues key.java.lang.Object
getJSONValue(java.lang.String aKey)
RMJSONArchiver method to get archiver values via getValue() and handle NewValues.long
getModifiedTime()
Returns the file modification time.Row
getOriginal()
Returns the original state of this row (or null if row not modified).java.lang.Object
getPrimaryValue()
Returns the primary property.Property
getProperty(java.lang.String aName)
Returns the named property.protected java.lang.Object
getRaw(Property aProperty)
Returns the current value or RowLink for a key.WebSite
getSite()
Returns the WebSite that created this row.Row[]
getUnresolvedRelationRows()
Returns an array of relation rows for this row that don't have a primary key value.java.lang.Object
getValue(Property aProperty)
Returns the current row value for key.java.lang.Object
getValue(java.lang.String aKey)
Returns the current row value for key.void
initValues(java.util.Map aMap)
Initialize row values from map (or Entity default values).boolean
isModified()
Returns whether this row's row object has been changed.void
propertyChange(java.beans.PropertyChangeEvent anEvent)
PropertyChangeListener method to propagate changes from row object to row.java.lang.Object
put(Property aProperty, java.lang.Object anObj)
Override put to do conversion.java.lang.Object
put(java.lang.String aKey, java.lang.Object aValue)
Put value by string.Row
remove(Property aProperty, int anIndex)
Removes an object from list at given index.Row
remove(java.lang.String aKey, int anIndex)
Removes an object from a list at given index.void
removePropertyChangeListener(java.beans.PropertyChangeListener aListener)
Remove a property change listener.void
save()
Saves this row.void
setEntity(Entity anEntity)
Sets the entity that describes the data in this row.protected void
setExists(boolean aFlag)
Sets whether file exists in data source (has been saved and, if so, not deleted).void
setJSONValue(java.lang.String aKey, java.lang.Object aValue)
RMJSONArchiver method to put archiver values and handle NewValues.protected void
setModified(boolean aValue)
Sets whether this row's row object has been changed.void
setModifiedTime(long aTime)
Sets the file modification time.protected void
setSite(WebSite aSite)
Sets the WebSite that created this row.java.lang.String
toString()
Standard toString implementation.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Method Detail
-
getSite
public WebSite getSite()
Returns the WebSite that created this row.
-
setSite
protected void setSite(WebSite aSite)
Sets the WebSite that created this row.
-
getEntity
public Entity getEntity()
Returns the entity that describes the data in this row.
-
setEntity
public void setEntity(Entity anEntity)
Sets the entity that describes the data in this row.
-
getProperty
public Property getProperty(java.lang.String aName)
Returns the named property.
-
getPrimaryValue
public java.lang.Object getPrimaryValue()
Returns the primary property.
-
initValues
public void initValues(java.util.Map aMap)
Initialize row values from map (or Entity default values).
-
get
@Nullable public java.lang.Object get(java.lang.Object aKey)
Returns the current row value for key. If key is a relation, return value as an Row or List.
- Specified by:
get
in interfacejava.util.Map<java.lang.String,java.lang.Object>
- Overrides:
get
in classjava.util.HashMap<java.lang.String,java.lang.Object>
-
get
@Nullable public java.lang.Object get(java.lang.String aKey)
Returns the current row value for key. If key is a relation, return value as a Row or List.
-
get
@Nullable public java.lang.Object get(Property aProperty)
Returns the current row value for key. If key is a relation, return value as a Row or List.
-
getValue
public java.lang.Object getValue(java.lang.String aKey)
Returns the current row value for key.
-
getValue
public java.lang.Object getValue(Property aProperty)
Returns the current row value for key.
-
getRaw
protected java.lang.Object getRaw(Property aProperty)
Returns the current value or RowLink for a key.
-
put
public java.lang.Object put(java.lang.String aKey, java.lang.Object aValue)
Put value by string.- Specified by:
put
in interfacejava.util.Map<java.lang.String,java.lang.Object>
- Overrides:
put
in classjava.util.HashMap<java.lang.String,java.lang.Object>
-
put
public java.lang.Object put(Property aProperty, java.lang.Object anObj)
Override put to do conversion.
-
getOriginal
public Row getOriginal()
Returns the original state of this row (or null if row not modified).
-
createOriginal
protected Row createOriginal()
Returns the row this row was loaded from or the original state of this row.
-
getUnresolvedRelationRows
public Row[] getUnresolvedRelationRows()
Returns an array of relation rows for this row that don't have a primary key value.
-
add
public void add(java.lang.String aKey, Row aRow, int anIndex)
Adds an object to a list at given index.
-
add
public void add(Property aProperty, Row aRow, int anIndex)
Adds an object to a list at given index.
-
remove
public Row remove(java.lang.String aKey, int anIndex)
Removes an object from a list at given index.
-
remove
@Nullable public Row remove(Property aProperty, int anIndex)
Removes an object from list at given index.
-
getExists
public boolean getExists()
Returns whether file exists in data source (has been saved and, if so, not deleted).
-
setExists
protected void setExists(boolean aFlag)
Sets whether file exists in data source (has been saved and, if so, not deleted).
-
getModifiedTime
public long getModifiedTime()
Returns the file modification time.
-
setModifiedTime
public void setModifiedTime(long aTime)
Sets the file modification time.
-
isModified
public boolean isModified()
Returns whether this row's row object has been changed.
-
setModified
protected void setModified(boolean aValue)
Sets whether this row's row object has been changed.
-
save
public void save()
Saves this row.
-
delete
public void delete()
Deletes this row.
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent anEvent)
PropertyChangeListener method to propagate changes from row object to row.- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener aListener)
Add a property change listener.
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener aListener)
Remove a property change listener.
-
firePropertyChange
protected void firePropertyChange(java.lang.String aPropName, java.lang.Object anOldVal, java.lang.Object aNewVal, int anIndex)
Fires a property change.
-
getJSONKeys
public java.util.List<java.lang.String> getJSONKeys()
RMJSONArchiver method to return keys in property order and, potentially, NewValues key.- Specified by:
getJSONKeys
in interfaceRMJSONArchiver.GetKeys
-
getJSONValue
public java.lang.Object getJSONValue(java.lang.String aKey)
RMJSONArchiver method to get archiver values via getValue() and handle NewValues.- Specified by:
getJSONValue
in interfaceRMJSONArchiver.GetValue
-
setJSONValue
public void setJSONValue(java.lang.String aKey, java.lang.Object aValue)
RMJSONArchiver method to put archiver values and handle NewValues.- Specified by:
setJSONValue
in interfaceRMJSONArchiver.SetValue
-
equals
public boolean equals(java.lang.Object anObj)
Override to just check identity, since rows are unique.- Specified by:
equals
in interfacejava.util.Map<java.lang.String,java.lang.Object>
- Overrides:
equals
in classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
toString
public java.lang.String toString()
Standard toString implementation.- Overrides:
toString
in classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
-