This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
magik-demo:developer:class:core:atom [2013/07/18 13:43] alex [parseAtoms] |
magik-demo:developer:class:core:atom [2017/07/06 15:24] (current) |
||
---|---|---|---|
Line 5: | Line 5: | ||
Class for the definition an Atom. Atom managing all the functions for atoms.\\ | Class for the definition an Atom. Atom managing all the functions for atoms.\\ | ||
+ | |||
+ | {{ :magik-demo:developer:schema2.png?nolink&600 |}} | ||
+ | |||
===== Class Attributes ===== | ===== Class Attributes ===== | ||
Line 14: | Line 17: | ||
</code> | </code> | ||
- | ===== Class Constructor ===== | + | ===== Class Constructors ===== |
==== Atom ==== | ==== Atom ==== | ||
Line 153: | Line 156: | ||
==== parseAtoms ==== | ==== parseAtoms ==== | ||
<code java> | <code java> | ||
- | public java.util.ArrayList<Atom> parseAtoms (java.util.ArrayList<java.lang.String> arrAtomStr) | + | public static java.util.ArrayList<Atom> parseAtoms (java.util.ArrayList<java.lang.String> arrAtomStr) |
throws ContextException | throws ContextException | ||
</code> | </code> | ||
- | Create a list of Atom from a list of string definition of atoms | + | Create a list of Atom from a list of string definition of atoms (defined has: ''relation:attr1,attr2'') |
**Parameters:** | **Parameters:** | ||
Line 168: | Line 171: | ||
---- | ---- | ||
- | ==== isVariable ==== | + | |
+ | ==== parseAtoms ==== | ||
<code java> | <code java> | ||
- | public static boolean isVariable () | + | public static java.util.ArrayList<Atom> parseAtoms (java.lang.String Atoms) |
+ | throws ContextException | ||
</code> | </code> | ||
- | Check if the term is a variable.\\ | ||
+ | Parses the string contains list of atoms separated by comma (e.g.: ''classes(Level,Code,'humanities'), pupil(Name,Level,Code)'') and create the respective Atom class | ||
+ | |||
+ | **Parameters:** | ||
+ | * Atoms - list of string definition of atoms | ||
**Returns:** | **Returns:** | ||
- | * //true//, if the term is a variable, //false// otherwise | + | * list of Atom |
+ | **Throws:** | ||
+ | * ContextException | ||
---- | ---- | ||
- | ==== isConstant ==== | + | ==== getArity ==== |
<code java> | <code java> | ||
- | public static boolean isConstant () | + | public int getArity () |
</code> | </code> | ||
- | Check if the term is a constant.\\ | + | |
+ | Calculate the arity of the atom | ||
**Returns:** | **Returns:** | ||
- | * //true//, if the term is a constant, //false// otherwise | + | * arity of the atom |
---- | ---- | ||
+ | |||
+ | ==== getConstants ==== | ||
+ | <code java> | ||
+ | public java.util.ArrayList<Term> getConstants() | ||
+ | </code> | ||
+ | |||
+ | Gives all constants that occur in the atom | ||
+ | |||
+ | **Returns:** | ||
+ | * list of the constants | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== getVariables ==== | ||
+ | <code java> | ||
+ | public java.util.ArrayList<Term> getVariables() | ||
+ | </code> | ||
+ | |||
+ | Gives all variables that occur in the atom | ||
+ | |||
+ | **Returns:** | ||
+ | * list of the variables | ||
+ | |||
+ | |||
+ | ---- | ||
+ | ==== isContainingTerm ==== | ||
+ | <code java> | ||
+ | public static boolean isContainingTerm (Term term) | ||
+ | </code> | ||
+ | Check if the Atom contains a term. | ||
+ | |||
+ | **Parameters:** | ||
+ | * term - term that we want to find | ||
+ | **Returns:** | ||
+ | * //true//, if the atom contains the term , //false// otherwise | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== replaceTerm ==== | ||
+ | <code java> | ||
+ | public void replaceTerm(java.lang.String oldTerm, | ||
+ | java.lang.String newTerm) | ||
+ | </code> | ||
+ | Replace term with a new string (if old string is found in the atom). | ||
+ | |||
+ | **Parameters:** | ||
+ | * oldTerm - the term that is candidated to be replace | ||
+ | * newTerm - the new term | ||
+ | |||
+ | |||
+ | ---- | ||
+ | ==== clone ==== | ||
+ | <code java> | ||
+ | @Override | ||
+ | public Object clone () | ||
+ | </code> | ||
+ | |||
+ | **Returns:** | ||
+ | * cloned object (Atom type) | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== equals ==== | ||
+ | <code java> | ||
+ | @Override | ||
+ | public boolean equals (Object o) | ||
+ | </code> | ||
+ | |||
+ | Implementation for checking the equality for Atom | ||
+ | |||
+ | **Returns:** | ||
+ | * //true// if equal, //false// otherwise | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== toString ==== | ||
+ | <code java> | ||
+ | @Override | ||
+ | public String toString () | ||
+ | </code> | ||
+ | |||
+ | Implementation for converting in String format Atom. | ||
+ | |||
+ | **Returns:** | ||
+ | * String version of the atom | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== getters and setters methods ==== | ||
+ | <code java> | ||
+ | public long getAtomId() | ||
+ | public void setAtomId(long atomId) | ||
+ | |||
+ | public java.lang.String getAtomName() | ||
+ | public void setAtomName(java.lang.StringString atomName) | ||
+ | |||
+ | public java.util.StringArrayList<Term> getTerms() | ||
+ | public void setTerms(java.util.ArrayList<Term> terms) | ||
+ | |||
+ | </code> | ||
+ | |||
+ | [[magik-demo:developer:class:core:atom|Back to Top]] | [[magik-demo:start|Back to Home Page]] |