001: /*
002: * Copyright 2004-2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.compass.gps.device.jdbc.mapping;
018:
019: import java.sql.Types;
020:
021: /**
022: * Maps a version column (no property mapping required - if you wish to map the
023: * version colum to a <code>Resource Property</code> use the
024: * {@link org.compass.gps.device.jdbc.mapping.DataColumnToPropertyMapping}).
025: * <p>
026: * In order to map a version column, either the column index or the column name
027: * must be set, and the version column jdbc type (one of
028: * <code>java.sql.Types</code>). The version column jdbc type defaults to
029: * <code>java.sql.Types.BIGINT</code>.
030: * <p>
031: * Note that {@link org.compass.gps.device.jdbc.ResultSetJdbcGpsDevice} defaults
032: * to automatically detect and assign the version column sql type.
033: *
034: * @author kimchy
035: */
036: public class VersionColumnMapping extends AbstractColumnMapping {
037:
038: private int sqlType = Types.BIGINT;
039:
040: /**
041: * Creates an empty version column mapping. Must set at least the colum
042: * index or colum name.
043: * <p>
044: * The <code>sqlType</code> defaults to <code>java.sql.Types.BIGINT</code>.
045: */
046: public VersionColumnMapping() {
047:
048: }
049:
050: /**
051: * Creates a new version column mapping given the column name.
052: * <p>
053: * The <code>sqlType</code> defaults to <code>java.sql.Types.BIGINT</code>.
054: *
055: * @param columnName
056: * The version column name that will be used to look up the
057: * column value.
058: */
059: public VersionColumnMapping(String columnName) {
060: super (columnName);
061: }
062:
063: /**
064: * Creates a new version column mapping given the column name.
065: * <p>
066: * The <code>sqlType</code> defaults to <code>java.sql.Types.BIGINT</code>.
067: *
068: * @param columnIndex
069: * The version column name that will be used to look up the
070: * column value.
071: */
072: public VersionColumnMapping(int columnIndex) {
073: super (columnIndex);
074: }
075:
076: /**
077: * Creates a new version column mapping given the column name and the column
078: * sql type.
079: *
080: * @param columnName
081: * The version column name that will be used to look up the
082: * column value.
083: * @param sqlType
084: * The sql type (<code>java.sql.Types</code>) of the version
085: * column.
086: */
087: public VersionColumnMapping(String columnName, int sqlType) {
088: super (columnName);
089: this .sqlType = sqlType;
090: }
091:
092: /**
093: * Creates a new version column mapping given the column index and the
094: * column sql type.
095: *
096: * @param columnIndex
097: * The version column name that will be used to look up the
098: * column value.
099: * @param sqlType
100: * The sql type (<code>java.sql.Types</code>) of the version
101: * column.
102: */
103: public VersionColumnMapping(int columnIndex, int sqlType) {
104: super (columnIndex);
105: this .sqlType = sqlType;
106: }
107:
108: /**
109: * Returns the jdbc sql type of the version column. Should be one of
110: * <code>java.sql.Types</code>.
111: *
112: * @return The jdbc sql type of the version column.
113: */
114: public int getSqlType() {
115: return sqlType;
116: }
117:
118: /**
119: * Sets the jdbc sql type of the version column. Should be one of
120: * <code>java.sql.Types</code>.
121: *
122: * @param sqlType
123: * The jdbc sql type of the version column.
124: */
125: public void setSqlType(int sqlType) {
126: this.sqlType = sqlType;
127: }
128: }
|