2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.md.sal.dom.xsql;
11 import java.io.Serializable;
14 * To be removed in Nitrogen
17 public class XSQLColumn implements Serializable, Comparable<Object> {
18 private static final long serialVersionUID = 4854919735031714751L;
20 private String name = null;
21 private String tableName = null;
22 private int charWidth = -1;
23 private Class<?> type = null;
24 private transient Object bluePrintNode = null;
25 private String origName = null;
26 private String origTableName = null;
28 public XSQLColumn(Object odlNode, String _tableName, Object _bluePrintNode) {
29 this.name = XSQLODLUtils.getNodeNameFromDSN(odlNode);
30 this.tableName = _tableName;
31 this.bluePrintNode = _bluePrintNode;
32 this.type = XSQLODLUtils.getTypeForODLColumn(odlNode);
35 public XSQLColumn(String _name, String _tableName,String _origName, String _origTableName){
37 this.tableName = _tableName;
38 this.origName = _origName;
39 this.origTableName = _origTableName;
42 public String getName() {
46 public String getTableName() {
50 public void setCharWidth(int i) {
51 if (this.charWidth < i) {
56 public int getCharWidth() {
57 return this.charWidth;
61 public int hashCode() {
62 return this.name.hashCode() + this.tableName.hashCode();
66 public boolean equals(Object obj) {
67 if (!(obj instanceof XSQLColumn)) {
70 XSQLColumn other = (XSQLColumn) obj;
71 return tableName.equals(other.tableName) && name.equals(other.name);
74 public Object getBluePrintNode() {
75 return this.bluePrintNode;
79 public String toString() {
80 return tableName + "." + name;
84 public int compareTo(Object o) {
85 return this.toString().compareTo(o.toString());
88 public Object getResultSetValue(Object obj){
89 if(this.type.equals(String.class)){
90 return obj.toString();
92 if(this.type.equals(int.class)){
93 return Integer.parseInt(obj.toString());
95 if(this.type.equals(long.class)){
96 return Long.parseLong(obj.toString());
98 if(this.type.equals(byte.class)){
99 return Byte.parseByte(obj.toString());