Package eu.simuline.octave.type
Class OctaveStruct
- java.lang.Object
-
- eu.simuline.octave.type.OctaveStruct
-
- All Implemented Interfaces:
OctaveObject
public final class OctaveStruct extends Object implements OctaveObject
1x1 struct. JavaOctave does not support the multidimensional structs that octave has.
-
-
Field Summary
Fields Modifier and Type Field Description private Map<String,OctaveObject>
data
private static int
PRIME
-
Constructor Summary
Constructors Constructor Description OctaveStruct()
Create empty struct.OctaveStruct(Map<String,OctaveObject> data)
Create struct from data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
<T extends OctaveObject>
Tget(Class<T> castClass, String key)
OctaveObject
get(String key)
Get object from struct as plain OctaveObject.Map<String,OctaveObject>
getData()
int
hashCode()
void
set(String name, OctaveObject value)
OctaveStruct
shallowCopy()
Make a shallow copy of this object.
-
-
-
Field Detail
-
PRIME
private static final int PRIME
- See Also:
- Constant Field Values
-
data
private final Map<String,OctaveObject> data
-
-
Constructor Detail
-
OctaveStruct
public OctaveStruct()
Create empty struct.
-
OctaveStruct
public OctaveStruct(Map<String,OctaveObject> data)
Create struct from data.- Parameters:
data
- this data will be referenced, not copied
-
-
Method Detail
-
set
public void set(String name, OctaveObject value)
- Parameters:
name
-value
-
-
get
public OctaveObject get(String key)
Get object from struct as plain OctaveObject. If you want to cast the object to a special type useget(Class, String)
.- Parameters:
key
-- Returns:
- shallow copy of value for this key, or null if key isn't there.
-
get
public <T extends OctaveObject> T get(Class<T> castClass, String key)
- Type Parameters:
T
-- Parameters:
castClass
- Class to cast tokey
-- Returns:
- shallow copy of value for this key, or null if key isn't there.
- Throws:
OctaveClassCastException
- if the object can not be cast to a castClass
-
getData
public Map<String,OctaveObject> getData()
- Returns:
- reference to internal map
-
shallowCopy
public OctaveStruct shallowCopy()
Description copied from interface:OctaveObject
Make a shallow copy of this object. In general when anOctaveObject
is returned from a getter, e.g. onOctaveStruct
orOctaveStruct
, a shallow copy is returned in order to follow the way octave behaves. This method is used to make that copy.- Specified by:
shallowCopy
in interfaceOctaveObject
- Returns:
- a shallow copy of this
-
-