net.sourceforge.pmd.util.viewer.model
Class ViewerModel

java.lang.Object
  extended bynet.sourceforge.pmd.util.viewer.model.ViewerModel

public class ViewerModel
extends java.lang.Object

The model for the viewer gui

This is the model part of MVC

Version:
$Id: ViewerModel.java,v 1.8 2005/08/23 17:17:49 tomcopeland Exp $
Author:
Boris Gruschko ( boris at gruschko.org )

Constructor Summary
ViewerModel()
          constructs the model
 
Method Summary
 void addViewerModelListener(ViewerModelListener l)
          adds a listener to the model
 void appendToXPathExpression(java.lang.String pathFragment, java.lang.Object appender)
          appends the given fragment to the XPath expression
 void commitSource(java.lang.String source)
          commits source code to the model.
 void evaluateXPathExpression(java.lang.String xPath, java.lang.Object evaluator)
          evaluates the given XPath expression against the current tree
protected  void fireViewerModelEvent(ViewerModelEvent e)
          notifes all listener of a change in the model
 java.util.List getLastEvaluationResults()
          retrieves the results of last evaluation
 SimpleNode getRootNode()
          Retrieves AST's root node
 boolean hasCompiledTree()
          determines wheteher the model has a compiled tree at it's disposal
 void removeViewerModelListener(ViewerModelListener l)
          removes the lisetener from the model
 void selectNode(SimpleNode node, java.lang.Object selector)
          selects the given node in the AST
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewerModel

public ViewerModel()
constructs the model

Method Detail

getRootNode

public SimpleNode getRootNode()
Retrieves AST's root node

Returns:
AST's root node

commitSource

public void commitSource(java.lang.String source)
commits source code to the model.

all existing source will be replaced

Parameters:
source - source to be commited

hasCompiledTree

public boolean hasCompiledTree()
determines wheteher the model has a compiled tree at it's disposal

Returns:
true if there is an AST, false otherwise

evaluateXPathExpression

public void evaluateXPathExpression(java.lang.String xPath,
                                    java.lang.Object evaluator)
                             throws ParseException,
                                    org.jaxen.JaxenException
evaluates the given XPath expression against the current tree

Parameters:
xPath - XPath expression to be evaluated
evaluator - object which requests the evaluation
Throws:
ParseException
org.jaxen.JaxenException

getLastEvaluationResults

public java.util.List getLastEvaluationResults()
retrieves the results of last evaluation

Returns:
a list containing the nodes selected by the last XPath expression

evaluation


selectNode

public void selectNode(SimpleNode node,
                       java.lang.Object selector)
selects the given node in the AST

Parameters:
node - node to be selected
selector - object which requests the selection

appendToXPathExpression

public void appendToXPathExpression(java.lang.String pathFragment,
                                    java.lang.Object appender)
appends the given fragment to the XPath expression

Parameters:
pathFragment - fragment to be added
appender - object that is trying to append the fragment

addViewerModelListener

public void addViewerModelListener(ViewerModelListener l)
adds a listener to the model

Parameters:
l - listener to be added

removeViewerModelListener

public void removeViewerModelListener(ViewerModelListener l)
removes the lisetener from the model

Parameters:
l - listener to be removed

fireViewerModelEvent

protected void fireViewerModelEvent(ViewerModelEvent e)
notifes all listener of a change in the model

Parameters:
e - change's reason


Copyright © 2002-2005 InfoEther. All Rights Reserved.