org.stanwood.media.database
Class DBRegExpTokenMapping

java.lang.Object
  extended by org.stanwood.media.database.DBRegExpTokenMapping
All Implemented Interfaces:
IDBTokenMappings

public class DBRegExpTokenMapping
extends java.lang.Object
implements IDBTokenMappings

This is used to translate DB tokens from MySQL to another database. It does this through the use of regular expressions. If the regular expression is used to extract groups from the SQL, then these can be placed in the native token, via the syntax $1....$n for groups 1....n.


Constructor Summary
DBRegExpTokenMapping(java.lang.String mysqlRegexp, java.lang.String nativeToken)
          Used to construct a regular expression token mapping.
 
Method Summary
 boolean accept(java.lang.String token)
          Part of the SQL is passed into this method.
 java.lang.String getNativeToken()
          If this mapping handled a token with accept(String) was called, then this will return the replacement token.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBRegExpTokenMapping

public DBRegExpTokenMapping(java.lang.String mysqlRegexp,
                            java.lang.String nativeToken)
Used to construct a regular expression token mapping.

Parameters:
mysqlRegexp - The regular expression to match on.
nativeToken - The returned token pattern.
Method Detail

accept

public boolean accept(java.lang.String token)
Part of the SQL is passed into this method. If it to be converted, then this method should return true.

Specified by:
accept in interface IDBTokenMappings
Parameters:
token - The SQL token that is been checked
Returns:
True if handled by the mapping, otherwise false.

getNativeToken

public java.lang.String getNativeToken()
If this mapping handled a token with accept(String) was called, then this will return the replacement token.

Specified by:
getNativeToken in interface IDBTokenMappings
Returns:
The replacement token