1   /*
2    * Copyright 2003 - 2013 The eFaps Team
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   * Revision:        $Rev$
17   * Last Changed:    $Date$
18   * Last Changed By: $Author$
19   */
20  
21  package org.efaps.admin.datamodel.ui;
22  
23  import java.io.Serializable;
24  
25  import org.efaps.util.EFapsException;
26  
27  /**
28   * Abstract class for the UIInterface interface implementing for all required
29   * methods a default.
30   *
31   * @author The eFaps Team
32   * @version $Id$
33   */
34  public abstract class AbstractUI
35      implements IUIProvider, UIInterface, Serializable
36  {
37      /**
38       * Needed for serialization.
39       */
40      private static final long serialVersionUID = 1L;
41  
42      /**
43       * {@inheritDoc}
44       */
45      @Override
46      public String getEditHtml(final FieldValue _fieldValuee)
47          throws EFapsException
48      {
49          return "edit";
50      }
51  
52      /**
53       * {@inheritDoc}
54       */
55      @Override
56      public String getHiddenHtml(final FieldValue _fieldValue)
57          throws EFapsException
58      {
59          return "hidden";
60      }
61  
62      /**
63       * {@inheritDoc}
64       */
65      @Override
66      public String getReadOnlyHtml(final FieldValue _fieldValue)
67          throws EFapsException
68      {
69          return "read only";
70      }
71  
72      /**
73       * {@inheritDoc}
74       */
75      @Override
76      public String getStringValue(final FieldValue _fieldValue)
77          throws EFapsException
78      {
79          return getReadOnlyHtml(_fieldValue);
80      }
81  
82      /**
83       * {@inheritDoc}
84       */
85      @Override
86      public Object getObject4Compare(final FieldValue _fieldValue)
87          throws EFapsException
88      {
89          return null;
90      }
91  
92      /**
93       * {@inheritDoc}
94       * @throws EFapsException
95       */
96      @Override
97      public int compare(final FieldValue _fieldValue,
98                         final FieldValue _fieldValue2)
99          throws EFapsException
100     {
101         return 0;
102     }
103 
104     /**
105      * {@inheritDoc}
106      */
107     @Override
108     public String validateValue(final UIValue _value)
109         throws EFapsException
110     {
111         return null;
112     }
113 
114     /**
115      * {@inheritDoc}
116      */
117     @Override
118     public Object format(final Object _object,
119                          final String _pattern)
120         throws EFapsException
121     {
122         return _object;
123     }
124 
125     /**
126      * {@inheritDoc}
127      */
128     @Override
129     public Object getValue(final UIValue _uiValue)
130         throws EFapsException
131     {
132         return _uiValue.getDbValue();
133     }
134 
135     /**
136      * {@inheritDoc}
137      */
138     @Override
139     public Object transformObject(final UIValue _uiValue,
140                                   final Object _object)
141         throws EFapsException
142     {
143         if (_object instanceof Serializable) {
144             _uiValue.setDbValue((Serializable) _object);
145         }
146         return _object;
147     }
148 }