Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

oracle.javatools.db.plsql
Class PlSqlSearch

java.lang.Object
  extended by oracle.javatools.db.plsql.PlSqlSearch

public class PlSqlSearch
extends java.lang.Object

PlSqlSearch works in colaboration with the PlSqlTokenizer (and/or PlSqlInterrogator) to provide a search mechanism for PL/SQL (including Triggers and User Defined Types).

Searches are applied using a regular expression like syntax, and applied only to the code, ignoring whitespace and comments.

Search Clause Syntax
A search expression is made up of one or more seach clauses, where a search clause is defined as one of the following:

Wildcards
A question mark ( ? ) can be placed in the expression, and this will match any single token. By combining the wildcard with the other search clause syntax, more complex strings can be matched. Using these combinations, two shortcuts are available: Named Clauses
The results of any part of a match can be queried by naming search clauses within the overall expression. This is done by preceeding the search clause with the required name and enclosing the name and clause with < and > For example "procedure <name ?.>" would be found in both
create or replace procedure updateSalary is...
and
create or replace procedure hr.updateSalary is...
the value of name in the first case being UPDATESALARY and in the second HR.UPDATESALARY. See getNamedMatch(String name, boolean format) for details.


Constructor Summary
PlSqlSearch(java.lang.String expression)
          Constructs a PlSqlSearch with the given expression.
 
Method Summary
 PlSqlToken getEndToken()
           
 java.lang.String getNamedMatch(java.lang.String name)
           
 java.lang.String getNamedMatch(java.lang.String name, boolean format)
          Returns the results of a named search clause.
 java.lang.String[] getNames()
           
 PlSqlToken getStartToken()
           
 int getTokenCount()
           
 boolean isWithin(PlSqlToken startToken)
           
 boolean isWithin(PlSqlToken startToken, PlSqlToken endToken)
           
 boolean isWithin(java.lang.String source)
           
 boolean matches(PlSqlToken startToken)
           
 boolean matches(PlSqlToken startToken, PlSqlToken endToken)
           
 boolean matches(java.lang.String source)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlSqlSearch

public PlSqlSearch(java.lang.String expression)
            throws PlSqlSearchException
Constructs a PlSqlSearch with the given expression.

Parameters:
expression -
Throws:
PlSqlSearchException
Method Detail

matches

public final boolean matches(java.lang.String source)
Returns:
true if the PlSqlSearch matches the source, false otherwise.

matches

public final boolean matches(PlSqlToken startToken)
Returns:
true if the PlSqlSearch matches the list of PlSqlTokens starting at startToken, false otherwise.

matches

public final boolean matches(PlSqlToken startToken,
                             PlSqlToken endToken)
Returns:
true if the PlSqlSearch matches the list of PlSqlTokens starting at startToken and not extending past endToken, false otherwise.

isWithin

public final boolean isWithin(java.lang.String source)
Returns:
true if the PlSqlSearch is found within the given source, false otherwise.

isWithin

public final boolean isWithin(PlSqlToken startToken)
Returns:
true if the PlSqlSearch is found within the list of PlSqlTokens starting at startToken, false otherwise.

isWithin

public final boolean isWithin(PlSqlToken startToken,
                              PlSqlToken endToken)
Returns:
true if the PlSqlSearch is found within the list of PlSqlTokens starting at startToken and not extending past endToken, false otherwise.

getNamedMatch

public final java.lang.String getNamedMatch(java.lang.String name)
Returns:
the formatted result of a named Seach Clause within the PlSqlSearch if that clause matched. See getNamedMatch(String name, boolean format)

getNamedMatch

public final java.lang.String getNamedMatch(java.lang.String name,
                                            boolean format)
Returns the results of a named search clause.

Parameters:
name - The search clause name.
format - how the match should be returned
  • if format == false, the results are the exact string from the original source from the start of the match to end. This will preserve the case of the original source, include whitespace and comments.
  • if format == true, the results will have comments removed, alphanumerics (other than string literals) will be forced to uppercase, and white space will just be around alphanumerics and following right parenthesis.
Returns:
the result of a named Seach Clause within the PlSqlSearch if that clause matched. If named clause did not produce a match, or the name cannot be found, null is returned.

getStartToken

public PlSqlToken getStartToken()
Returns:
the first token of a successful match, or null if match failed

getEndToken

public PlSqlToken getEndToken()
Returns:
the last token of a successful match, or null if match failed

getNames

public java.lang.String[] getNames()
Returns:
the names used in named search clauses.

getTokenCount

public int getTokenCount()

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

Copyright © 1997, 2013, Oracle. All rights reserved.