© 2002 BEA Systems, Inc.


com.bea.p13n.content
Class ContentHelper

java.lang.Object
  |
  +--com.bea.p13n.content.ContentHelper

public class ContentHelper
extends java.lang.Object

Helper class for dealing with Content, ContentManagers, and the possible subclasses.


Field Summary
static java.lang.String DEF_CONTENT_HOME
          Deprecated. Use DEF_CONTENT_MANAGER_HOME instead.
static java.lang.String DEF_CONTENT_MANAGER_HOME
          The default ContentManagerHome name.
static boolean DEF_CONTENT_READONLY
          Deprecated. No longer needed.
static java.lang.String DEF_CONTENT_SCHEMA_HOME
          Deprecated. Use PropertySetManager and ejb-refs instead.
static java.lang.String DEF_DOCUMENT_HOME
          Deprecated. Use DEF_DOCUMENT_MANAGER_HOME instead.
static java.lang.String DEF_DOCUMENT_MANAGER_HOME
          The default DocumentManagerHome name.
static java.lang.String DEF_DOCUMENT_SCHEMA_HOME
          Deprecated. Use PropertySetManager and ejb-refs instead.
static boolean USE_SOFT_HASH_MAP
          Deprecated. No longer needed.
 
Constructor Summary
ContentHelper()
           
 
Method Summary
static Content[] getContent(java.lang.String homeName, Search s)
          Return an array of Content from the ContentManager at the given name.
static Content[] getContent(java.lang.String homeName, Search s)
          Deprecated. Use new Search instead
static Content[] getContent(java.lang.String homeName, Search s, boolean readOnly)
          Deprecated. Use getContent(String, Search) instead.
static Content[] getContent(java.lang.String homeName, Search s, boolean readOnly)
          Deprecated. Use new content expressions and getContent(String, Search) instead.
static java.util.Enumeration getContentFromManager(java.lang.String homeName, javax.ejb.EJBHome home, Search s)
          Deprecated. use getContentManager(homeName, home).getContent(s) instead.
static java.util.Enumeration getContentFromManager(java.lang.String homeName, javax.ejb.EJBHome home, Search s)
          Deprecated. use new content search and getContentManager(homeName, home).getContent(s) instead.
static java.util.Enumeration getContentFromManager(java.lang.String homeName, javax.ejb.EJBHome home, Search s, boolean readOnly)
          Deprecated. Use getContentManager(homeName, home).getContent(s);
static java.util.Enumeration getContentFromManager(java.lang.String homeName, javax.ejb.EJBHome home, Search s, boolean readOnly)
          Deprecated. Use new content expressions and getContentManager(homeName, home).getContent(s);
static java.util.Collection getContentIds(java.lang.String homeName, Search s)
          Return an rray of Content from the ContentManager or ContentHome at the given name.
static int getContentLength(long docSize, int bytesLen)
          Return the correct content length.
static ContentManager getContentManager(java.lang.String homeName)
          Get a ContentManager from a JNDI home name.
static ContentManager getContentManager(java.lang.String homeName, javax.ejb.EJBHome home)
          Get a ContentManager from an EJBHome.
static java.lang.String pathInfoEncode(java.lang.String pathInfo)
          Correctly URLEncode a path-info string.
static Content[] toArray(java.util.Enumeration e)
          Turn an Enumeration of Content into an array.
static java.lang.String toHTML(java.lang.String in)
          Convert an arbitrary string to HTML which will display as the original string intended.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEF_CONTENT_READONLY

public static final boolean DEF_CONTENT_READONLY
Deprecated. No longer needed.
The default readonly flag for getting Content.

DEF_CONTENT_HOME

public static final java.lang.String DEF_CONTENT_HOME
Deprecated. Use DEF_CONTENT_MANAGER_HOME instead.
The default ContentHome name (always null).

DEF_CONTENT_MANAGER_HOME

public static final java.lang.String DEF_CONTENT_MANAGER_HOME
The default ContentManagerHome name.

This points to "java:comp/env/ejb/ContentManager", which is the closest <ejb-ref>'ed ContentManager home. The <ejb-ref> should be configured either in your EJB ejb-jar.xml deployment descriptor or in your webapp's web.xml deployment descriptor.


DEF_CONTENT_SCHEMA_HOME

public static final java.lang.String DEF_CONTENT_SCHEMA_HOME
Deprecated. Use PropertySetManager and ejb-refs instead.
The default Content SchemaHome name.

DEF_DOCUMENT_HOME

public static final java.lang.String DEF_DOCUMENT_HOME
Deprecated. Use DEF_DOCUMENT_MANAGER_HOME instead.
The default DocumentHome name (always null).

DEF_DOCUMENT_MANAGER_HOME

public static final java.lang.String DEF_DOCUMENT_MANAGER_HOME
The default DocumentManagerHome name.

This points to "java:comp/env/ejb/DocumentManager", which is the closest <ejb-ref>'ed DocumentManager home. The <ejb-ref> should be configured either in your EJB ejb-jar.xml deployment descriptor or in your webapp's web.xml deployment descriptor.


DEF_DOCUMENT_SCHEMA_HOME

public static final java.lang.String DEF_DOCUMENT_SCHEMA_HOME
Deprecated. Use PropertySetManager and ejb-refs instead.
The default Document SchemaHome name.

USE_SOFT_HASH_MAP

public static boolean USE_SOFT_HASH_MAP
Deprecated. No longer needed.
Should caches use a SoftHashMap or not (always false).
Constructor Detail

ContentHelper

public ContentHelper()
Method Detail

getContent

public static Content[] getContent(java.lang.String homeName,
                                   Search s)
                            throws javax.naming.NamingException,
                                   java.rmi.RemoteException,
                                   javax.ejb.FinderException,
                                   java.lang.IllegalArgumentException
Return an array of Content from the ContentManager at the given name.

If homeName points to a home for a ContentManager (or subclass), then the home's create() method will be invoked and the ContentManager's getContent() method will be used. The resulting enumeration will be put into an array.

Throws:
javax.naming.NamingException - thrown if home cannot be found.
java.rmi.RemoteException - thrown on communications error.
javax.ejb.FinderException - thrown on error in findBySearchParams (never thrown)
java.lang.IllegalArgumentException - thrown on any other error.
See Also:
getContentManager(java.lang.String)

getContent

public static Content[] getContent(java.lang.String homeName,
                                   Search s)
                            throws javax.naming.NamingException,
                                   java.rmi.RemoteException,
                                   javax.ejb.FinderException,
                                   java.lang.IllegalArgumentException
Deprecated. Use new Search instead
Return an array of Content from the ContentManager at the given name.

If homeName points to a home for a ContentManager (or subclass), then the home's create() method will be invoked and the ContentManager's getContent() method will be used. The resulting enumeration will be put into an array.

Throws:
javax.naming.NamingException - thrown if home cannot be found.
java.rmi.RemoteException - thrown on communications error.
javax.ejb.FinderException - thrown on error in findBySearchParams (never thrown)
java.lang.IllegalArgumentException - thrown on any other error.
See Also:
getContentManager(java.lang.String), Search

getContentIds

public static java.util.Collection getContentIds(java.lang.String homeName,
                                                 Search s)
                                          throws javax.naming.NamingException,
                                                 java.rmi.RemoteException,
                                                 javax.ejb.FinderException,
                                                 java.lang.IllegalArgumentException
Return an rray of Content from the ContentManager or ContentHome at the given name.

If homeName points to a home for a ContentManager (or subclass), then the home's create() method will be invoked and the ContentManager's getContentIds() method will be used.

Throws:
javax.naming.NamingException - thrown if home cannot be found.
java.rmi.RemoteException - thrown on communications error.
javax.ejb.FinderException - thrown on error in findBySearchParams (never thrown)
java.lang.IllegalArgumentException - thrown on any other error.
See Also:
getContentManager(java.lang.String)

getContentManager

public static ContentManager getContentManager(java.lang.String homeName)
                                        throws javax.naming.NamingException,
                                               javax.ejb.CreateException,
                                               java.rmi.RemoteException,
                                               java.lang.IllegalArgumentException
Get a ContentManager from a JNDI home name.

Parameters:
homeName - the original home name.
Returns:
a ContentManager instance.
Throws:
javax.naming.NamingException - thrown on a lookup error.
javax.ejb.CreateException - thrown on a creation error.
java.rmi.RemoteException - thrown on an error.
java.lang.IllegalArgumentException - thrown on an invalid ejb home.
See Also:
getContentManager(java.lang.String, javax.ejb.EJBHome)

getContentManager

public static ContentManager getContentManager(java.lang.String homeName,
                                               javax.ejb.EJBHome home)
                                        throws javax.ejb.CreateException,
                                               java.rmi.RemoteException,
                                               java.lang.IllegalArgumentException
Get a ContentManager from an EJBHome.

Parameters:
homeName - the original home name.
home - the EJBHome.
Returns:
a ContentManager instance.
Throws:
javax.ejb.CreateException - thrown on a creation error.
java.rmi.RemoteException - thrown on an error.
java.lang.IllegalArgumentException - thrown on an invalid ejb home.

getContent

public static Content[] getContent(java.lang.String homeName,
                                   Search s,
                                   boolean readOnly)
                            throws javax.naming.NamingException,
                                   java.rmi.RemoteException,
                                   javax.ejb.FinderException,
                                   java.lang.IllegalArgumentException
Deprecated. Use getContent(String, Search) instead.
Return an array of Content from the ContentManager or ContentHome at the given name.

If homeName points to a home for a ContentManager (or subclass), then the home's create() method will be invoked and the ContentManager's getContent() method will be used. If homeName points to a home for Content (or subclasses), then it's findBySearchParams() method will used. The resulting enumeration will be put into an array.

Throws:
javax.naming.NamingException - thrown if home cannot be found.
java.rmi.RemoteException - thrown on communications error.
javax.ejb.FinderException - thrown on error in findBySearchParams
java.lang.IllegalArgumentException - thrown on any other error.
See Also:
getContent(java.lang.String, com.bea.p13n.content.expression.Search)

getContent

public static Content[] getContent(java.lang.String homeName,
                                   Search s,
                                   boolean readOnly)
                            throws javax.naming.NamingException,
                                   java.rmi.RemoteException,
                                   javax.ejb.FinderException,
                                   java.lang.IllegalArgumentException
Deprecated. Use new content expressions and getContent(String, Search) instead.
Return an array of Content from the ContentManager or ContentHome at the given name.

If homeName points to a home for a ContentManager (or subclass), then the home's create() method will be invoked and the ContentManager's getContent() method will be used. If homeName points to a home for Content (or subclasses), then it's findBySearchParams() method will used. The resulting enumeration will be put into an array.

Throws:
javax.naming.NamingException - thrown if home cannot be found.
java.rmi.RemoteException - thrown on communications error.
javax.ejb.FinderException - thrown on error in findBySearchParams
java.lang.IllegalArgumentException - thrown on any other error.
See Also:
getContent(java.lang.String, com.bea.p13n.content.expression.Search)

getContentFromManager

public static java.util.Enumeration getContentFromManager(java.lang.String homeName,
                                                          javax.ejb.EJBHome home,
                                                          Search s)
                                                   throws java.rmi.RemoteException,
                                                          java.lang.IllegalArgumentException
Deprecated. use getContentManager(homeName, home).getContent(s) instead.
Search for content from a ContentManager.

Parameters:
homeName - the JNDI home name (used for errors).
home - the EJBHome of the ContentManager.
s - the search parameters.
Returns:
the Enumeration of Content which match the search.
See Also:
getContentManager(java.lang.String, javax.ejb.EJBHome)

getContentFromManager

public static java.util.Enumeration getContentFromManager(java.lang.String homeName,
                                                          javax.ejb.EJBHome home,
                                                          Search s)
                                                   throws java.rmi.RemoteException,
                                                          java.lang.IllegalArgumentException
Deprecated. use new content search and getContentManager(homeName, home).getContent(s) instead.
Search for content from a ContentManager.

Parameters:
homeName - the JNDI home name (used for errors).
home - the EJBHome of the ContentManager.
s - the search parameters.
Returns:
the Enumeration of Content which match the search.
See Also:
getContentManager(java.lang.String, javax.ejb.EJBHome)

getContentFromManager

public static java.util.Enumeration getContentFromManager(java.lang.String homeName,
                                                          javax.ejb.EJBHome home,
                                                          Search s,
                                                          boolean readOnly)
                                                   throws java.rmi.RemoteException,
                                                          java.lang.IllegalArgumentException
Deprecated. Use getContentManager(homeName, home).getContent(s);
Search for content from a ContentManager.

Parameters:
homeName - the JNDI home name (used for errors).
home - the EJBHome of the ContentManager.
s - the search parameters.
readOnly - the read-only flag (ignored).
Returns:
the Enumeration of Content which match the search.
See Also:
getContentManager(java.lang.String, javax.ejb.EJBHome)

getContentFromManager

public static java.util.Enumeration getContentFromManager(java.lang.String homeName,
                                                          javax.ejb.EJBHome home,
                                                          Search s,
                                                          boolean readOnly)
                                                   throws java.rmi.RemoteException,
                                                          java.lang.IllegalArgumentException
Deprecated. Use new content expressions and getContentManager(homeName, home).getContent(s);
Search for content from a ContentManager.

Parameters:
homeName - the JNDI home name (used for errors).
home - the EJBHome of the ContentManager.
s - the search parameters.
readOnly - the read-only flag (ignored).
Returns:
the Enumeration of Content which match the search.
See Also:
getContentManager(java.lang.String, javax.ejb.EJBHome)

toArray

public static Content[] toArray(java.util.Enumeration e)
Turn an Enumeration of Content into an array.

Parameters:
e - the Enumeration.
Returns:
an array of the Content objects.
Throws:
java.lang.ClassCastException - thrown if the objects in the Enumeration aren't Content objects.

getContentLength

public static int getContentLength(long docSize,
                                   int bytesLen)
Return the correct content length. Since the getContent() method of Document does not guarentee that the resulting array will be the correct size (it might be larger), this method will tell what the actual number of bytes to use from that array is.

Parameters:
docSize - the value doc.getSize().
bytesLen - the length of the doc.getContent() array.
Returns:
the number of bytes in the content array which are valid.
See Also:
com.bea.p13n.content.document.document.Document#getContent

pathInfoEncode

public static java.lang.String pathInfoEncode(java.lang.String pathInfo)
Correctly URLEncode a path-info string.

This can be used to pass a contentId as Path-Info to the ShowDocServlet.

This will url encode the pathInfo, but will leave "/"'s alone.


toHTML

public static java.lang.String toHTML(java.lang.String in)
Convert an arbitrary string to HTML which will display as the original string intended.

This will replace the characters '&', '"', '<', and '>' with '&amp;', &quot;', '&lt;', and '&gt;', respectively.


© 2002 BEA Systems, Inc.

Copyright © 2002 BEA Systems, Inc. All Rights Reserved