|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.intermine.pathquery.PathQuery
public class PathQuery
Class to represent a path-based query.
| Field Summary | |
|---|---|
protected static java.util.regex.Pattern |
SPACE_SPLITTER
A Pattern that finds spaces in a String. |
static int |
USERPROFILE_VERSION
Version number for the userprofile and PathQuery XML format. |
| Constructor Summary | |
|---|---|
PathQuery(Model model)
Constructor. |
|
PathQuery(PathQuery o)
Constructor. |
|
| Method Summary | |
|---|---|
java.lang.String |
addConstraint(PathConstraint constraint)
Adds a PathConstraint to this query. |
void |
addConstraint(PathConstraint constraint,
java.lang.String code)
Adds a PathConstraints to this query, associated with a given constraint code. |
void |
addConstraints(java.util.Collection<PathConstraint> constraints)
Adds a collection of constraints to this query. |
void |
addConstraints(PathConstraint... constraints)
Adds a group of constraints to this query. |
void |
addOrderBy(OrderElement orderElement)
Adds an element to the order by list of this query. |
void |
addOrderBy(java.lang.String orderPath,
OrderDirection direction)
Adds an element to the order by list of this query. |
void |
addOrderBys(java.util.Collection<OrderElement> orderElements)
Adds a group of elements to the order by list of this query. |
void |
addOrderBys(OrderElement... orderElements)
Adds a group of elements to the order by list of this query. |
void |
addOrderBySpaceSeparated(java.lang.String orderString)
Adds a group of elements to the order by list, given a space-separated list. |
void |
addView(java.lang.String viewPath)
Add a single element to the view list. |
void |
addViews(java.util.Collection<java.lang.String> viewPaths)
Adds a group of elements to the view list. |
void |
addViews(java.lang.String... viewPaths)
Adds a group of elements to the view list. |
void |
addViewSpaceSeparated(java.lang.String viewPaths)
Adds a group of elements to the view list, given a space-separated list. |
static void |
checkPathFormat(java.lang.String path)
Verifies the format of a path for a query. |
void |
clearConstraints()
Clears the entire set of constraints from this query, and resets the constraint logic. |
void |
clearDescriptions()
Removes all path descriptions from this query. |
void |
clearOrderBy()
Clears the entire order by list. |
void |
clearOuterJoinStatus()
Clears all outer join status data from this query. |
void |
clearView()
Clears the entire view list. |
PathQuery |
clone()
Returns a deep copy of this object. |
java.util.List<java.lang.String> |
fixUpForJoinStyle()
Fixes up the order by list and the constraint logic, given the arrangement of outer joins in the query. |
java.util.Set<java.lang.String> |
getBagNames()
Returns all bag names used in constraints on this query. |
java.util.Set<java.lang.String> |
getCandidateLoops(java.lang.String stringPath)
Returns the set of paths that could feasibly be loop constrained onto the given path, given the current outer join situation. |
java.util.Set<java.lang.String> |
getConstraintCodes()
Return the constraint codes used in the query, some constraint types (subclasses) don't get assigned a code, these are not included. |
PathConstraint |
getConstraintForCode(java.lang.String code)
Returns the PathConstraint associated with a given code. |
java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
getConstraintGroups()
Returns the outer join constraint codes groups map for this query, if the query verifies correctly. |
java.lang.String |
getConstraintLogic()
Returns the current constraint logic. |
LogicExpression |
getConstraintLogicForGroup(java.lang.String group)
Returns the constraint logic for the given outer join group, if the query verifies correctly. |
java.util.Map<PathConstraint,java.lang.String> |
getConstraints()
Returns a Map of all the constraints in this query, from PathConstraint to the constraint code used in the constraint logic. |
java.util.List<PathConstraint> |
getConstraintsForPath(java.lang.String path)
Returns a list of PathConstraints applied to a given path or an empty list. |
java.lang.String |
getDescription()
Gets the description for this PathQuery. |
java.lang.String |
getDescription(java.lang.String path)
Returns the description for a given path, or null if no description is registered. |
java.util.Map<java.lang.String,java.lang.String> |
getDescriptions()
Returns an unmodifiable Map which is a copy of the current set of path descriptions of this query at the time of execution of this method. |
java.util.Set<java.lang.String> |
getExistingLoops()
Returns the set of loop constraint descriptive strings, for the purpose of checking for uniqueness. |
java.lang.String |
getGeneratedPathDescription(java.lang.String path)
Returns the path description for the given path. |
java.util.List<java.lang.String> |
getGroupedConstraintLogic()
Returns a List of logic Strings according to the different outer join sections of the query. |
Model |
getModel()
Returns the Model object stored in this object. |
java.util.List<OrderElement> |
getOrderBy()
Returns the current order by list. |
java.lang.String |
getOuterJoinGroup(java.lang.String stringPath)
Returns the outer join group that the given path is in. |
java.util.Map<java.lang.String,java.lang.String> |
getOuterJoinGroups()
Returns the outer join groups map for this query, if the query verifies correctly. |
java.util.Map<java.lang.String,OuterJoinStatus> |
getOuterJoinStatus()
Returns an unmodifiable Map which is a copy of the current outer join status of this query at the time of execution of this method. |
OuterJoinStatus |
getOuterJoinStatus(java.lang.String path)
Returns the outer join status of the last part of a given path in this query. |
java.util.Map<java.lang.String,java.lang.Boolean> |
getOuterMap()
Returns a Map from path to TRUE for all paths that are outer joined. |
PathQuery |
getQueryToExecute()
Get the PathQuery that should be executed. |
java.lang.String |
getRootClass()
Returns the root path for this query, if the query verifies correctly. |
java.util.Map<java.lang.String,java.lang.String> |
getSubclasses()
Returns the subclass Map for this query, if the query verifies correctly. |
java.util.List<java.lang.String> |
getView()
Returns the current view list. |
boolean |
isPathCompletelyInner(java.lang.String stringPath)
Returns true if a path string is in the root outer join group of this query. |
boolean |
isValid()
Returns true if the query verifies correctly. |
Path |
makePath(java.lang.String path)
Produces a Path object from the given path String, using subclass information from the query. |
void |
removeAllIrrelevant()
Removes everything from this query that is irrelevant, and therefore making the query invalid. |
void |
removeAllUnder(java.lang.String path)
Removes everything under a given path from the query, such that if the query was valid before, it will be valid after this method. |
void |
removeConstraint(PathConstraint constraint)
Removes a constraint from this query. |
void |
removeOrderBy(java.lang.String orderPath)
Removes an element from the order by list of this query. |
java.util.List<java.lang.String> |
removeSubclassAndFixUp(java.lang.String path)
Removes a subclass from the query, and removes any parts of the query that relied on it. |
void |
removeView(java.lang.String viewPath)
Removes a single element from the view list. |
void |
replaceConstraint(PathConstraint old,
PathConstraint replacement)
Replaces a constraint in the query with a different, carrying over the constraint code, and preserving the constraint logic. |
void |
setConstraintLogic(java.lang.String logic)
Sets the current constraint logic. |
void |
setDescription(java.lang.String description)
Sets the description for this PathQuery. |
void |
setDescription(java.lang.String path,
java.lang.String description)
Sets the description for a given path. |
void |
setOuterJoinStatus(java.lang.String path,
OuterJoinStatus status)
Sets the outer join status of the last part of a given path in this query. |
protected void |
sortConstraints(java.util.List<PathConstraint> listToSortBy)
A method to sort constraints by a given lists, provided to allow TemplateQuery to set a specific sort order that will be preserved in a round-trip to XML. |
java.lang.String |
toString()
Converts this object into a rudimentary String format, containing all the data. |
java.lang.String |
toXml(int version)
Convert a PathQuery to XML. |
java.util.List<java.lang.String> |
verifyQuery()
Verifies the contents of this query against the model, and for internal integrity. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final java.util.regex.Pattern SPACE_SPLITTER
public static final int USERPROFILE_VERSION
| Constructor Detail |
|---|
public PathQuery(Model model)
model - a Model objectpublic PathQuery(PathQuery o)
o - a PathQuery to copy| Method Detail |
|---|
public Model getModel()
public void addView(java.lang.String viewPath)
viewPath - the new path String to add to the view list
java.lang.NullPointerException - if viewPath is null
java.lang.IllegalArgumentException - if the viewPath contains colons or square brackets, or is
otherwise in a bad formatpublic void removeView(java.lang.String viewPath)
viewPath - the path String to remove from the view list
java.lang.NullPointerException - if the viewPath is null
java.util.NoSuchElementException - if the viewPath is not already on the view listpublic void clearView()
public void addViews(java.util.Collection<java.lang.String> viewPaths)
viewPaths - a Collection of String paths to add to the view list
java.lang.NullPointerException - if viewPaths is null or contains a null element
java.lang.IllegalArgumentException - if a view path contains colons or square brackets, or is
otherwise in a bad formatpublic void addViews(java.lang.String... viewPaths)
viewPaths - String paths to add to the view list
java.lang.NullPointerException - if viewPaths is null or contains a null element
java.lang.IllegalArgumentException - if a view path contains colons or square brackets, or is
otherwise in a bad formatpublic void addViewSpaceSeparated(java.lang.String viewPaths)
viewPaths - String paths to add to the view list
java.lang.NullPointerException - if viewPaths is null or contains a null element
java.lang.IllegalArgumentException - if a view path contains colons or square brackets, or is
otherwise in a bad formatpublic java.util.List<java.lang.String> getView()
public void addOrderBy(java.lang.String orderPath,
OrderDirection direction)
orderPath - the path expression to add to the order by listdirection - the sort order
java.lang.NullPointerException - if orderPath or direction is null
java.lang.IllegalArgumentException - if the orderPath contains colons or square brackets, or is
otherwise in a bad formatpublic void removeOrderBy(java.lang.String orderPath)
orderPath - the path String to remove from the order by list
java.lang.NullPointerException - if the orderPath is null
java.util.NoSuchElementException - if the orderPath is not already in the order by listpublic void clearOrderBy()
public void addOrderBy(OrderElement orderElement)
orderElement - an OrderElement to add to the order by list
java.lang.NullPointerException - if orderElement is nullpublic void addOrderBys(java.util.Collection<OrderElement> orderElements)
orderElements - a Collection of OrderElement objects to add to the view list
java.lang.NullPointerException - if orderElements is null or contains a null elementpublic void addOrderBys(OrderElement... orderElements)
orderElements - an array/varargs of OrderElement objects to add to the view list
java.lang.NullPointerException - if orderElements is null or contains a null elementpublic void addOrderBySpaceSeparated(java.lang.String orderString)
orderString - the order elements in space-separated string form
java.lang.NullPointerException - if orderString is null
java.lang.IllegalArgumentException - if a path expression contains colons or square brackets, or
is otherwise in a bad format, or if there is not an even number of space-separated elements,
or if any even-numbered element is not either "asc" or "desc".public java.util.List<OrderElement> getOrderBy()
public java.lang.String addConstraint(PathConstraint constraint)
constraint - the PathConstraint to add to this query
java.lang.NullPointerException - if the constraint is null
public void addConstraint(PathConstraint constraint,
java.lang.String code)
constraint - the PathConstraint to add to this querycode - the constraint code to associate with this constraint
java.lang.NullPointerException - if the constraint or the code is null
java.lang.IllegalStateException - if the constraint is already associated with a different code,
or the code is already associated with a different constraint
java.lang.IllegalArgumentException - if the code is in an inappropriate format - that is, if it
is not a single uppercase characterpublic void removeConstraint(PathConstraint constraint)
constraint - the PathConstraint to remove from this query
java.lang.NullPointerException - if the constraint is null
java.util.NoSuchElementException - if the constraint is not present in the query
public void replaceConstraint(PathConstraint old,
PathConstraint replacement)
old - the old PathConstraint objectreplacement - the new PathConstraint object to replace it
java.lang.NullPointerException - if old or replacement are null
java.util.NoSuchElementException - if the old PathConstraint is not already in the query
java.lang.IllegalArgumentException - if the code from the old constraint is not appropriate to
the replacement constraint
java.lang.IllegalStateException - if the replacement is already in the querypublic void clearConstraints()
public void addConstraints(java.util.Collection<PathConstraint> constraints)
constraints - the PathConstraint objects to add to this query
java.lang.NullPointerException - if constraints is null, or if it contains a null elementpublic void addConstraints(PathConstraint... constraints)
constraints - the PathConstraint objects to add to this query
java.lang.NullPointerException - if constraints is null, or if it contains a null elementpublic java.util.Map<PathConstraint,java.lang.String> getConstraints()
public PathConstraint getConstraintForCode(java.lang.String code)
code - a single uppercase character
java.lang.NullPointerException - if code is null
java.util.NoSuchElementException - if there is no PathConstraint for that codepublic java.util.List<PathConstraint> getConstraintsForPath(java.lang.String path)
path - the path to fetch constraints for
public java.util.Set<java.lang.String> getConstraintCodes()
public java.lang.String getConstraintLogic()
public void setConstraintLogic(java.lang.String logic)
logic - the constraint logicpublic OuterJoinStatus getOuterJoinStatus(java.lang.String path)
path - a String path to check
java.lang.NullPointerException - if path is null
java.lang.IllegalArgumentException - if the path String contains colons or square brackets, or is
otherwise in a bad format
public void setOuterJoinStatus(java.lang.String path,
OuterJoinStatus status)
path - a String path to setstatus - an OuterJoinStatus object
java.lang.NullPointerException - if path is null
java.lang.IllegalArgumentException - if the path String contains colons or square brackets, or is
otherwise in a bad formatpublic java.util.Map<java.lang.String,OuterJoinStatus> getOuterJoinStatus()
public void clearOuterJoinStatus()
public java.util.Map<java.lang.String,java.lang.Boolean> getOuterMap()
public java.lang.String getDescription(java.lang.String path)
path - a String path to check
java.lang.NullPointerException - if path is null
java.lang.IllegalArgumentException - if the path String contains colons or square brackets, or is
otherwise in a bad format
public void setDescription(java.lang.String path,
java.lang.String description)
path - the String path to setdescription - a String description or null
java.lang.NullPointerException - if path is null
java.lang.IllegalArgumentException - if the path String contains colons or square brackets, or is
otherwise in a bad formatpublic java.util.Map<java.lang.String,java.lang.String> getDescriptions()
public void clearDescriptions()
public java.lang.String getGeneratedPathDescription(java.lang.String path)
path - a String path with no square brackets or colons
java.lang.NullPointerException - is path is null
java.lang.IllegalArgumentException - if the path String contains colons or square brackets, or is
otherwise in a bad formatpublic void setDescription(java.lang.String description)
description - the new description, or null for nonepublic java.lang.String getDescription()
public void removeAllUnder(java.lang.String path)
path - everything under this path will be removed from the query
java.lang.NullPointerException - is path is null
java.lang.IllegalArgumentException - if the path String contains colons or square brackets, or is
otherwise in a bad format
public void removeAllIrrelevant()
throws PathException
PathException - if the query is invalid for a reason other than irrelevance
public java.util.List<java.lang.String> fixUpForJoinStyle()
throws PathException
PathException - if the query is invalid in any way other than that which this method
will fix.
public java.util.List<java.lang.String> removeSubclassAndFixUp(java.lang.String path)
throws PathException
path - the path of the subclass constraint to remove
PathException - if the query is already invalid
java.lang.NullPointerException - is path is null
java.lang.IllegalArgumentException - if the path String contains colons or square brackets, or is
otherwise in a bad formatpublic PathQuery clone()
clone in class java.lang.Object
public Path makePath(java.lang.String path)
throws PathException
path - the String path
PathException - if something goes wrong, or if the path is in an invalid formatpublic boolean isValid()
public java.util.List<java.lang.String> verifyQuery()
public java.lang.String getRootClass()
throws PathException
PathException - if the query does not verify
public java.util.Map<java.lang.String,java.lang.String> getSubclasses()
throws PathException
PathException - if the query does not verifypublic java.util.Set<java.lang.String> getBagNames()
public java.util.Map<java.lang.String,java.lang.String> getOuterJoinGroups()
throws PathException
PathException - if the query does not verify
public java.util.Set<java.lang.String> getExistingLoops()
throws PathException
PathException - if the query does not verify
public java.lang.String getOuterJoinGroup(java.lang.String stringPath)
throws PathException
stringPath - a pathString
java.lang.NullPointerException - if pathString is null
PathException - if the query is invalid or the path is invalid
java.util.NoSuchElementException - is the path is not in the query
public boolean isPathCompletelyInner(java.lang.String stringPath)
throws PathException
stringPath - a path String
java.lang.NullPointerException - if pathString is null
PathException - if the query is invalid or the path is invalid
java.util.NoSuchElementException - if the path is not in the query
public java.util.Set<java.lang.String> getCandidateLoops(java.lang.String stringPath)
throws PathException
stringPath - a path String
java.lang.NullPointerException - if stringPath is null
java.lang.IllegalArgumentException - if stringPath refers to an attribute
PathException - if the query is invalid or stringPath is invalid
public java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getConstraintGroups()
throws PathException
PathException - if the query does not verify
public java.util.List<java.lang.String> getGroupedConstraintLogic()
throws PathException
PathException - if the query does not verify
public LogicExpression getConstraintLogicForGroup(java.lang.String group)
throws PathException
group - an outer join group
PathException - if the query does not verify
java.lang.IllegalArgumentException - if the group is not present in this querypublic static void checkPathFormat(java.lang.String path)
path - a String path
java.lang.NullPointerException - if path is null
java.lang.IllegalArgumentException - if path contains colons or square brackets, or is otherwise
in a bad formatpublic PathQuery getQueryToExecute()
protected void sortConstraints(java.util.List<PathConstraint> listToSortBy)
listToSortBy - a list to define the new constraint orderpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toXml(int version)
version - the version number of the XML format
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||