org.mmbase.bridge.implementation
Class BasicNodeQuery

java.lang.Object
  extended by org.mmbase.bridge.implementation.BasicQuery
      extended by org.mmbase.bridge.implementation.BasicNodeQuery
All Implemented Interfaces:
Serializable, Cloneable, NodeQuery, Query, Cacheable, SearchQuery, SearchQueryWrapper, PublicCloneable<Query>

public class BasicNodeQuery
extends BasicQuery
implements NodeQuery

'Basic' implementation of bridge NodeQuery. Wraps a Query with all and only fields of one Step. If there is only one step, this can wrap NodeSearchQuery of core. Often, queries with more steps are sensible nodequeries, because sorting (e.g. posrel.pos) or filtering can be done on those steps (e.g. publishtimes). Nodes of this type can be used as an argument to function which do return 'real' nodes (so not clusternodes).

Since:
MMBase-1.7
Version:
$Id: BasicNodeQuery.java 41855 2010-04-12 16:21:03Z michiel $
Author:
Michiel Meeuwissen
See Also:
NodeSearchQuery, Serialized Form
To Do:
perhaps it would be nice to have the possibllity to query also two complete steps (also one of the neigbouring 'relation' steps). this would give nice efficient implementations of things like mm:relatednode (of mm:listrelations), This kind of functionality should perhaps be present in NodeSearchQuery itself because you can then use it 'under' the bridge too.

Field Summary
protected  Step step
           
 
Fields inherited from class org.mmbase.bridge.implementation.BasicQuery
aggregating, cloud, explicitFields, implicitFields, insecureConstraint, query, queryCheck, used
 
Fields inherited from interface org.mmbase.storage.search.SearchQuery
DEFAULT_MAX_NUMBER, DEFAULT_OFFSET
 
Constructor Summary
BasicNodeQuery(Cloud c)
           
BasicNodeQuery(Cloud cloud, NodeSearchQuery q)
           
BasicNodeQuery(Cloud cloud, SearchQuery q)
          Makes a multi-step node-query, based on a normal query.
BasicNodeQuery(NodeManager nodeManager)
          node query.
 
Method Summary
protected  void addFields(Collection<BasicStepField> c)
          Adds all fields of the gives collection, unless it is a field of the 'step' itself
 NodeQuery cloneWithoutFields()
          Clones this object, only without the fields
 StepField createStepField(String fieldName)
          Creates the step field for the given name.
 List<StepField> getExtraFields()
           
 NodeList getList()
          Executes the query and returns the resulting node list.
 NodeManager getNodeManager()
          Returns the node-manager.
 Step getNodeStep()
          Returns the step for which the fields are added (or null)
 StepField getStepField(Field field)
          Since in a NodeQuery one of the steps is 'exceptional', also this function makes sense now.
 void removeFields()
          Removes all fields from the Query object.
 Query setDistinct(boolean distinct)
          Specifies wether the query result must contain only 'distinct' results.
 Step setNodeStep(Step step)
          Removes all fields and add all fields of the given step.
 
Methods inherited from class org.mmbase.bridge.implementation.BasicQuery
addAggregatedField, addField, addField, addFieldImplicit, addNode, addNode, addRelationStep, addRelationStep, addRelationStep, addRelationStep, addSortOrder, addSortOrder, addSortOrder, addStep, aggregatingClone, clone, createAlias, createConstraint, createConstraint, createConstraint, createConstraint, createConstraint, createConstraint, createConstraint, createConstraint, createConstraint, createConstraint, createNewQuery, createStepField, createStepField, equals, getCachePolicy, getCleanConstraint, getCloud, getConstraint, getFields, getMaxNumber, getOffset, getQuery, getSortOrders, getSql, getStep, getSteps, glueAlias, hashCode, isAggregating, isDistinct, isSecure, isUsed, markUsed, removeImplicitFields, removeSecurityConstraint, removeSecurityConstraintFromClone, setAlias, setCachePolicy, setCaseSensitive, setConstraint, setInverse, setMaxNumber, setOffset, setSecurityConstraint, toSql, toString, unwrap
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mmbase.bridge.Query
addAggregatedField, addField, addField, addNode, addNode, addRelationStep, addRelationStep, addSortOrder, addSortOrder, addSortOrder, addStep, aggregatingClone, clone, createConstraint, createConstraint, createConstraint, createConstraint, createConstraint, createConstraint, createConstraint, createConstraint, createConstraint, createConstraint, createStepField, createStepField, getCleanConstraint, getCloud, getStep, isUsed, markUsed, removeImplicitFields, setAlias, setCaseSensitive, setConstraint, setInverse, setMaxNumber, setOffset, toSql
 
Methods inherited from interface org.mmbase.storage.search.SearchQuery
equals, getConstraint, getFields, getMaxNumber, getOffset, getSortOrders, getSteps, hashCode, isAggregating, isDistinct, toString
 
Methods inherited from interface org.mmbase.cache.Cacheable
getCachePolicy, setCachePolicy
 
Methods inherited from interface org.mmbase.storage.search.SearchQueryWrapper
unwrap
 

Field Detail

step

protected Step step
Constructor Detail

BasicNodeQuery

public BasicNodeQuery(Cloud c)

BasicNodeQuery

public BasicNodeQuery(NodeManager nodeManager)
node query.


BasicNodeQuery

BasicNodeQuery(Cloud cloud,
               NodeSearchQuery q)

BasicNodeQuery

BasicNodeQuery(Cloud cloud,
               SearchQuery q)
Makes a multi-step node-query, based on a normal query. As a default, all fields of last steps are added (if at least there are steps already)

Method Detail

getNodeManager

public NodeManager getNodeManager()
Description copied from interface: NodeQuery
Returns the node-manager. Or 'null' if this is not yet determined.

Specified by:
getNodeManager in interface NodeQuery
Returns:
node-manager or 'null'

getNodeStep

public Step getNodeStep()
Description copied from interface: NodeQuery
Returns the step for which the fields are added (or null)

Specified by:
getNodeStep in interface NodeQuery
Returns:
step for which the fields are added

createStepField

public StepField createStepField(String fieldName)
Description copied from interface: Query
Creates the step field for the given name. For a NodeQuery the arguments is simply the name of the field. For a 'normal' query, it should be prefixed by the (automatic) alias of the Step.

Specified by:
createStepField in interface Query
Overrides:
createStepField in class BasicQuery
Parameters:
fieldName - field identifier to create StepField from
Returns:
new StepField

getStepField

public StepField getStepField(Field field)
Description copied from interface: NodeQuery
Since in a NodeQuery one of the steps is 'exceptional', also this function makes sense now.

Specified by:
getStepField in interface NodeQuery
Parameters:
field - field to get the StepField for.
Returns:
null if field is not of 'the' nodemanager.

removeFields

public void removeFields()
Description copied from interface: Query
Removes all fields from the Query object.

Specified by:
removeFields in interface Query
Overrides:
removeFields in class BasicQuery

getExtraFields

public List<StepField> getExtraFields()
Specified by:
getExtraFields in interface NodeQuery

addFields

protected void addFields(Collection<BasicStepField> c)
Adds all fields of the gives collection, unless it is a field of the 'step' itself


setDistinct

public Query setDistinct(boolean distinct)
Description copied from interface: Query
Specifies wether the query result must contain only 'distinct' results.

Specified by:
setDistinct in interface Query
Overrides:
setDistinct in class BasicQuery
Parameters:
distinct - 'distinct' results
Returns:
Query
See Also:
BasicSearchQuery.setDistinct(boolean), SearchQuery.isDistinct()

setNodeStep

public Step setNodeStep(Step step)
Description copied from interface: NodeQuery
Removes all fields and add all fields of the given step. This also can have an effect on the result of getNodeManager().

Specified by:
setNodeStep in interface NodeQuery
Parameters:
step - add all fields of the this step
Returns:
the previously associated step (if there was one, otherwise null).

cloneWithoutFields

public NodeQuery cloneWithoutFields()
Description copied from interface: Query
Clones this object, only without the fields

Specified by:
cloneWithoutFields in interface Query
Overrides:
cloneWithoutFields in class BasicQuery
Returns:
Cloned Query

getList

public NodeList getList()
Description copied from interface: Query
Executes the query and returns the resulting node list.

Specified by:
getList in interface Query
Overrides:
getList in class BasicQuery
Returns:
resulting node list


MMBase 2.0-SNAPSHOT - null