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>dataprivate static intPRIME
-
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 booleanequals(Object obj)<T extends OctaveObject>
Tget(Class<T> castClass, String key)OctaveObjectget(String key)Get object from struct as plain OctaveObject.Map<String,OctaveObject>getData()inthashCode()voidset(String name, OctaveObject value)OctaveStructshallowCopy()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:OctaveObjectMake a shallow copy of this object. In general when anOctaveObjectis returned from a getter, e.g. onOctaveStructorOctaveStruct, a shallow copy is returned in order to follow the way octave behaves. This method is used to make that copy.- Specified by:
shallowCopyin interfaceOctaveObject- Returns:
- a shallow copy of this
-
-