KickJava   Java API By Example, From Geeks To Geeks.

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


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.CopletInstanceData;
19 import org.apache.cocoon.portal.layout.impl.CopletLayout;
20
21 /**
22  * Field handler for external CopletInstanceData references.
23  *
24  * @author <a HREF="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
25  *
26  * @version CVS $Id: CopletInstanceDataReferenceFieldHandler.java 148910 2005-01-28 18:19:44Z cziegeler $
27  */

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