edu.byu.ece.edif.core
Class BasicEdifBusNetNamingPolicy

java.lang.Object
  extended by edu.byu.ece.edif.core.BasicEdifBusNetNamingPolicy
All Implemented Interfaces:
EdifBusNetNamingPolicy

public class BasicEdifBusNetNamingPolicy
extends java.lang.Object
implements EdifBusNetNamingPolicy

Basic implementation of the EdifBusNetNamingPolicy 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
private  java.util.regex.Pattern _p
          Local copy of the Pattern.
static java.lang.String BASENAME_GROUP
           
static java.lang.String BRACKET_BUS_NET
          This regular expression will match against a net name that ends with [n:n] where n and n is a decimal number.
static java.lang.String LEFT_BRACKET
           
static java.lang.String LEFT_PAREN
           
static java.lang.String LESS_BITPOS_GREATER_REGEX
          This regular expression will match against a net name that end in "<<#>>" where <#> is a decimal number.
static java.lang.String LESS_GREATER_BUS_NET
          This regular expression will match against a net name that ends with where n is a decimal number.
static java.lang.String PARAN_BITPOS_PARAN_REGEX
          This regular expression will match against a net name that ends in "(<#>)" where <#> is a decimal number.
static java.lang.String PARANTHESIS_BUS_NET
          This regular expression will match against a net name that ends with (n:n) where n and n is a decimal number.
static java.lang.String RIGHT_BRACKET
           
static java.lang.String RIGHT_PAREN
           
static java.lang.String UNDERSCORE_BITPOS_REGEX
          This regular expression will match against a net name that ends in "_<#>" where <#> is a decimal number.
static java.lang.String UNDERSCORE_BITPOS_UNDERSCORE_REGEX
          This regular expression will match against a net name that ends in "_<#>_" where <#> is a decimal number.
static java.lang.String UNSIGNED_INTEGER_GROUP
           
 
Constructor Summary
BasicEdifBusNetNamingPolicy()
          The default constructor will create a naming policy based on the UNDERSCORE_BITPOS_UNDERSCORE_REGEX.
BasicEdifBusNetNamingPolicy(java.lang.String regex)
          Create a new naming policy based on the given regular expression.
 
Method Summary
static EdifBusNetNamingPolicy EdifBusNetNamingPolicy(java.lang.String str)
          Parse a string and identifies the bus net naming scheme that matches the given string.
 java.lang.String generateBitSuffix(int bitPos)
          Given a bit number, create a bit suffix that matches the naming policy
 java.lang.String getBusBaseName(java.lang.String name)
          Parse the given bus net name to determine its basename according to the policy.
static java.lang.String getBusBaseNameStatic(java.lang.String str)
          Get the base name of a bus net name by first determining which policy it conforms to and then calling the getBusBaseName(String) method on that policy.
 int getBusPosition(java.lang.String name)
          Parse the given bus net name to determine its bit position according to the policy.
private  java.util.regex.Matcher getMatcher(java.lang.String name)
           
 java.lang.String getRegexString()
          Get the regular expression string used to parse bus net names for this policy
 boolean isValidBusNetName(java.lang.String name)
          Determine if the given bus net name is valid according to the 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

LEFT_PAREN

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

RIGHT_PAREN

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

LEFT_BRACKET

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

RIGHT_BRACKET

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

UNSIGNED_INTEGER_GROUP

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

BASENAME_GROUP

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

UNDERSCORE_BITPOS_REGEX

public static final java.lang.String UNDERSCORE_BITPOS_REGEX
This regular expression will match against a net name that ends in "_<#>" where <#> is a decimal number. Example: test_5

See Also:
Constant Field Values

UNDERSCORE_BITPOS_UNDERSCORE_REGEX

public static final java.lang.String UNDERSCORE_BITPOS_UNDERSCORE_REGEX
This regular expression will match against a net name that ends in "_<#>_" where <#> is a decimal number. Example: test_5_

See Also:
Constant Field Values

PARAN_BITPOS_PARAN_REGEX

public static final java.lang.String PARAN_BITPOS_PARAN_REGEX
This regular expression will match against a net name that ends in "(<#>)" where <#> is a decimal number. Note that this is not a valid EDIF name and is used for the "oldname" value. Example: test(5)

See Also:
Constant Field Values

LESS_BITPOS_GREATER_REGEX

public static final java.lang.String LESS_BITPOS_GREATER_REGEX
This regular expression will match against a net name that end in "<<#>>" where <#> is a decimal number. Note that this is not a valid EDIF name and is used for the "oldname" value. Example: test<5>

See Also:
Constant Field Values

LESS_GREATER_BUS_NET

public static final java.lang.String LESS_GREATER_BUS_NET
This regular expression will match against a net name that ends with where n is a decimal number.

See Also:
Constant Field Values

PARANTHESIS_BUS_NET

public static final java.lang.String PARANTHESIS_BUS_NET
This regular expression will match against a net name that ends with (n:n) where n and n is a decimal number.

See Also:
Constant Field Values

BRACKET_BUS_NET

public static final java.lang.String BRACKET_BUS_NET
This regular expression will match against a net name that ends with [n:n] where n and n is a decimal number.

See Also:
Constant Field Values

_p

private java.util.regex.Pattern _p
Local copy of the Pattern.

Constructor Detail

BasicEdifBusNetNamingPolicy

public BasicEdifBusNetNamingPolicy()
The default constructor will create a naming policy based on the UNDERSCORE_BITPOS_UNDERSCORE_REGEX.


BasicEdifBusNetNamingPolicy

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

Method Detail

EdifBusNetNamingPolicy

public static EdifBusNetNamingPolicy EdifBusNetNamingPolicy(java.lang.String str)
Parse a string and identifies the bus net naming scheme that matches the given string. If no bus net naming policy matches the string, this method returns a null.


getBusBaseName

public java.lang.String getBusBaseName(java.lang.String name)
Parse the given bus net name to determine its basename according to the policy.

Specified by:
getBusBaseName in interface EdifBusNetNamingPolicy
Parameters:
name - the bus net name to parse
Returns:
the basename of the given bus net name

getBusBaseNameStatic

public static java.lang.String getBusBaseNameStatic(java.lang.String str)
Get the base name of a bus net name by first determining which policy it conforms to and then calling the getBusBaseName(String) method on that policy.

Parameters:
name - the bus net name to parse
Returns:
the base name of the bus net name

generateBitSuffix

public java.lang.String generateBitSuffix(int bitPos)
Given a bit number, create a bit suffix that matches the naming policy

Specified by:
generateBitSuffix in interface EdifBusNetNamingPolicy
Parameters:
bitPos - bit position

getBusPosition

public int getBusPosition(java.lang.String name)
Parse the given bus net name to determine its bit position according to the policy.

Specified by:
getBusPosition in interface EdifBusNetNamingPolicy
Parameters:
name - the bus net name to parse
Returns:
the bit position of the bus net name

getRegexString

public java.lang.String getRegexString()
Get the regular expression string used to parse bus net names for this policy

Specified by:
getRegexString in interface EdifBusNetNamingPolicy

isValidBusNetName

public boolean isValidBusNetName(java.lang.String name)
Determine if the given bus net name is valid according to the policy.

Specified by:
isValidBusNetName in interface EdifBusNetNamingPolicy
Parameters:
name - the bus net name to parse
Returns:
true iff the given bus net name is valid according to the policy.

main

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

getMatcher

private java.util.regex.Matcher getMatcher(java.lang.String name)
Parameters:
name - the bus net name to parse
Returns:
a Matcher object based on the policy and given bus net name.