zyh.robot
Class ContentManager

java.lang.Object
  |
  +--zyh.robot.ContentManager

public class ContentManager
extends java.lang.Object

The basic service for managing a set of content filters and processors. zyh.robot.ContentManager is with responsibility for registering manifold content filters and content processors. The purpose of content filter is to parse raw data in some formats, such as text, HTML, PostScript or RTF, and stores filtered information and extracted URLs in zyh.robot.Content, a data structure, which holds title, keywords, summary, text and extracted URLs. Content processor decides on the index policy and does actual index process on the Content object, which is constructed by content filter.

When the method getContent is called, the ContentManager will attempt to locate a suitable content filter from those content filters registered explicitly by the method registerContentFilter.

When the method getWordIDs is called, the ContentManager will attempt to locate a suitable content processor from those content processors registered explicitly by the method registerContentProcessors.

See Also:
Content, ContentFilter, ContentProcessor

Constructor Summary
ContentManager()
           
 
Method Summary
static Content getContent(java.net.URLConnection urlConnection)
          Attempts to get a content from a given input stream.
static java.io.PrintWriter getLogWriter()
          Gets the log writer.
static int[] getWordIDs(java.lang.Object obj, Content content)
          Sort and Index a content object.
static void println(java.lang.String message)
          Prints a message to the current ContentFilter log stream.
static void registerContentFilter(ContentFilter contentFilter)
           
static void registerContentFilter(java.lang.String acceptedContenttype, ContentFilter contentFilter)
          Registers the content filter with the ContentManager.
static void registerContentProcessor(Robot robot, ContentProcessor contentProcessor)
           
static void setLogWriter(java.io.PrintWriter out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentManager

public ContentManager()
Method Detail

setLogWriter

public static void setLogWriter(java.io.PrintWriter out)

getLogWriter

public static java.io.PrintWriter getLogWriter()
Gets the log writer.

println

public static void println(java.lang.String message)
Prints a message to the current ContentFilter log stream.
Parameters:
message - a log or tracing message

registerContentFilter

public static void registerContentFilter(ContentFilter contentFilter)

registerContentFilter

public static void registerContentFilter(java.lang.String acceptedContenttype,
                                         ContentFilter contentFilter)
Registers the content filter with the ContentManager.
Parameters:
acceptedContenttype - the accepted content type
contentFilter - the new content filter that is to be registered with the ContentManager

getContent

public static Content getContent(java.net.URLConnection urlConnection)
                          throws java.io.IOException
Attempts to get a content from a given input stream. The ContentManager attempts to select an appropriate content filter from the set of registered content filter.
Parameters:
InputStream - an input stream
Returns:
a Content from the input stream
Throws:
java.io.IOException - if an input stream access error occurs

registerContentProcessor

public static void registerContentProcessor(Robot robot,
                                            ContentProcessor contentProcessor)

getWordIDs

public static int[] getWordIDs(java.lang.Object obj,
                               Content content)
                        throws java.sql.SQLException
Sort and Index a content object.
Parameters:
obj - an robot object
content - an Content object
Returns:
a wordID array of all keywords from the content
Throws:
java.sql.SQLException - if an index database access error occurs