KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > util > CopletBaseDataReferenceFieldHandler


1 /*
2  * Copyright 1999-2002,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.cocoon.portal.util;
17
18 import org.apache.cocoon.portal.coplet.CopletBaseData;
19 import org.apache.cocoon.portal.coplet.CopletData;
20
21 /**
22  * Field handler for external CopletBaseData references.
23  *
24  * @author <a HREF="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
25  *
26  * @version CVS $Id: CopletBaseDataReferenceFieldHandler.java 123407 2004-12-27 13:51:59Z cziegeler $
27  */

28 public class CopletBaseDataReferenceFieldHandler
29     extends ReferenceFieldHandler {
30
31     public Object JavaDoc getValue(Object JavaDoc object) {
32         CopletBaseData copletBaseData = ((CopletData) object).getCopletBaseData();
33         if (copletBaseData != null) {
34             return copletBaseData.getId();
35         }
36         return null;
37     }
38
39     public Object JavaDoc newInstance(Object JavaDoc parent) {
40         return new CopletBaseData();
41     }
42
43     public void resetValue(Object JavaDoc object) {
44         ((CopletData) object).setCopletBaseData(null);
45     }
46
47     public void setValue(Object JavaDoc object, Object JavaDoc value) {
48         CopletBaseData copletBaseData = (CopletBaseData) getObjectMap().get(value);
49         if (copletBaseData == null) {
50             throw new ProfileException(
51                 "Referenced Coplet Base Data " + value + " does not exist.");
52         }
53         ((CopletData) object).setCopletBaseData(copletBaseData);
54     }
55 }
56
Popular Tags