byucc.edif.tools.merge
Class BasicEdifBusNamingPolicy

java.lang.Object
  extended by byucc.edif.tools.merge.BasicEdifBusNamingPolicy
All Implemented Interfaces:
EdifBusNamingPolicy

public class BasicEdifBusNamingPolicy
extends java.lang.Object
implements EdifBusNamingPolicy

Basic implementation of the EdifBusNamingPolicy using regular expressions. This class performs the parsing on given EdifNet names by comparing the names with predefined regular expressions. The regular expression defines the naming policy.

Author:
Michael J Wirthlin

Field Summary
(package private)  java.util.regex.Pattern _p
           
static java.lang.String BRACKET_INT_COLON_INT_BRACKET_RANGE_REGEX
           
static java.lang.String PARAN_INT_COLON_INT_PARAN_RANGE_REGEX
           
 
Constructor Summary
BasicEdifBusNamingPolicy(java.lang.String regex)
          Create a new naming policy based on the given regular expression.
 
Method Summary
 java.lang.String getBusBaseName(java.lang.String name)
          Return the basename of the bus name without all of the bus range information.
 int getLeftBusLimit(java.lang.String name)
          Returns the integer value of the "left" bus limit within the bus string name (i.e. will return a "4" for the following naming example "(4:8)").
 java.util.regex.Matcher getMatcher(java.lang.String name)
           
 int getRightBusLimit(java.lang.String name)
          Returns the integer value of the "right" bus limit within the bus string name (i.e. will return a "8" for the following naming example "(4:8)").
 boolean isValidBusName(java.lang.String name)
          Indicates whether the given String is a valid Bus name using the implemented bus naming policy.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAN_INT_COLON_INT_PARAN_RANGE_REGEX

public static final java.lang.String PARAN_INT_COLON_INT_PARAN_RANGE_REGEX
See Also:
Constant Field Values

BRACKET_INT_COLON_INT_BRACKET_RANGE_REGEX

public static final java.lang.String BRACKET_INT_COLON_INT_BRACKET_RANGE_REGEX
See Also:
Constant Field Values

_p

java.util.regex.Pattern _p
Constructor Detail

BasicEdifBusNamingPolicy

public BasicEdifBusNamingPolicy(java.lang.String regex)
Create a new naming policy based on the given regular expression. The regular expression should have three and only three "groups" (i.e. regular expression units separated by parenthesis). The first group will identify the "basename", the second group will identify the "left position", and the third will identify the "right position".

Method Detail

isValidBusName

public boolean isValidBusName(java.lang.String name)
Description copied from interface: EdifBusNamingPolicy
Indicates whether the given String is a valid Bus name using the implemented bus naming policy.

Specified by:
isValidBusName in interface EdifBusNamingPolicy

getMatcher

public java.util.regex.Matcher getMatcher(java.lang.String name)

getLeftBusLimit

public int getLeftBusLimit(java.lang.String name)
Description copied from interface: EdifBusNamingPolicy
Returns the integer value of the "left" bus limit within the bus string name (i.e. will return a "4" for the following naming example "(4:8)"). Will return a non-negative value if the string is valid. Otherwise, it returns -1.

Specified by:
getLeftBusLimit in interface EdifBusNamingPolicy

getRightBusLimit

public int getRightBusLimit(java.lang.String name)
Description copied from interface: EdifBusNamingPolicy
Returns the integer value of the "right" bus limit within the bus string name (i.e. will return a "8" for the following naming example "(4:8)"). Will return a non-negative value if the string is valid. Otherwise, it returns -1.

Specified by:
getRightBusLimit in interface EdifBusNamingPolicy

getBusBaseName

public java.lang.String getBusBaseName(java.lang.String name)
Description copied from interface: EdifBusNamingPolicy
Return the basename of the bus name without all of the bus range information. This method will should return a null if the name does not match the bus naming policy.

Specified by:
getBusBaseName in interface EdifBusNamingPolicy

main

public static void main(java.lang.String[] args)