package org.javarosa.core.model.instance;

import org.javarosa.core.model.condition.EvaluationContext;
import org.javarosa.core.model.data.IAnswerData;
import org.javarosa.core.model.instance.utils.ITreeVisitor;
import org.javarosa.xpath.expr.XPathExpression;

import java.util.Vector;

public interface AbstractTreeElement<T extends AbstractTreeElement> {

    public abstract boolean isLeaf();

    public abstract boolean isChildable();

    public abstract String getInstanceName();

    /**
     * Get a child element with the given name and occurence position (multiplicity)
     *
     * @param name         the name of the child element to select
     * @param multiplicity is the n-th occurence of an element with a given name
     */
    public abstract T getChild(String name, int multiplicity);

    /**
     * Get all the child nodes of this element, with specific name
     */
    public abstract Vector<T> getChildrenWithName(String name);

    public abstract boolean hasChildren();

    public abstract int getNumChildren();

    public abstract T getChildAt(int i);

    public abstract boolean isRepeatable();

    public abstract boolean isAttribute();

    public abstract int getChildMultiplicity(String name);

    /**
     * Visitor pattern acceptance method.
     *
     * @param visitor The visitor traveling this tree
     */
    public abstract void accept(ITreeVisitor visitor);

    /**
     * Returns the number of attributes of this element.
     */
    public abstract int getAttributeCount();

    /**
     * get namespace of attribute at 'index' in the vector
     */
    public abstract String getAttributeNamespace(int index);

    /**
     * get name of attribute at 'index' in the vector
     */
    public abstract String getAttributeName(int index);

    /**
     * get value of attribute at 'index' in the vector
     */
    public abstract String getAttributeValue(int index);

    /**
     * Retrieves the TreeElement representing the attribute at
     * the provided namespace and name, or null if none exists.
     *
     * If 'null' is provided for the namespace, it will match the first
     * attribute with the matching name.
     */
    public abstract T getAttribute(String namespace, String name);

    /**
     * get value of attribute with namespace:name' in the vector
     */
    public abstract String getAttributeValue(String namespace, String name);

    //return the tree reference that corresponds to this tree element
    public abstract TreeReference getRef();

    public abstract int getDepth();

    public abstract String getName();

    public abstract int getMult();

    //Support?
    public abstract AbstractTreeElement getParent();

    public abstract IAnswerData getValue();

    public abstract int getDataType();

    public abstract void clearCaches();

    public abstract boolean isRelevant();

    public abstract String getNamespace();

    /**
     * TODO: Worst method name ever. Don't use this unless you know what's up.
     *
     * @param predicates  possibly list of predicates to be evaluated. predicates will be removed from list if they are
     *                    able to be evaluated
     */
    public abstract Vector<TreeReference> tryBatchChildFetch(String name, int mult, Vector<XPathExpression> predicates, EvaluationContext evalContext);
}

@@ -355,32 +355,16 @@
  %7B%0A%0A    
-public abstract 
 boolean 
@@ -378,32 +378,16 @@
 );%0A%0A    
-public abstract 
 boolean 
@@ -406,32 +406,16 @@
 );%0A%0A    
-public abstract 
 String g
@@ -693,32 +693,16 @@
  */%0A    
-public abstract 
 T getChi
@@ -824,32 +824,16 @@
  */%0A    
-public abstract 
 Vector%3CT
@@ -873,32 +873,16 @@
 );%0A%0A    
-public abstract 
 boolean 
@@ -901,32 +901,16 @@
 );%0A%0A    
-public abstract 
 int getN
@@ -928,32 +928,16 @@
 );%0A%0A    
-public abstract 
 T getChi
@@ -954,32 +954,16 @@
 );%0A%0A    
-public abstract 
 boolean 
@@ -983,32 +983,16 @@
 );%0A%0A    
-public abstract 
 boolean 
@@ -1011,32 +1011,16 @@
 );%0A%0A    
-public abstract 
 int getC
@@ -1174,32 +1174,16 @@
  */%0A    
-public abstract 
 void acc
@@ -1287,32 +1287,16 @@
  */%0A    
-public abstract 
 int getA
@@ -1392,32 +1392,16 @@
  */%0A    
-public abstract 
 String g
@@ -1508,32 +1508,16 @@
  */%0A    
-public abstract 
 String g
@@ -1620,32 +1620,16 @@
  */%0A    
-public abstract 
 String g
@@ -1925,32 +1925,16 @@
  */%0A    
-public abstract 
 T getAtt
@@ -2058,32 +2058,16 @@
  */%0A    
-public abstract 
 String g
@@ -2190,32 +2190,16 @@
 ent%0A    
-public abstract 
 TreeRefe
@@ -2219,32 +2219,16 @@
 );%0A%0A    
-public abstract 
 int getD
@@ -2240,32 +2240,16 @@
 );%0A%0A    
-public abstract 
 String g
@@ -2263,32 +2263,16 @@
 );%0A%0A    
-public abstract 
 int getM
@@ -2298,32 +2298,16 @@
 rt?%0A    
-public abstract 
 Abstract
@@ -2336,32 +2336,16 @@
 );%0A%0A    
-public abstract 
 IAnswerD
@@ -2365,32 +2365,16 @@
 );%0A%0A    
-public abstract 
 int getD
@@ -2389,32 +2389,16 @@
 );%0A%0A    
-public abstract 
 void cle
@@ -2414,32 +2414,16 @@
 );%0A%0A    
-public abstract 
 boolean 
@@ -2441,32 +2441,16 @@
 );%0A%0A    
-public abstract 
 String g
@@ -2742,24 +2742,8 @@
     
-public abstract 
 Vect

Remove unneeded 'public abstract' from interface