com.telelogic.cs.api
Class KeywordString

java.lang.Object
  extended by com.telelogic.cs.api.KeywordString

public class KeywordString
extends java.lang.Object

Finds and replaces keywords in a string with given replacement values. Keywords are marked with a % character and are single alpha-numeric "words" which can include underscores, e.g., %keyword1, %another_keyword, %AndAnother. Often used to expand parameterized synopses like "See CR %crid" in triggers.

Since:
4.7 06

Constructor Summary
KeywordString(java.lang.String template)
          Constructs a new KeywordString for the given template.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.String[] getKeywords()
          Returns all the unique keywords in the underlying string.
 int hashCode()
           
 java.lang.String replaceKeywords(java.util.Map<java.lang.String,java.lang.String> replacements)
          Replaces keywords with the given replacements and return the resulting string.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeywordString

public KeywordString(java.lang.String template)
Constructs a new KeywordString for the given template.

Parameters:
template - a string with embedded keywords.
Method Detail

getKeywords

public java.lang.String[] getKeywords()
Returns all the unique keywords in the underlying string. Each keyword is only returned once.

Returns:
each unique keyword without its leading % character. Unspecified order. May be empty if no keywords are found.

replaceKeywords

public java.lang.String replaceKeywords(java.util.Map<java.lang.String,java.lang.String> replacements)
Replaces keywords with the given replacements and return the resulting string. Keywords without replacements are left as-is, with the leading %.

Parameters:
replacements - map of keyword names (no leading %) to their replacement values. Extra replacements (no matching keyword) are ignored.
Returns:
the keyword string with its keywords replaced by the applicable replacement values.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


© Copyright IBM Corporation 2000, 2009
US Government Users Restricted Rights--Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
Notices