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
          The count.
protected  int end
          The end.
protected  int start
          The start.
 
Constructor Summary
ExpandableString(java.lang.String template)
          Instantiates a new expandable string.
 
Method Summary
 java.lang.String getTemplate()
          Gets the template.
 boolean remove(java.lang.String seq)
          Removes the.
 boolean replaceSequence(java.lang.String open, java.lang.String close, java.lang.String with)
          Replace sequence.
 ExpandableString reset()
          Reset.
protected  boolean restoreQuotes()
          Restore quotes.
protected  boolean saveQuotes()
          Save quotes.
protected  boolean scanNext(java.lang.String open, java.lang.String close)
          Scan next.
protected  boolean scanNext(java.lang.String open, java.lang.String close, int offset)
          Scan next.
 void setTemplate(java.lang.String template)
          Sets the template.
 java.lang.String template()
          Template.
 java.lang.String toString()
          To string.
 
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
The count.


end

protected int end
The end.


start

protected int start
The start.

Constructor Detail

ExpandableString

public ExpandableString(java.lang.String template)
Instantiates a new expandable string.

Parameters:
template - the template
Method Detail

getTemplate

public final java.lang.String getTemplate()
Gets the template.

Returns:
the template

remove

public boolean remove(java.lang.String seq)
Removes the.

Parameters:
seq - the seq
Returns:
true, if successful

replaceSequence

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

Parameters:
open - the open
close - the close
with - the with
Returns:
true, if successful

reset

public ExpandableString reset()
Reset.

Returns:
the expandable string

restoreQuotes

protected boolean restoreQuotes()
Restore quotes.

Returns:
true, if successful

saveQuotes

protected boolean saveQuotes()
Save quotes.

Returns:
true, if successful

scanNext

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

Parameters:
open - the open
close - the close
Returns:
true, if successful

scanNext

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

Parameters:
open - the open
close - the close
offset - the offset
Returns:
true, if successful

setTemplate

public final void setTemplate(java.lang.String template)
Sets the template.

Parameters:
template - the template to set

template

public java.lang.String template()
Template.

Returns:
the string

toString

public java.lang.String toString()
To string.

Overrides:
toString in class JStringBuilder
Returns:
the string
See Also:
JStringBuilder.toString()