|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.foxsmart.csu.config.CiscoRouterConfigParser
public class CiscoRouterConfigParser
The CiscoRouterConfigParser class contains many methods to aid in the parsing and generation of IOS strings.
| Field Summary | |
|---|---|
protected org.apache.commons.logging.Log |
log
|
static java.lang.String |
NO
|
protected int |
tokenIndex
|
| Constructor Summary | |
|---|---|
CiscoRouterConfigParser()
Constructs the parser. |
|
| Method Summary | |
|---|---|
protected void |
checkExists(java.lang.Object object,
java.lang.String description)
Checks to see if a variable is not null. |
protected void |
checkLineComplete(java.lang.String line,
java.util.List tokens)
Checks that there are no more tokens on the current line. |
protected void |
checkNotEmpty(java.lang.String value,
java.lang.String description)
Checks to see if a variable is not empty. |
protected void |
checkRange(java.lang.Number value,
java.lang.Number minRange,
java.lang.Number maxRange,
boolean required,
java.lang.String description)
Checks that a value is possibly not null and between a specified range. |
protected void |
checkTokenCount(java.lang.String line,
java.util.List tokens,
java.lang.Integer count)
Ensures that the passed in list of tokens contains the count specified. |
protected void |
checkTokenCount(java.lang.String line,
java.util.List tokens,
java.lang.Integer lowRange,
java.lang.Integer highRange)
Ensures that the passed in list of tokens contains the correct count. |
protected void |
checkTokenMatch(java.lang.String line,
java.util.List tokens,
int count,
java.lang.String match)
Checks that the token number in the array of tokens matches the passed in string. |
protected void |
checkTokenMatch(java.lang.String line,
java.lang.String token,
java.lang.String match)
Checks that a token matches the passed in match string. |
protected void |
decrementTokenIndex()
Decrements the current token index. |
protected Commands |
generateCommands(java.lang.String ios)
Generates a Commands object from a multi-line string. |
protected java.math.BigDecimal |
getBigDecimalNumberFromString(java.lang.String line,
java.lang.String token)
Checks that a token is a BigDecimal number and returns it. |
protected java.lang.Double |
getDoubleNumberFromString(java.lang.String line,
java.lang.String token)
Checks that a token is a double number and returns it. |
protected Enum |
getEnum(java.lang.Class enumClass,
java.lang.String enumStringValue,
java.lang.String line)
Instantiates an enum of the specified type with the value specified. |
protected Hexadecimal |
getHexadecimalNumberFromString(java.lang.String line,
java.lang.String token)
Checks that a token is a hexadecimal number and returns it. |
protected java.lang.Integer |
getIntegerNumberFromString(java.lang.String line,
java.lang.String token)
Checks that a token is an integer and returns it. |
protected IpAddress |
getIpAddressFromString(java.lang.String line,
java.lang.String token)
Checks that a token is an IP Address and returns it. |
protected java.lang.String |
getLine(java.util.List lines,
int count)
Gets a specified line, that is to say, an element, from the passed in List. |
protected java.lang.Long |
getLongNumberFromString(java.lang.String line,
java.lang.String token)
Checks that a token is a long number and returns it. |
protected MacAddress |
getMacAddressFromString(java.lang.String line,
java.lang.String token)
Checks that a token is a 48-bit mac address and returns it. |
protected java.lang.String |
getNextOptionalToken(java.lang.String line,
java.util.List tokens)
Returns the next token in the list of tokens if one exists. |
protected java.lang.String |
getNextToken(java.lang.String line,
java.util.List tokens)
Returns the next token in the list of tokens. |
protected java.lang.String |
getToken(java.util.List tokens,
int count)
Returns the string token at the specified position. |
protected int |
getTokenIndex()
Gets the current token index. |
protected java.util.List |
getTokens(java.lang.String line)
Gets a list of tokens from the specified line. |
protected int |
getTotalIndentedLines(java.util.List lines)
Deprecated. Use the getTotalLines(List configLines) method instead. |
protected int |
getTotalLines(java.util.List configLines)
Gets the total number of lines that are a part of this configuration component. |
protected void |
incrementTokenIndex()
Increments the current token index. |
protected void |
invalidConfiguration(java.lang.String errorMessage,
java.lang.String line)
Throws an InvalidConfigurationException with a specified error message. |
protected void |
invalidTokenFound(java.lang.String line,
java.lang.String token)
Throws an InvalidConfigurationException because an invalid token was found. |
protected boolean |
isEmpty(java.lang.String string)
Determines if the passed in string is empty. |
protected boolean |
moreIndentedLines(java.util.List lines,
int originalIndentPos)
Determines if the next line in the list of lines is indented beyond the originally indented position for a component. |
protected boolean |
moreLines(java.util.List lines,
int index)
Determines if there are more lines to read. |
protected boolean |
moreTokens(java.util.List tokens)
Determines if there are more tokens to read. |
protected java.util.List |
removeLines(java.util.List lines,
int count)
Removes a specified number of lines (List elements) from the beginning of the passed in lines list. |
protected void |
resetTokenIndex()
Resets the current token index. |
protected void |
setTokenIndex(int index)
Sets the current token index. |
protected int |
tokensLeft(java.util.List tokens)
Returns the number of tokens left to read. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.apache.commons.logging.Log log
protected int tokenIndex
public static final java.lang.String NO
| Constructor Detail |
|---|
public CiscoRouterConfigParser()
| Method Detail |
|---|
protected void checkTokenCount(java.lang.String line,
java.util.List tokens,
java.lang.Integer lowRange,
java.lang.Integer highRange)
throws InvalidConfigurationException
line - The IOS configuration linetokens - The list of tokens to checklowRange - The low range for the token count. If null, no low range check will be performed.highRange - The high range for the token count. If null, no high range check will be performed.
InvalidConfigurationException - if the number of token doesn't match what is expected.
protected void checkLineComplete(java.lang.String line,
java.util.List tokens)
throws InvalidConfigurationException
line - The IOS configuration linetokens - The list of tokens to check
InvalidConfigurationException - if there are still additional token on the line.
protected void checkTokenCount(java.lang.String line,
java.util.List tokens,
java.lang.Integer count)
throws InvalidConfigurationException
line - The IOS configuration linetokens - The list of tokens to checkcount - The number of tokens expected.
InvalidConfigurationException - if the number of token doesn't match what is expected.
protected void checkTokenMatch(java.lang.String line,
java.util.List tokens,
int count,
java.lang.String match)
throws InvalidConfigurationException
line - The IOS configuration linetokens - The list of tokens to checkcount - The token number to check for a match. The token number should start at position 0.match - The match string
InvalidConfigurationException - if the token at the specified position doesn't match the passed in match
string.
protected void checkTokenMatch(java.lang.String line,
java.lang.String token,
java.lang.String match)
throws InvalidConfigurationException
line - The IOS configuration linetoken - The token to matchmatch - The match string
InvalidConfigurationException - if the token doesn't match the passed in match string.
protected void checkExists(java.lang.Object object,
java.lang.String description)
throws InvalidConfigurationException
object - The object to checkdescription - A description of the value (e.g. "width").
InvalidConfigurationException - If the object is null.
protected void checkNotEmpty(java.lang.String value,
java.lang.String description)
throws InvalidConfigurationException
value - The value to checkdescription - A description of the value (e.g. "width").
InvalidConfigurationException - If the value is empty.
protected void checkRange(java.lang.Number value,
java.lang.Number minRange,
java.lang.Number maxRange,
boolean required,
java.lang.String description)
throws InvalidConfigurationException
value - The value to checkminRange - The lower bound of the range checkmaxRange - The upper bound of the range checkrequired - Whether the value is required or notdescription - A description of the value (e.g. "width").
InvalidConfigurationException - If the value was not specified when required or falls outside the range.
protected void invalidTokenFound(java.lang.String line,
java.lang.String token)
throws InvalidConfigurationException
line - The line the token was found ontoken - The invalid token
InvalidConfigurationException - always.
protected void invalidConfiguration(java.lang.String errorMessage,
java.lang.String line)
throws InvalidConfigurationException
errorMessage - The error message.line - The IOS line that contained the error.
InvalidConfigurationException - always.
protected java.lang.Integer getIntegerNumberFromString(java.lang.String line,
java.lang.String token)
throws InvalidConfigurationException
line - The IOS configuration linetoken - The token to check
InvalidConfigurationException - if the token isn't a valid number.
protected java.lang.Long getLongNumberFromString(java.lang.String line,
java.lang.String token)
throws InvalidConfigurationException
line - The IOS configuration linetoken - The token to check
InvalidConfigurationException - if the token isn't a valid number.
protected java.lang.Double getDoubleNumberFromString(java.lang.String line,
java.lang.String token)
throws InvalidConfigurationException
line - The IOS configuration linetoken - The token to check
InvalidConfigurationException - if the token isn't a valid number.
protected java.math.BigDecimal getBigDecimalNumberFromString(java.lang.String line,
java.lang.String token)
throws InvalidConfigurationException
line - The IOS configuration linetoken - The token to check
InvalidConfigurationException - if the token isn't a valid number.
protected Hexadecimal getHexadecimalNumberFromString(java.lang.String line,
java.lang.String token)
throws InvalidConfigurationException
line - The IOS configuration linetoken - The token to check
InvalidConfigurationException - if the token isn't a valid hexadecimal number.
protected MacAddress getMacAddressFromString(java.lang.String line,
java.lang.String token)
throws InvalidConfigurationException
line - The IOS configuration linetoken - The token to check
InvalidConfigurationException - if the token isn't a valid 48-bit mac address.
protected IpAddress getIpAddressFromString(java.lang.String line,
java.lang.String token)
throws InvalidConfigurationException
line - The IOS configuration linetoken - The token to check
InvalidConfigurationException - if the token isn't a valid number.
protected java.lang.String getToken(java.util.List tokens,
int count)
tokens - The list of tokenscount - The token number to get.
protected java.lang.String getNextToken(java.lang.String line,
java.util.List tokens)
throws InvalidConfigurationException
line - The IOS configuration linetokens - The list of tokens
InvalidConfigurationException - if there are no more tokens available.
protected java.lang.String getNextOptionalToken(java.lang.String line,
java.util.List tokens)
line - The IOS configuration linetokens - The list of tokens
protected int getTokenIndex()
protected void setTokenIndex(int index)
index - The new token index. This value will be the next index used by getNextToken().protected void incrementTokenIndex()
protected void decrementTokenIndex()
protected void resetTokenIndex()
protected boolean moreTokens(java.util.List tokens)
tokens - The list of tokens
protected int tokensLeft(java.util.List tokens)
tokens - The list of tokens
protected boolean moreLines(java.util.List lines,
int index)
lines - The list of linesindex - The current line index
protected java.lang.String getLine(java.util.List lines,
int count)
lines - The list of linescount - The line in the list to retrieve.
protected int getTotalIndentedLines(java.util.List lines)
line aux 0 refuse-message ^CLine 1 Line2^C <-- Should be part of indented line, but isn't. modem answer-timeout 65535
lines - The list of lines
protected boolean moreIndentedLines(java.util.List lines,
int originalIndentPos)
lines - The list of linesoriginalIndentPos - The original indent offset of the first line for the component.
protected java.util.List getTokens(java.lang.String line)
line - The line of text used to retrieve the tokens
protected int getTotalLines(java.util.List configLines)
configLines - The total possible lines
protected java.util.List removeLines(java.util.List lines,
int count)
lines - The list of linescount - The number of lines to remove.
protected boolean isEmpty(java.lang.String string)
string - the string to check.
protected Commands generateCommands(java.lang.String ios)
ios - The list of commands in a string form.
protected Enum getEnum(java.lang.Class enumClass,
java.lang.String enumStringValue,
java.lang.String line)
throws InvalidConfigurationException
enumClass - The class of the enum.enumStringValue - The enum value.line - The configuration line that is being processed.
InvalidConfigurationException - if the enum couldn't be created properly.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||