org.qedeq.kernel.se.base.list
Interface Element

All Known Subinterfaces:
Atom, ElementList
All Known Implementing Classes:
DefaultAtom, DefaultElementList

public interface Element

An element is either a list or an atom. Each list has an operator and contains elements which are also elements. A list has a size and their elements can be accessed by their position. An atom carries textual data, has no operator and no size in the previous sense.

Author:
Michael Meyling

Method Summary
 Element copy()
          Returns an identical object.
 boolean equals(java.lang.Object object)
          Is this object equal to the given one?
 Atom getAtom()
          Return this element as an Atom.
 ElementList getList()
          Return this element as an ElementList.
 int hashCode()
          Calculates the hash code.
 boolean isAtom()
          Is this an atom?
 boolean isList()
          Is this an ElementList?
 Element replace(Element search, Element replacement)
          Creates and returns a copy of this object, but replaces anything that equals(java.lang.Object) argument with a copy() of replacement.
 java.lang.String toString()
          Get show this in String form.
 

Method Detail

isAtom

boolean isAtom()
Is this an atom?

Returns:
true if this is an instance of Atom.

getAtom

Atom getAtom()
Return this element as an Atom.

Returns:
This is an instance of Atom.
Throws:
java.lang.ClassCastException - This is no instance of Atom.

isList

boolean isList()
Is this an ElementList?

Returns:
true if this is an instance of ElementList.

getList

ElementList getList()
Return this element as an ElementList.

Returns:
This as an instance of ElementList.
Throws:
java.lang.ClassCastException - This is no instance of ElementList.

equals

boolean equals(java.lang.Object object)
Is this object equal to the given one?

Overrides:
equals in class java.lang.Object
Parameters:
object - to compare with
Returns:
Is object equal to this one?

hashCode

int hashCode()
Calculates the hash code.

Overrides:
hashCode in class java.lang.Object
Returns:
Hash code of this object

copy

Element copy()
Returns an identical object. This is a deep copy so later changes of the original element (or its sub parts) are not reflected in the copy.

Returns:
Copy of this object.

replace

Element replace(Element search,
                Element replacement)
Creates and returns a copy of this object, but replaces anything that equals(java.lang.Object) argument with a copy() of replacement.

Parameters:
search - Check for occurrence of this.
replacement - Replace with this.
Returns:
Copy with replacements.

toString

java.lang.String toString()
Get show this in String form.

Overrides:
toString in class java.lang.Object
Returns:
Readable list.


Copyright © 2014. All Rights Reserved.