org.mevenide.idea.psi.util
Class XmlTagPath

java.lang.Object
  extended by org.mevenide.idea.psi.util.XmlTagPath

public class XmlTagPath
extends Object

Author:
Arik

Constructor Summary
XmlTagPath(com.intellij.psi.xml.XmlFile pFile)
          Creates an instance using the given file.
XmlTagPath(com.intellij.psi.xml.XmlFile pFile, String pPath)
          Creates an instance using the given file and tag path expression.
XmlTagPath(XmlTagPath pParent, String pPath)
          Creates an instance that extends the given parent path with the specified path.
 
Method Summary
 com.intellij.psi.xml.XmlTag ensureTag()
          Like the getTag() method, this method will return the final tag for the tag path.
 com.intellij.openapi.editor.Document getDocument()
          Returns the document (not the xml document).
 com.intellij.psi.xml.XmlFile getFile()
          Returns the XML file.
 XmlTagPath getParent()
          Returns the tag path parent, if any.
 String getPath()
          Returns the tag path.
 String getPath(boolean pIncludeParent)
          Returns the tag path, including or excluding the parent path, as specified by the given flag.
 String[] getPathAndConcat(String pTagName)
          Returns the tag path as string tokens, concatenating the given tag name to the end of the tag path.
 String[] getPathTokens()
          Returns the tag path as string tokens, where each item in the array is a tag name or expression.
 String[] getPathTokens(boolean pIncludeParent)
          Returns the tag path as string tokens, where each item in the array is a tag name or expression.
 com.intellij.openapi.project.Project getProject()
          Returns the path project.
 Integer getRow()
          Returns the row for the last path path.
 String getStringValue()
           
 com.intellij.psi.xml.XmlTag getTag()
          Returns (but does not create) the xml tag for the tag path expression.
 com.intellij.psi.xml.XmlTag[] getTags()
          Returns the tags in the tag-path as an array.
 void setPath(String pPath)
          Sets the tag path.
 void setRow(Integer pRow)
          Sets the row for the last path path.
 void setValue(Object pValue)
           
 void setValueProtected(Object pValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlTagPath

public XmlTagPath(com.intellij.psi.xml.XmlFile pFile)
Creates an instance using the given file.

Parameters:
pFile - the XML file

XmlTagPath

public XmlTagPath(com.intellij.psi.xml.XmlFile pFile,
                  String pPath)
Creates an instance using the given file and tag path expression.

Parameters:
pFile - the XML file
pPath - the tag path expression

XmlTagPath

public XmlTagPath(XmlTagPath pParent,
                  String pPath)
Creates an instance that extends the given parent path with the specified path.

Parameters:
pParent - the parent path to extend
pPath - the extending path
Method Detail

getProject

public final com.intellij.openapi.project.Project getProject()
Returns the path project. The project is derived from the XML file we are searching.

Returns:
project

getFile

public final com.intellij.psi.xml.XmlFile getFile()
Returns the XML file.

Returns:
the file

getParent

public XmlTagPath getParent()
Returns the tag path parent, if any.

Returns:
the parent, or null if there isn't any

getDocument

public final com.intellij.openapi.editor.Document getDocument()
Returns the document (not the xml document).

Returns:
idea document

getPath

public final String getPath()
Returns the tag path.

Returns:
string

getPath

public final String getPath(boolean pIncludeParent)
Returns the tag path, including or excluding the parent path, as specified by the given flag.

Parameters:
pIncludeParent - whether to use the parent path as a prefix
Returns:
string

setPath

public final void setPath(String pPath)
Sets the tag path.

Parameters:
pPath - the new path (may be null)

getRow

public final Integer getRow()
Returns the row for the last path path.

If this tag path has no path, this method will throw an IllegalStateException. If the last tag has no row, null is returned.

Returns:
the row number, or null

setRow

public final void setRow(Integer pRow)
Sets the row for the last path path.

If this tag path has no path, this method will throw an IllegalStateException. If the last tag already has a row, it is replaced with the new row number.

Parameters:
pRow - the new row number

getPathTokens

public final String[] getPathTokens()
Returns the tag path as string tokens, where each item in the array is a tag name or expression.

Returns:
string array

getPathTokens

public final String[] getPathTokens(boolean pIncludeParent)
Returns the tag path as string tokens, where each item in the array is a tag name or expression.

Returns:
string array

getPathAndConcat

public final String[] getPathAndConcat(String pTagName)
Returns the tag path as string tokens, concatenating the given tag name to the end of the tag path.

Parameters:
pTagName - the tag name to add at the end of the path
Returns:
string array

getTag

public final com.intellij.psi.xml.XmlTag getTag()
Returns (but does not create) the xml tag for the tag path expression.

This method will not create the path, and will return null if the path cannot be parsed (missing tags).

Returns:
the xml tag, or null

getTags

public final com.intellij.psi.xml.XmlTag[] getTags()
Returns the tags in the tag-path as an array. The length of the array will be of the number of tags that exist in the path.

For instance, if the path is set to "a/b/c", and tag "c" does not exist, the returned array will be: ["a","b"].

Returns:
a tag of XmlTag instances

ensureTag

public final com.intellij.psi.xml.XmlTag ensureTag()
                                            throws com.intellij.util.IncorrectOperationException
Like the getTag() method, this method will return the final tag for the tag path.

If, however, the tag path cannot be found, it will be created.

Returns:
the xml tag
Throws:
com.intellij.util.IncorrectOperationException - if the root tag does not satisfy the tag expression (incorrect name)

getStringValue

public final String getStringValue()

setValue

public void setValue(Object pValue)
              throws com.intellij.util.IncorrectOperationException
Throws:
com.intellij.util.IncorrectOperationException

setValueProtected

public final void setValueProtected(Object pValue)


Copyright © 2005 The Codehaus. All Rights Reserved.