com.starbase.starteam
Class SimpleKeyword

java.lang.Object
  |
  +--com.starbase.starteam.SimpleKeyword
All Implemented Interfaces:
Keyword
Direct Known Subclasses:
HistoryKeyword, LogKeyword, NoKeywords

public class SimpleKeyword
extends java.lang.Object
implements Keyword

A Keyword object that encapsulates information about a File keyword. When checking a file is added, checked-in or checked-out of the repository keyword expansion may be applied to the contents of the file. For example, an occurance of $Author$ in a file might be be replaced with $Author: Fred$ upon checkout.

See Also:
KeywordReader

Constructor Summary
SimpleKeyword(java.lang.String name, java.lang.String value)
          Create a new basic keyword object with the specified name and expansion value.
 
Method Summary
 boolean equals(java.lang.Object source)
          returns true if this object instance is equal to the source
 java.lang.String expand(java.lang.String linePrefix, java.lang.String eol, boolean expand)
          Returns the expanded or unexpanded version of this keyword.
 java.lang.String getName()
          Return the keyword name.
 java.lang.String getValue()
          Return the keyword value.
 int hashCode()
          returns a unique hash for all instances of this type
 boolean matches(java.lang.String line, int start, int[] endPos)
          Returns true of this keyword is found in the specified line.
 boolean multiLine()
          Return true if this keyword spans multiple lines.
 boolean stopExpanding()
          Return true if upon encountering this keyword in a file that no further keyword expansion will occur.
 java.lang.String toXMLString()
          Returns an XML representation of the keyword.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleKeyword

public SimpleKeyword(java.lang.String name,
                     java.lang.String value)
Create a new basic keyword object with the specified name and expansion value.

Parameters:
name - the name of the keyword. E.g. "Author"
value - the value to expand to. E.g. "Fred"
Method Detail

getName

public java.lang.String getName()
Return the keyword name.

Specified by:
getName in interface Keyword
Returns:
the keyword name.

getValue

public java.lang.String getValue()
Return the keyword value.

Specified by:
getValue in interface Keyword
Returns:
the keyword value

stopExpanding

public boolean stopExpanding()
Return true if upon encountering this keyword in a file that no further keyword expansion will occur. This is true for the StarTeam keyword $NoKeywords$.

Specified by:
stopExpanding in interface Keyword
Returns:
true if keyword expansion should stop in a file after encountering this keyword.

multiLine

public boolean multiLine()
Return true if this keyword spans multiple lines. This is only true for the StarTeam $Log$ keyword.

Specified by:
multiLine in interface Keyword
Returns:
true if this keyword spans multiple lines.

matches

public boolean matches(java.lang.String line,
                       int start,
                       int[] endPos)
Returns true of this keyword is found in the specified line. If found then the endPos parameter is treated as an output parameter and the value of endPos[0] should be the position in the line where the ending $ occurs.

Specified by:
matches in interface Keyword
Parameters:
line - the line to search for this keyword
start - the position in the line (zero based) to start searching
endPos - and "output" array where the end of the keyword occurs.
Returns:
true if the keyword is found on the specified line

expand

public java.lang.String expand(java.lang.String linePrefix,
                               java.lang.String eol,
                               boolean expand)
Returns the expanded or unexpanded version of this keyword. For example, if the keyword is "Author" then expanding this should return "Author: Fred$". Note that the leading $ is not returned, it is handled elsehwere. Unexpand would return "Author$"

Specified by:
expand in interface Keyword
Parameters:
linePrefix - the begining of the line in the souce leading up to the keyword
eol - the end-of-line convention used in the source file
expand - true if the keyword is to be expanded and false for unexpand
Returns:
the appropriately expanded or unexpanded keyword.

toXMLString

public java.lang.String toXMLString()
Returns an XML representation of the keyword. The default XML representation for a SimpleKeyword is of the form:
 <keyword name="Author" value="Bob"/>
 

Specified by:
toXMLString in interface Keyword
Returns:
an XML representation of the keyword.

equals

public boolean equals(java.lang.Object source)
returns true if this object instance is equal to the source

Overrides:
equals in class java.lang.Object
Parameters:
source - Object the source to comapre with
Returns:
boolean true if this object is equal to the source

hashCode

public int hashCode()
returns a unique hash for all instances of this type

Overrides:
hashCode in class java.lang.Object
Returns:
int a unique hash for all instances of this type


StarTeam SDK 10.4, Build 36
Copyright © 2003-2008 Borland Software Corporation. All rights reserved.