java.lang.Cloneable
, RandomAccess
AllDirectionsMemoryContainer
, RandomizableMemoryContainer
, WekaTransferableMemoryContainer
public class MemoryContainer extends java.lang.Object implements RandomAccess, java.lang.Cloneable
Here is proper sequence of using memory container. First attributes have to be assigned and they cannot be replaced in the future. But they can be modified. Once you set attributes, add examples. Remember that fields in each example must be of identical type as it is in attributes. Notice that examples are duplicated, to prevent from inserting one example into many rows. It is a possibility of making default examples with fields' values taken from pattern stored in attributes.
In memory container you have random access to the data, but
you can use MemoryInput
or MemoryOutput
to manage
it as serial stream.
Constructor | Description |
---|---|
MemoryContainer() |
Prepares empty container.
|
Modifier and Type | Method | Description |
---|---|---|
Example |
addExample() |
Adds new row to decision table with default fields' values
taken from attributes' initial values.
|
Example |
addExample(Example example) |
Makes new row at the end of the table and fills its fields by taking
values from given example.
|
void |
clear() |
Removes all examples
|
java.lang.Object |
clone() |
Clones this memory container
|
void |
deleteExample(int index) |
Removes one row of decision table at specified position.
|
int |
getAttrCount() |
Gives number of attributes.
|
Attribute |
getAttribute(int index) |
Gives direct access to specified attribute.
|
Attribute[] |
getAttributes() |
Gives an access to attributes.
|
Example |
getExample(int index) |
Gives reference directly to example at specified index.
|
FileInfo |
getFileInfo() |
Gives direct access to information connected with the table.
|
java.lang.String |
getId() |
Gets id of this container.
|
MemoryContainerDescription |
getMemoryContainerDescription() |
Gets description of this container.
|
Example |
insertExample(int index) |
Adds new row to decision table with default fields' values.
|
Example |
insertExample(int index,
Example example) |
Inserts new row to decision table with fields taken from given example.
|
void |
setAttributes(Attribute[] attributes) |
Sets the first row of the table - attributes.
|
void |
setExample(int index,
Example example) |
Sets new example instead of one at given position.
|
void |
setFileInfo(FileInfo info) |
Sets the file info referenced to this table.
|
void |
setId(java.lang.String id) |
Sets id of this container
|
void |
setMemoryContainerDescription(MemoryContainerDescription memoryContainerDescription) |
Sets description of this container.
|
int |
size() |
Reads size of the table.
|
public MemoryContainer()
public Example addExample()
InvalidOperationException
- when attribute row is still emptypublic Example insertExample(int index)
index
- position to insertjava.lang.IndexOutOfBoundsException
- if given index is wrongInvalidOperationException
- when attribute table is emptypublic Example addExample(Example example) throws ContainerFailureException
example
- reference to fields values (they are going to be copied)ContainerFailureException
- when example doesn't match the attributesInvalidOperationException
- if attributes haven't been setpublic Example insertExample(int index, Example example) throws ContainerFailureException
insertExample
in interface RandomAccess
index
- position to insertexample
- reference to example (copy is going to be made)ContainerFailureException
- when example doesn't match the attributesjava.lang.IndexOutOfBoundsException
- if index is wrongInvalidOperationException
- if attributes haven't been setpublic void deleteExample(int index)
deleteExample
in interface RandomAccess
index
- index of the example to deletejava.lang.IndexOutOfBoundsException
- when index is wrongInvalidOperationException
- if attributes haven't been setpublic void setExample(int index, Example example) throws ContainerFailureException
setExample
in interface RandomAccess
index
- position in the tableexample
- reference to example to take fields' values fromjava.lang.IndexOutOfBoundsException
- when index is wrongInvalidOperationException
- if attributes haven't been setContainerFailureException
- when example doesn't match the attributespublic Example getExample(int index)
getExample
in interface RandomAccess
index
- index of the example to getjava.lang.IndexOutOfBoundsException
- when index is out of the tablepublic int size()
size
in interface RandomAccess
public void setAttributes(Attribute[] attributes) throws ContainerFailureException
attributes
- table with attributesContainerFailureException
- when given table is emptyInvalidOperationException
- when attributes have been already setjava.lang.NullPointerException
- if table or its field is nullpublic Attribute[] getAttributes()
InvalidOperationException
- if attributes haven't been setpublic Attribute getAttribute(int index)
index
- position of attributejava.lang.ArrayIndexOutOfBoundsException
- if index is out of rangeInvalidOperationException
- when attributes haven't been setpublic int getAttrCount()
InvalidOperationException
- when attributes haven't been setpublic void setFileInfo(FileInfo info)
info
- set of informationpublic FileInfo getFileInfo()
public java.lang.Object clone()
clone
in class java.lang.Object
public void clear()
public MemoryContainerDescription getMemoryContainerDescription()
public void setMemoryContainerDescription(MemoryContainerDescription memoryContainerDescription)
memoryContainerDescription
- new description of this containerpublic java.lang.String getId()
public void setId(java.lang.String id)
id
- new id of this container