|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jafer.query.QueryBuilder
public class QueryBuilder
Class for building XML representations of Z39.50 Bib1 queries.
A default search profile is used if one has been set using an appropriate constructor.
Some getNode() methods allow the default search profile to be altered, or ignored for that query.
of XML structure available at www.jafer.org .
Field Summary | |
---|---|
(package private) int[] |
defaultAttributes
|
private org.w3c.dom.Document |
document
|
Constructor Summary | |
---|---|
QueryBuilder()
Constructs a new QueryBuilder without any default search profile. |
|
QueryBuilder(int[] defaultSearchProfile)
Constructs a new QueryBuilder with a default Bib1 search profile which will be used in creating queries. |
|
QueryBuilder(java.lang.String defaultSearchProfile)
Constructs a new QueryBuilder with a default Bib1 search profile which will be used in creating queries. |
Method Summary | |
---|---|
org.w3c.dom.Node |
and(org.w3c.dom.Node leftNode,
org.w3c.dom.Node rightNode)
Produces an AND node from 2 nodes, which can be query or Boolean nodes. |
org.w3c.dom.Node |
and(java.util.Vector useAttributes,
java.util.Vector terms)
Produces an AND node from a pair of attributes, or a tree of AND nodes if more than 2 attributes are given. |
private org.w3c.dom.Node |
buildConstraintModelNode(int[] attributes,
java.lang.String term)
Builds an XML representation of a query, using Bib1 attributes. |
private java.lang.String[] |
getConstraintModelData(org.w3c.dom.Node cM)
|
java.lang.String[][] |
getContent(org.w3c.dom.Node queryNode)
Method returns a representation of an XML query as a 2 dimensional String[]. |
org.w3c.dom.Node |
getNode(int[][] attTypesValues,
java.lang.String term)
Creates a basic query node incorporating the term and attributes supplied. |
org.w3c.dom.Node |
getNode(int[] attributes,
java.lang.String term)
Creates a basic query node incorporating the attributes and term supplied. |
org.w3c.dom.Node |
getNode(int useAttribute,
java.lang.String term)
Creates a basic query node incorporating the Use attribute and term supplied. |
org.w3c.dom.Node |
getNode(java.lang.String queryExp)
Create a Node from a query string |
org.w3c.dom.Node |
getNode(java.lang.String[] termAndAttributes)
Creates a basic query node incorporating the term and attributes supplied. |
org.w3c.dom.Node |
getNode(java.lang.String useAttribute,
java.lang.String term)
Creates a basic query node incorporating the Use attribute and term supplied. |
private void |
getNodeData(org.w3c.dom.Node node,
java.util.Vector nodeData)
|
private java.lang.String |
getNodeValue(org.w3c.dom.Node node)
|
private int |
lookUpUseAttribute(java.lang.String attributeString)
|
org.w3c.dom.Node |
not(org.w3c.dom.Node inputNode)
Produces a NOT node from the supplied node, which can be a query or Boolean node. |
org.w3c.dom.Node |
or(org.w3c.dom.Node leftNode,
org.w3c.dom.Node rightNode)
Produces an OR node from 2 nodes, which can be query or Boolean nodes. |
org.w3c.dom.Node |
or(java.util.Vector useAttributes,
java.util.Vector terms)
Produces an OR node from a pair of attributes, or a tree of OR nodes if more than 2 attributes are given. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private org.w3c.dom.Document document
int[] defaultAttributes
Constructor Detail |
---|
public QueryBuilder()
public QueryBuilder(int[] defaultSearchProfile)
The profile parameter is interpreted in the following order:
[1] Use, [2] Relation, [3] Position, [4] Structure, [5] Truncation, [6] Completeness
A value of zero in the array will be ignored, and can be used as a spacer.
(Default search profile can be overidden when using certain getNode() methods.)
defaultSearchProfile
- int array (0 < length < 7)public QueryBuilder(java.lang.String defaultSearchProfile)
The profile parameter consists of a dot delimited String (eg: 4.3.3.101.100.1), with values interpreted in the following order:
Use, Relation, Position, Structure, Truncation, Completeness.
A value of zero will be ignored, and can be used as a spacer.
(Default search profile can be overidden when using certain getNode() methods.)
defaultSearchProfile
- dot delimited String with at least 1, and a
maximum of 6 items.Method Detail |
---|
public org.w3c.dom.Node getNode(java.lang.String useAttribute, java.lang.String term) throws QueryException
Attribute supplied must be the name of a Use attribute (eg: "Title"), or a String representation of its corresponding numeric value (eg: "4").
Note: If an attribute name is supplied, it is checked against lookup
table via org.jafer.conf.Config.getAttributeValue()
, but
not if a corresponding numeric value is used, in which case any positive
value within the int range is accepted.
getNode
in interface QueryBuilder
useAttribute
- represents the Use attribute to be used in the query,
e.g. "title".term
- the term to be used in the query.
org.jafer.zclient.QueryException
- if useAttribute
parameter is not valid, and term
is empty..
QueryException
public org.w3c.dom.Node getNode(int useAttribute, java.lang.String term) throws QueryException
Attribute value is not checked, any positive int value is accepted.
getNode
in interface QueryBuilder
useAttribute
- represents the Use attribute to be used in the query.term
- the term to be used in the query.
QueryException
- if parameters are not valid or
empty.public org.w3c.dom.Node getNode(int[] attributes, java.lang.String term) throws QueryException
The int[] parameter values are used in order for:
{Use, Relation, Position, Structure, Truncation, Completeness}
e.g. { 4, 3, 3, 2, 100, 1 }
A smaller sized array can be used, in which case the values given will be interpreted in order, following the pattern above.
A parameter value of 0 will cause the corresponding attribute type to be excluded from the query.
(If a default search profile has been set, it will be overridden for this query: any values supplied in the parameter will replace corresponding default values.)
getNode
in interface QueryBuilder
attributes
- represents the attribute values to be used in the
query.term
- the term to be used in the query.
org.jafer.zclient.QueryException
- if attributes
array size is smaller than 1, or larger than 6.
QueryException
public org.w3c.dom.Node getNode(int[][] attTypesValues, java.lang.String term) throws QueryException
The int[][] parameter holds the attribute types and corresponding values.
e.g. {{1,1003}, {2,3}, {4,2}} would set:
Use = 1003, Relation = 3 and Structure = 2.
A parameter value of 0 will result in the corresponding attribute type to be excluded from the query.
(If a default search profile has been set, it will be altered for this query: any values given in the parameter will replace corresponding default values.)
getNode
in interface QueryBuilder
attTypesValues
- represents the attribute types and their
corresponding values to be used in the query.term
- the term to be used in the query.
org.jafer.zclient.QueryException
- if attTypesValues
array size is smaller than 1, or larger than 6. Also if the first
attribute type is missing, or not a positive value.
QueryException
public org.w3c.dom.Node getNode(java.lang.String[] termAndAttributes) throws QueryException
The String[] parameter holds the term to be used in position [0], and the remaining attributes thereafter, eg:
{"Shakespeare", "1003", "3", "3", "2", "100", "1"}
Shorter arrays can be used, and values of "0" will cause that attribute to be omitted from the query.
(If a default search profile has been set, it will be ignored for this query)
getNode
in interface QueryBuilder
termAndAttributes
- the term (position [0]) and attributes to be
used in the query.
QueryException
private org.w3c.dom.Node buildConstraintModelNode(int[] attributes, java.lang.String term) throws QueryException
attributes
- represents the attribute values to be used in the
query.term
- the term to be used in the query.
org.jafer.zclient.QueryException
- if there is an error in the
attribute lookup, or the term is empty.
QueryException
of XML structure available at www.jafer.org .
public org.w3c.dom.Node and(org.w3c.dom.Node leftNode, org.w3c.dom.Node rightNode) throws QueryException
and
in interface QueryBuilder
leftNode
- a query, AND, OR or NOT node.rightNode
- a query, AND, OR or NOT node.
QueryException
- if either Node parameter is null.public org.w3c.dom.Node and(java.util.Vector useAttributes, java.util.Vector terms) throws QueryException
Vector parameters: Minimum size is 2, and must contain only String objects.
Attributes supplied must be the name of a Use attribute (eg: "Title"), or a String representation of its corresponding numeric value (eg: "4").
Note: If an attribute name is supplied, it is checked against lookup
table via org.jafer.conf.Config.getAttributeValue()
, but
not if a corresponding numeric value is used, in which case any positive
value within the int range is accepted.
useAttributes
- the attribute values to be used in building the
query.terms
- the corresponding terms to be used in building the query.
QueryException
- if a problem is encountered with
the input Vectors.public org.w3c.dom.Node or(org.w3c.dom.Node leftNode, org.w3c.dom.Node rightNode) throws QueryException
or
in interface QueryBuilder
leftNode
- a query, AND, OR or NOT node.rightNode
- a query, AND, OR or NOT node.
QueryException
- if either Node parameter is null.public org.w3c.dom.Node or(java.util.Vector useAttributes, java.util.Vector terms) throws QueryException
Vector parameters: minimum size is 2, and must contain only String objects.
Attributes supplied must be the name of a Use attribute (eg: "Title"), or a String representation of its corresponding numeric value (eg: "4").
Note: If an attribute name is supplied, it is checked against lookup
table via org.jafer.conf.Config.getAttributeValue()
, but
not if a corresponding numeric value is used, in which case any positive
value within the int range is accepted.
useAttributes
- the attribute values to be used in building the
query.terms
- the corresponding terms to be used in building the query.
QueryException
- if a problem is encountered with
the input Vectors.public org.w3c.dom.Node not(org.w3c.dom.Node inputNode) throws QueryException
not
in interface QueryBuilder
inputNode
- a query, AND or OR node.
QueryException
- if inputNode parameter is null..public org.w3c.dom.Node getNode(java.lang.String queryExp) throws QueryException
QueryException
public java.lang.String[][] getContent(org.w3c.dom.Node queryNode) throws QueryException
Operands follow operators.
An operator is a String[] containing 1 String, eg: {"and"}
An operand is a String[] containing a term, followed by up to 6 attributes. eg:
{"Shakespeare", "1003", "3", "3", "2", "100", "1"}
queryNode
- the XML query node.
QueryException
- if a problem is found in the query
structure.private void getNodeData(org.w3c.dom.Node node, java.util.Vector nodeData) throws QueryException
QueryException
private java.lang.String[] getConstraintModelData(org.w3c.dom.Node cM) throws QueryException
QueryException
private java.lang.String getNodeValue(org.w3c.dom.Node node)
private int lookUpUseAttribute(java.lang.String attributeString) throws QueryException
QueryException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |