edu.byu.ece.edif.core
Class BasicEdifBusNamingPolicy

java.lang.Object
  extended by edu.byu.ece.edif.core.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 expressions define the naming policy.

Author:
Michael J Wirthlin

Field Summary
private  java.util.regex.Pattern _p
           
static java.lang.String BASENAME_GROUP
           
static java.lang.String BRACKET_BUS
          This regular expression will match against a bus name that ends with [n:m] where n and m are decimal numbers.
static java.lang.String LEFT_BRACKET
           
static java.lang.String LEFT_PAREN
           
static java.lang.String LESS_GREATER_BUS
          This regular expression will match against a bus name that ends with where n and m are decimal numbers.
static java.lang.String PARANTHESIS_BUS
          This regular expression will match against a bus name that ends with (n:m) where n and m are decimal numbers.
static java.lang.String RIGHT_BRACKET
           
static java.lang.String RIGHT_PAREN
           
static java.lang.String UNSIGNED_INTEGER_GROUP
           
 
Constructor Summary
BasicEdifBusNamingPolicy(java.lang.String regex)
          Create a new naming policy based on the given regular expression.
 
Method Summary
static EdifBusNamingPolicy EdifBusNamingPolicy(java.lang.String str)
          Parses a string and identifies the bus naming scheme that matches the given string.
 java.lang.String getBusBaseName(java.lang.String name)
          Parse the given bus name to determine its basename according to the policy.
static java.lang.String getBusBaseNameStatic(java.lang.String name)
          Get the base name of a bus name by first determining which policy it conforms to and then calling the getBusBaseName(String) method on that policy.
 java.lang.String getBusRangeSpecifier(java.lang.String name)
          Return the portion of the bus string that specifies the range of the bus.
 int getLeftBusLimit(java.lang.String name)
          Returns the integer value of the "left" bus limit within the bus string name (i.e.
private  java.util.regex.Matcher getMatcher(java.lang.String name)
           
 java.lang.String getRegexString()
          Get the regular expression String from which this policy was created
 int getRightBusLimit(java.lang.String name)
          Returns the integer value of the "right" bus limit within the bus string name (i.e.
 boolean isLittleEndian(java.lang.String name)
          Determine the bit ordering of the given EDIF bus name.
 boolean isValidBusName(java.lang.String name)
          Determine 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

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

LESS_GREATER_BUS

public static final java.lang.String LESS_GREATER_BUS
This regular expression will match against a bus name that ends with where n and m are decimal numbers.

See Also:
Constant Field Values

PARANTHESIS_BUS

public static final java.lang.String PARANTHESIS_BUS
This regular expression will match against a bus name that ends with (n:m) where n and m are decimal numbers.

See Also:
Constant Field Values

BRACKET_BUS

public static final java.lang.String BRACKET_BUS
This regular expression will match against a bus name that ends with [n:m] where n and m are decimal numbers.

See Also:
Constant Field Values

_p

private 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

EdifBusNamingPolicy

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


getBusBaseName

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

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

getBusBaseNameStatic

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

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

getBusRangeSpecifier

public java.lang.String getBusRangeSpecifier(java.lang.String name)
Description copied from interface: EdifBusNamingPolicy
Return the portion of the bus string that specifies the range of the bus. This String does not include the basename.

Specified by:
getBusRangeSpecifier in interface EdifBusNamingPolicy
Returns:
the portion of the bus string that specifies the range of the bus. This String does not include the basename.

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
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.

getRegexString

public java.lang.String getRegexString()
Get the regular expression String from which this policy was created

Specified by:
getRegexString 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
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.

isLittleEndian

public boolean isLittleEndian(java.lang.String name)
Determine the bit ordering of the given EDIF bus name. Little endian implies that the "little" end of the bus (i.e. bit 0) comes first. Big endian implies that the "big" end of the bus comes first (i.e. bit 31). LittleEndian:(31:0) BigEndian: (0:31)

Specified by:
isLittleEndian in interface EdifBusNamingPolicy

isValidBusName

public boolean isValidBusName(java.lang.String name)
Determine whether the given String is a valid Bus name using the implemented bus naming policy.

Specified by:
isValidBusName in interface EdifBusNamingPolicy

main

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

getMatcher

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