1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.upgrade.util;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.dao.db.DB;
19  import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
20  
21  /**
22   * <a href="BaseUpgradeColumnImpl.java.html"><b><i>View Source</i></b></a>
23   *
24   * @author Brian Wing Shun Chan
25   */
26  public abstract class BaseUpgradeColumnImpl implements UpgradeColumn {
27  
28      public BaseUpgradeColumnImpl(String name) {
29          this(name, null);
30      }
31  
32      public BaseUpgradeColumnImpl(String name, Integer oldColumnType) {
33          _name = name;
34          _oldColumnType = oldColumnType;
35      }
36  
37      public String getName() {
38          return _name;
39      }
40  
41      public long increment() throws SystemException {
42          DB db = DBFactoryUtil.getDB();
43  
44          return db.increment();
45      }
46  
47      public boolean isApplicable(String name) {
48          if (_name.equals(name)) {
49              return true;
50          }
51          else {
52              return false;
53          }
54      }
55  
56      public Integer getOldColumnType(Integer defaultType) {
57          if (_oldColumnType == null) {
58              return defaultType;
59          }
60          else {
61              return _oldColumnType;
62          }
63      }
64  
65      public Object getOldValue() {
66          return _oldValue;
67      }
68  
69      public void setOldValue(Object oldValue) {
70          _oldValue = oldValue;
71      }
72  
73      public Integer getNewColumnType(Integer defaultType) {
74          return defaultType;
75      }
76  
77      public Object getNewValue() {
78          return _newValue;
79      }
80  
81      public void setNewValue(Object newValue) {
82          _newValue = newValue;
83      }
84  
85      private String _name;
86      private Integer _oldColumnType;
87      private Object _oldValue;
88      private Object _newValue;
89  
90  }