- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 11 Aug 2009 16:05:40 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/tasklisttree In directory hutz:/tmp/cvs-serv2609/src/org/w3c/unicorn/tasklisttree Added Files: Tag: dev2 TLTNode.java EnumCondType.java TLTExec.java TLTCond.java TLTIf.java Log Message: all initialization actions in Init.java + compatibility windows/linux --- NEW FILE: TLTNode.java --- package org.w3c.unicorn.tasklisttree; import java.util.ArrayList; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.unicorn.contract.Observer; /** * Class made to manage the execution of a tasklist. It can contain several * TLTExec objects and TLTIf. * * @author Barouh Jonathan & Batard Florent * */ public class TLTNode { private int NodeID; private ArrayList<TLTExec> executionList; // list of observations to // perform private ArrayList<TLTIf> ifList; // list of conditions and child nodes private static final Log logger = LogFactory .getLog("org.w3c.unicorn.tasklisttree"); public boolean bExpandingOrExpanded = false; /** * Default constructor for a node. * */ public TLTNode() { TLTNode.logger.trace("Constructor"); NodeID = 0; executionList = new ArrayList<TLTExec>(); ifList = new ArrayList<TLTIf>(); } /** * Advanced constructor for a node. * * @param level * The level of execution * @param executionList * The list of executions for the node * @param ifList * The list of tltIf for the node */ public TLTNode(int NodeID, ArrayList<TLTExec> executionList, ArrayList<TLTIf> ifList) { TLTNode.logger.trace("Constructor"); TLTNode.logger.trace("NodeID : " + NodeID); TLTNode.logger.trace("Number of executions : " + executionList.size()); TLTNode.logger.trace("Number of ifs : " + ifList.size()); this.NodeID = NodeID; this.executionList = executionList; this.ifList = ifList; } /** * * @param level * The level of execution */ public void setID(int NodeID) { TLTNode.logger.trace("setID : " + NodeID); this.NodeID = NodeID; } /** * Adds an "exec" object to the executionList * * @param exec * The "exec" to add */ public void addExec(TLTExec exec) { TLTNode.logger.trace("addExec : " + exec.getId()); if (!executionList.contains(exec)) { executionList.add(exec); } } /** * Adds an "if" object to the ifList. * * @param tltIf * The "if" to add */ public void addIf(TLTIf tltIf) { TLTNode.logger.trace("addIf : "); ifList.add(tltIf); } /** * * @return The list of executions */ public List<TLTExec> getExecutionList() { TLTNode.logger.trace("getExecutionList"); return executionList; } public List<Observer> getAllObservers() { List<Observer> res = new ArrayList<Observer>(); getAllObserversRec(res); return res; } private void getAllObserversRec(List<Observer> res) { // Add every observers directly under this TLTNode for (TLTExec exec : this.executionList) { Observer o = exec.getObserver(); if (!res.contains(o)) { res.add(o); } } // Recursively add observers in <if> elements for (TLTIf ifNode : this.ifList) { ifNode.getIfOk().getAllObserversRec(res); ifNode.getIfNotOk().getAllObserversRec(res); } } /** * * @return The list of "ifs" */ public ArrayList<TLTIf> getIfList() { TLTNode.logger.trace("getIfList"); return ifList; } /** * * @return The level of execution */ public int getID() { TLTNode.logger.trace("getLevel"); return NodeID; } @Override public String toString() { String res = new String("TLTNode level" + this.NodeID + " "); for (TLTIf conds : this.ifList) { res += conds.toString(); } for (TLTExec exec : this.executionList) { res += exec.toString(); } return res; } } --- NEW FILE: TLTExec.java --- package org.w3c.unicorn.tasklisttree; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3.unicorn.tasklist.ParamType; import org.w3c.unicorn.contract.Observer; /** * Class made to manage the XML type execType of the tasklist. Included in a * TLTNode, its value attribute corresponds to an observation which is to be * launched. * * @author Barouh Jonathan & Batard Florent * */ public class TLTExec { private String id; private String value; private String type; private ParamType param; private Observer observer; private static final Log logger = LogFactory .getLog("org.w3c.unicorn.tasklisttree"); /** * Constructor for a TLTExec. * * @param id * The id of the exec * @param value * The observer to run * @param param * The parameter of the exec */ public TLTExec(String id, Observer obs, String value, String type, ParamType param) { String toTrace = "constructor(" + id + ", "; if (type.equals("observation")) { toTrace += obs.getID() + ", "; this.observer = obs; } TLTExec.logger .trace(toTrace + type + ", " + value + ", " + param + ")"); this.id = id; this.value = value; this.type = type; this.param = param; } /** * * @param id * The id of the exec */ public void setObserver(Observer obs) { TLTExec.logger.trace("setObserver(" + obs.getID() + ")"); this.observer = obs; } /** * */ public Observer getObserver() { TLTExec.logger.trace("getObserver()"); return this.observer; } /** * * @param id * The id of the exec */ public void setId(String id) { TLTExec.logger.trace("setId(" + id + ")"); this.id = id; } /** * * @param value * The observer to run */ public void setValue(String value) { TLTExec.logger.trace("setValue(" + value + ")"); this.value = value; } /** * * @param value * The observer to run */ public void setType(String type) { TLTExec.logger.trace("setType(" + type + ")"); this.type = type; } /** * * @param param * The parameter of the exec */ public void setParam(ParamType param) { TLTExec.logger.trace("setParam(" + param + ")"); this.param = param; } /** * * @return The id of the exec */ public String getId() { TLTExec.logger.trace("getId()"); return id; } /** * * @return The observer or subtask to run */ public String getValue() { TLTExec.logger.trace("getValue()"); return value; } /** * * @return The type of execution Observer or subtask */ public String getType() { TLTExec.logger.trace("getType()"); return type; } /** * * @return The parameter of the exec */ public ParamType getParam() { TLTExec.logger.trace("getParam()"); return param; } @Override public String toString() { return "TLTExec{id: " + this.id + ", value: " + this.value + ", type: " + this.getType() + ", param: " + this.param + "}"; } } --- NEW FILE: EnumCondType.java --- package org.w3c.unicorn.tasklisttree; public enum EnumCondType { XPATH("xpath"), MIMETYPE("mimetype"); private final String sValue; private EnumCondType(final String sValue) { this.sValue = sValue; } public final String value() { return this.sValue; } } --- NEW FILE: TLTCond.java --- package org.w3c.unicorn.tasklisttree; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.unicorn.contract.Observer; /** * Class made to manage the XML type condType of the tasklist. Included in a * TLTIf, it will decide of the next node to be executed. * * @author Barouh Jonathan & Batard Florent * */ public class TLTCond { private String id; private Observer observer; private EnumCondType type; private boolean result; private String value; private static final Log logger = LogFactory .getLog("org.w3c.unicorn.tasklisttree"); /** * Advanced constructor for a TLTCond. * * @param id * @param observer * The name of the observer corresponding to the condition * @param type * The type of the condition */ public TLTCond(String id, Observer observer, EnumCondType type, String value) { TLTCond.logger.trace("constructor(" + id + ", " + observer + ", " + type.value() + ")"); this.id = id; this.observer = observer; this.type = type; } /** * Default constructor for a TLTCond. * */ public TLTCond() { TLTCond.logger.trace("constructor()"); } /** * * @param id * The id of the condition */ public void setId(String id) { TLTCond.logger.trace("setId(" + id + ")"); this.id = id; } /** * * @param observer * The observer the condition depends on */ public void setObserver(Observer observer) { TLTCond.logger.trace("setObserver(" + observer + ")"); this.observer = observer; } /** * * @param result * The result of the test */ public void setResult(boolean result) { TLTCond.logger.trace("setResult(" + result + ")"); this.result = result; } /** * * @param type * The type of the condition */ public void setType(EnumCondType type) { TLTCond.logger.trace("setType(" + type.value() + ")"); this.type = type; } /** * * @param type * The type of the condition */ public void setType(String type) { TLTCond.logger.trace("setType(" + type + ")"); for (EnumCondType val : EnumCondType.values()) { if (val.value().equals(type)) { this.type = val; } } } /** * * @param value * value of the condition */ public void setValue(String value) { TLTCond.logger.trace("setValue(" + value + ")"); this.value = value; } /** * @return The id of the condition */ public String getId() { TLTCond.logger.trace("getId()"); return id; } /** * * @return The observer the condition depends on */ public Observer getObserver() { TLTCond.logger.trace("getObserver()"); return observer; } /** * * @return The result of the test */ public boolean getResult() { TLTCond.logger.trace("getResult()"); return result; } /** * * @return The type of the condition */ public EnumCondType getType() { TLTCond.logger.trace("getType()"); return type; } /** * * @return The value of the condition */ public String getValue() { TLTCond.logger.trace("getValue()"); return value; } @Override public String toString() { if (this.observer != null) { return new String("TLTCond{id: " + this.id + ", observer: " + this.observer.getID() + ", value: " + this.value + "}"); } return new String("TLTCond{id: " + this.id + ", value: " + this.value + "}"); } } --- NEW FILE: TLTIf.java --- package org.w3c.unicorn.tasklisttree; import java.util.ArrayList; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Class made to manage the XML type : ifType in the tasklist. Included in a * TLTNode, it contains a condition and two child nodes : one if the condition * passed and the other if it failed. * * @author Barouh Jonathan & Batard Florent * */ public class TLTIf { private ArrayList<TLTCond> cond; private TLTNode ifOk; private TLTNode ifNotOk; private static final Log logger = LogFactory .getLog("org.w3c.unicorn.tasklisttree"); /** * Default constructor for a TLTIf. * */ public TLTIf() { TLTIf.logger.trace("Constructor"); this.cond = new ArrayList<TLTCond>(); this.ifOk = new TLTNode(); this.ifNotOk = new TLTNode(); } /** * Constructor for a TLTIf with only an ifOk node. * * @param id * @param cond * The condition to check * @param ifOK * The next node if the condition is ok */ public TLTIf(ArrayList<TLTCond> cond, TLTNode ifOk) { TLTIf.logger.trace("Constructor"); TLTIf.logger.trace("Cond : "); this.cond = cond; this.ifOk = ifOk; this.ifNotOk = new TLTNode(); } /** * Complete constructor for a TLTif. * * @param id * @param cond * The condition to check * @param ifOk * The next node if the condition is ok * @param ifNotOK * The next node if the condition is not ok */ public TLTIf(ArrayList<TLTCond> cond, TLTNode ifOk, TLTNode ifNotOK) { TLTIf.logger.trace("Constructor"); TLTIf.logger.trace("Cond : "); this.cond = cond; this.ifOk = ifOk; this.ifNotOk = ifNotOK; } /** * Sets the child node corresponding to the "ok" case * * @param ifOk */ public void setIfOk(TLTNode ifOk) { TLTIf.logger.trace("setIfOk"); this.ifOk = ifOk; } /** * Sets the child node corresponding to the "notOk" case * * @param ifNotOk */ public void setIfNotOk(TLTNode ifNotOk) { TLTIf.logger.trace("setIfNotOk"); this.ifNotOk = ifNotOk; } /** * Sets the condition to check. * * @param cond */ public void addCond(TLTCond cond) { TLTIf.logger.trace("addCond : " + cond.getId()); this.cond.add(cond); } /** * * @return The child node corresponding to the "ok" case */ public TLTNode getIfOk() { TLTIf.logger.trace("getIfOk"); return ifOk; } /** * * @return The child node corresponding to the "notOk" case */ public TLTNode getIfNotOk() { TLTIf.logger.trace("getIfNotOk"); return ifNotOk; } /** * * @return The condition */ public ArrayList<TLTCond> getCondArray() { TLTIf.logger.trace("getCond"); return cond; } @Override public String toString() { String res = new String("TLTIf "); for (TLTCond conds : this.cond) { res += conds.toString(); } return res; } }
Received on Tuesday, 11 August 2009 16:08:41 UTC