KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > services > search > handlers > RegistryEntryToDocHandler


1 /*
2  * Copyright 2000-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.jetspeed.services.search.handlers;
17
18 import org.apache.jetspeed.om.registry.RegistryEntry;
19 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
20 import org.apache.jetspeed.services.logging.JetspeedLogger;
21 import org.apache.jetspeed.services.search.BaseParsedObject;
22 import org.apache.jetspeed.services.search.AbstractObjectHandler;
23 import org.apache.jetspeed.services.search.ParsedObject;
24
25
26 /**
27  * This object handler deals with registry entries
28  *
29  * @author <a HREF="mailto:jford@apache.org">Jeremy Ford</a>
30  * @version $Id: RegistryEntryToDocHandler.java,v 1.4 2004/02/23 03:47:46 jford Exp $
31  */

32 public class RegistryEntryToDocHandler extends AbstractObjectHandler
33 {
34     /**
35      * Static initialization of the logger for this class
36      */

37     private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(RegistryEntryToDocHandler.class.getName());
38     
39     /**
40      * @see org.apache.jetspeed.services.search.ObjectHandler#parseObject(java.lang.Object)
41      * @param o
42      * @return
43      */

44     public ParsedObject parseObject(Object JavaDoc o)
45     {
46         ParsedObject result = new BaseParsedObject();
47
48         if ((o instanceof RegistryEntry) == false)
49         {
50             logger.error("RegistryEntryToDocHandler: invalid object type: " + o);
51             return null;
52         }
53
54         RegistryEntry regEntry = (RegistryEntry) o;
55         String JavaDoc desc = regEntry.getDescription();
56         result.setDescription(desc == null ? regEntry.getName() : desc);
57         result.setKey(regEntry.getName());
58         String JavaDoc title = regEntry.getTitle();
59         result.setTitle(title == null ? regEntry.getName() : title);
60         
61         result.setClassName(o.getClass().getName());
62         
63         return result;
64     }
65 }
66
Popular Tags