com.waveset.object
Class ObjectSummary

java.lang.Object
  extended bycom.waveset.object.ObjectSummary

public class ObjectSummary
extends java.lang.Object

A helper class that provides a set of static methods to assemble and parse object "summary" strings. A summary is a collection of one or more name/value pairs, that may be returned by certain repository queries instead of the entire object. This speeds up things like tree views and select lists, since you often only need the name and a few interesting attributes of the object. This saves XML parsing time, DOM tree construction time, PersistentObject construction time, and garbage collection time.

Summaries resemble XML attributes, they basically look like this:

   name1="value" name2="value" ...
 
Double quotes are used to make these look more natural once they're in SQL databases which normally escape single quotes.

If an attribute has multiple values, the contents of the 'value' string may contain list of substrings separated by a vertical bar.

    cars="porche|lexus|yugo"
 
If the vertical bar or double quote must appear as data in a value, it must be preceeded by a backslash.
   expression="x \|\| y"
 


Field Summary
static java.lang.String code_id
           
 
Constructor Summary
ObjectSummary()
           
 
Method Summary
static java.lang.String findSummaryText(java.lang.String xml)
          Locate the summary string within an the XML for a persistent object.
static void main(java.lang.String[] args)
           
static RepositoryResult makeFakeUsers(int howMany, java.lang.String summary)
           
static void pack(java.lang.StringBuffer sb, WSAttributes atts)
           
static void pack(java.lang.StringBuffer sb, WSAttributes atts, boolean comment)
          pack all of the passed in attributes following the rules for multiple values and charactor escaping described above.
static void packAttr(java.lang.StringBuffer sb, java.lang.String name, java.lang.Object val)
          place a name="value" pair in the buffer, with a space before the name.
static void packAttr(java.lang.StringBuffer sb, WSAttribute attr)
          place a name="value" pair in the buffer, with a space before the name.
static java.lang.String packMessage(Message m)
           
static void packValue(java.lang.StringBuffer sb, java.lang.String value)
          Append the string to the buffer, escaping | and " chars with a \.
static void println(java.lang.String msg)
           
static WSAttributes unpack(java.lang.String summary)
          Given a string buffer containing an object summary, unpack it into an WSAttributes object.
static Message unpackMessage(java.lang.String packedMessage)
           
static WSAttributes unpackSummaryFromObject(java.lang.String xml)
          This does a quick scan of the XML for an object, looking for a "summary" string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values
Constructor Detail

ObjectSummary

public ObjectSummary()
Method Detail

unpack

public static WSAttributes unpack(java.lang.String summary)
Given a string buffer containing an object summary, unpack it into an WSAttributes object.


unpackSummaryFromObject

public static WSAttributes unpackSummaryFromObject(java.lang.String xml)
This does a quick scan of the XML for an object, looking for a "summary" string. Once extracted the summary string is then converted into a WSAttributes object.

This can be used for applications that want some quick information about an object, without the overhead of a full XML parse and PersistentObject construction.

This was built to allow the summary text to appear in the XML serialization of the object. We're actually now storing this as a "queryable" attribute, so this code is dormant.


packMessage

public static java.lang.String packMessage(Message m)

unpackMessage

public static Message unpackMessage(java.lang.String packedMessage)

findSummaryText

public static java.lang.String findSummaryText(java.lang.String xml)
Locate the summary string within an the XML for a persistent object. Summary strings if present are always stored in an XML comment immediatly following the DOCTYPE statement if present. If there is no DOCTYPE or XML header, it will be the first comment in the string.

This was built to allow the summary text to appear in the XML serialization of the object. We're actually now storing this as a "queryable" attribute, so this code is dormant.


packValue

public static void packValue(java.lang.StringBuffer sb,
                             java.lang.String value)
Append the string to the buffer, escaping | and " chars with a \. "bob|mary" becomes bob\|mary UPDATE: escape '-' chars, in case there is a '--' in the value which will are not allowed in XML comments.


packAttr

public static void packAttr(java.lang.StringBuffer sb,
                            WSAttribute attr)
place a name="value" pair in the buffer, with a space before the name.


packAttr

public static void packAttr(java.lang.StringBuffer sb,
                            java.lang.String name,
                            java.lang.Object val)
place a name="value" pair in the buffer, with a space before the name.


pack

public static void pack(java.lang.StringBuffer sb,
                        WSAttributes atts,
                        boolean comment)
pack all of the passed in attributes following the rules for multiple values and charactor escaping described above.

You will end up with a buffer that looks like:


pack

public static void pack(java.lang.StringBuffer sb,
                        WSAttributes atts)

main

public static void main(java.lang.String[] args)

makeFakeUsers

public static RepositoryResult makeFakeUsers(int howMany,
                                             java.lang.String summary)

println

public static void println(java.lang.String msg)