org.jnetpcap.util
Class ExpandableString

java.lang.Object
  extended by org.jnetpcap.util.JStringBuilder
      extended by org.jnetpcap.util.ExpandableString
All Implemented Interfaces:
java.lang.Appendable
Direct Known Subclasses:
ConfigString

public class ExpandableString
extends JStringBuilder

A special string that allows easy expandibility within it. The ExpandableString is made up of 2 parts. A template string and a work buffer. Whenever a reset() call is made, the buffer is replaced with the contents of the template. The various replace calls, change the buffer by replacing certain parts, recursively. Subclasses perform specific expand operations, that are suited for their needs. Substitutions between single quotes are omitted and returned untouched. Everything else that is not single quoted, can be expanded. Escape character, the back-slash, is treated with a lot of respect.

For example ConfigString subclass replaces variables and properties (marked with $ and @ signs respectively) with contents from various maps and properties.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Field Summary
protected  int count
           
protected  int end
           
protected  int start
           
 
Constructor Summary
ExpandableString(java.lang.String template)
           
 
Method Summary
 java.lang.String getTemplate()
           
 boolean remove(java.lang.String seq)
           
 boolean replaceSequence(java.lang.String open, java.lang.String close, java.lang.String with)
           
 ExpandableString reset()
           
protected  boolean restoreQuotes()
           
protected  boolean saveQuotes()
           
protected  boolean scanNext(java.lang.String open, java.lang.String close)
           
protected  boolean scanNext(java.lang.String open, java.lang.String close, int offset)
           
 void setTemplate(java.lang.String template)
           
 java.lang.String template()
           
 java.lang.String toString()
           
 
Methods inherited from class org.jnetpcap.util.JStringBuilder
append, append, append, append, append, append, append, append, append, append, append, append, append, appendCodePoint, capacity, charAt, codePointAt, codePointBefore, codePointCount, delete, deleteCharAt, ensureCapacity, equals, getChars, hashCode, indexOf, indexOf, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, lastIndexOf, lastIndexOf, length, offsetByCodePoints, replace, reverse, setCharAt, setLength, subSequence, substring, substring, trimToSize
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

count

protected int count

end

protected int end

start

protected int start
Constructor Detail

ExpandableString

public ExpandableString(java.lang.String template)
Method Detail

getTemplate

public final java.lang.String getTemplate()
Returns:
the template

remove

public boolean remove(java.lang.String seq)

replaceSequence

public boolean replaceSequence(java.lang.String open,
                               java.lang.String close,
                               java.lang.String with)

reset

public ExpandableString reset()

restoreQuotes

protected boolean restoreQuotes()

saveQuotes

protected boolean saveQuotes()

scanNext

protected boolean scanNext(java.lang.String open,
                           java.lang.String close)

scanNext

protected boolean scanNext(java.lang.String open,
                           java.lang.String close,
                           int offset)

setTemplate

public final void setTemplate(java.lang.String template)
Parameters:
template - the template to set

template

public java.lang.String template()
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class JStringBuilder
See Also:
StringBuilder.toString()