1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.upgrade.util;
16  
17  import com.liferay.portal.kernel.dao.db.DB;
18  import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
19  import com.liferay.portal.kernel.exception.SystemException;
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  }