org.lastbamboo.common.sdp.fields
Class SDPObject

java.lang.Object
  extended by org.lastbamboo.common.sdp.GenericObject
      extended by org.lastbamboo.common.sdp.fields.SDPObject
All Implemented Interfaces:
Serializable, Cloneable, SDPFieldNames
Direct Known Subclasses:
ConnectionAddress, Email, EmailAddress, SDPField, SDPFormat, TypedTime, ZoneAdjustment

public abstract class SDPObject
extends GenericObject
implements SDPFieldNames

Root class for everything in this package.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.lastbamboo.common.sdp.GenericObject
AND, AT, COLON, COMMA, DOT, DOUBLE_QUOTE, EQUALS, GREATER_THAN, HT, immutableClasses, immutableClassNames, indentation, LESS_THAN, LPAREN, matchExpression, NEWLINE, PERCENT, POUND, QUESTION, QUOTE, RETURN, RPAREN, SEMICOLON, SLASH, SP, STAR, stringRepresentation
 
Fields inherited from interface org.lastbamboo.common.sdp.fields.SDPFieldNames
ATTRIBUTE_FIELD, BANDWIDTH_FIELD, CONNECTION_FIELD, EMAIL_FIELD, INFORMATION_FIELD, KEY_FIELD, MEDIA_FIELD, ORIGIN_FIELD, PHONE_FIELD, PROTO_VERSION_FIELD, REPEAT_FIELD, SESSION_NAME_FIELD, TIME_FIELD, URI_FIELD, ZONE_FIELD
 
Constructor Summary
SDPObject()
           
 
Method Summary
 String dbgPrint(int indent)
          Formatter with a given starting indentation.
 String debugDump()
          Generic introspection based printing funciton for this package.
abstract  String encode()
          Get the string encoded version of this object
 boolean equals(Object that)
          An introspection based equality predicate for SDPObjects.
protected  String getStringRepresentation()
           
protected  void initSprint()
           
 boolean match(Object other)
          An introspection based predicate matching using a template object.
 void merge(Object mergeObject)
          Recursively override the fields of this object with the fields of a new object.
 void replace(Match regexp, GenericObject replacement)
          Do a find and replace of objects based on regular expression matching of fields.
 void replace(Match regexp, GenericObjectList replacement)
          Do a recursive find and replace of objects pointed to by this object based on regular expression pattern matching.
 void replace(String objectText, GenericObject replacement, boolean matchSubstring)
          Do a find and replace of objects
 void replace(String objectText, GenericObjectList replacement, boolean matchSubstring)
          Do a find and replace of objects.
protected  void sprint(String s)
          Add a new string to the accumulated string representation.
 String toString()
           
 
Methods inherited from class org.lastbamboo.common.sdp.GenericObject
Assert, clone, dbgPrint, dbgPrint, debugDump, getIndentation, getMatcher, isMySubclass, makeClone, setMatcher, sprint, sprint, sprint, sprint, sprint, sprint, sprint, sprint
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SDPObject

public SDPObject()
Method Detail

encode

public abstract String encode()
Description copied from class: GenericObject
Get the string encoded version of this object

Specified by:
encode in class GenericObject

sprint

protected void sprint(String s)
Description copied from class: GenericObject
Add a new string to the accumulated string representation.

Overrides:
sprint in class GenericObject

initSprint

protected void initSprint()

toString

public String toString()
Overrides:
toString in class Object

getStringRepresentation

protected String getStringRepresentation()

equals

public boolean equals(Object that)
An introspection based equality predicate for SDPObjects.

Overrides:
equals in class GenericObject
Parameters:
other - is the other object to test against.
Returns:
true if the objects are equal.

debugDump

public String debugDump()
Generic introspection based printing funciton for this package. Because we use introspection, this must reside in this package and we cannot use the superclass defintion (even though it is virtually identical.

Overrides:
debugDump in class GenericObject

match

public boolean match(Object other)
An introspection based predicate matching using a template object. Allows for partial match of two protocl Objects.

Overrides:
match in class GenericObject
Parameters:
other - the match pattern to test against. The match object has to be of the same type (class). Primitive types and non-sip fields that are non null are matched for equality. Null in any field matches anything. Some book-keeping fields are ignored when making the comparison.

merge

public void merge(Object mergeObject)
Recursively override the fields of this object with the fields of a new object. This is useful when you want to genrate a template and override the fields of an incoming SIPMessage with another SIP message that you have already generated.

Overrides:
merge in class GenericObject
Parameters:
mergeObject - is the replacement object. The override obect must be of the same class as this object. Set any fields that you do not want to override as null in the mergeOject object.

dbgPrint

public String dbgPrint(int indent)
Formatter with a given starting indentation.


replace

public void replace(String objectText,
                    GenericObject replacement,
                    boolean matchSubstring)
             throws IllegalArgumentException
Do a find and replace of objects

Overrides:
replace in class GenericObject
Parameters:
objectText - is the canonical string representation of the object that we want to replace.
replacement - is the object that we want to replace it with.
matchSubstring - a boolean which tells if we should match a substring of the target object A replacement will occur if a portion of the structure is found with the same encoded text as objectText and with the same class as replacement.
Throws:
IllegalArgumentException
Since:
v1.0

replace

public void replace(String objectText,
                    GenericObjectList replacement,
                    boolean matchSubstring)
             throws IllegalArgumentException
Do a find and replace of objects.

Overrides:
replace in class GenericObject
Parameters:
objectText - Canonical string representation of the portion we want to replace.
replacement - object we want to replace this portion with. A replacement will occur if a portion of the structure is found with the matching encoded text as objectText and with the same class as the replacement.
matchSubstring - is true if we want to match the encoded text of a candidate object as a substring of the encoded target text. ( match occurs is objectText is a substring of the encoded text of an object with the same class as replacement.)
Throws:
IllegalArgumentException
Since:
v1.0

replace

public void replace(Match regexp,
                    GenericObjectList replacement)
             throws IllegalArgumentException
Do a recursive find and replace of objects pointed to by this object based on regular expression pattern matching.

Overrides:
replace in class GenericObject
Parameters:
regexp - regular expression for the object we want to find. This is generated using a regular expression matching package such as the apache regexp package.
replacement - object we want to replace this portion with. A replacement will occur if a portion of the structure is found with a match of the encoded text with objectText and with the same class as replacement.
Throws:
IllegalArgumentException
Since:
v1.0

replace

public void replace(Match regexp,
                    GenericObject replacement)
             throws IllegalArgumentException
Do a find and replace of objects based on regular expression matching of fields.

Overrides:
replace in class GenericObject
Parameters:
regexp - is the match expression (i.e. implementation of the Match interface) for the object that we want to replace.
replacement - is the object that we want to replace it with. A replacement will occur if a portion of the structure is found that matches according to the given regexp and if the class of the replaced field matches the replacement.
Throws:
IllegalArgumentException


Copyright © 2013 LittleShoot. All Rights Reserved.