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;
13 public class XSQLColumn implements Serializable, Comparable<Object> {
14 private static final long serialVersionUID = 4854919735031714751L;
16 private String name = null;
17 private String tableName = null;
18 private int charWidth = -1;
19 private Class<?> type = null;
20 private transient Object bluePrintNode = null;
21 private String origName = null;
22 private String origTableName = null;
24 public XSQLColumn(Object odlNode, String _tableName, Object _bluePrintNode) {
25 this.name = XSQLODLUtils.getNodeNameFromDSN(odlNode);
26 this.tableName = _tableName;
27 this.bluePrintNode = _bluePrintNode;
28 this.type = XSQLODLUtils.getTypeForODLColumn(odlNode);
31 public XSQLColumn(String _name, String _tableName,String _origName, String _origTableName){
33 this.tableName = _tableName;
34 this.origName = _origName;
35 this.origTableName = _origTableName;
38 public String getName() {
42 public String getTableName() {
46 public void setCharWidth(int i) {
47 if (this.charWidth < i) {
52 public int getCharWidth() {
53 return this.charWidth;
57 public int hashCode() {
58 return this.name.hashCode() + this.tableName.hashCode();
62 public boolean equals(Object obj) {
63 if (!(obj instanceof XSQLColumn)) {
66 XSQLColumn other = (XSQLColumn) obj;
67 return tableName.equals(other.tableName) && name.equals(other.name);
70 public Object getBluePrintNode() {
71 return this.bluePrintNode;
75 public String toString() {
76 return tableName + "." + name;
80 public int compareTo(Object o) {
81 return this.toString().compareTo(o.toString());
84 public Object getResultSetValue(Object obj){
85 if(this.type.equals(String.class)){
86 return obj.toString();
88 if(this.type.equals(int.class)){
89 return Integer.parseInt(obj.toString());
91 if(this.type.equals(long.class)){
92 return Long.parseLong(obj.toString());
94 if(this.type.equals(byte.class)){
95 return Byte.parseByte(obj.toString());