/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.shardingsphere.shardingproxy.transport.common.packet.command.query;

import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.DatabasePacket;

import java.sql.ResultSetMetaData;
import java.sql.SQLException;

/**
 * Data header packet.
 *
 * @author zhangyonglun
 */
@Getter
public final class DataHeaderPacket implements DatabasePacket {
    
    private final int sequenceId;
    
    private final String schema;
    
    private final String table;
    
    private final String orgTable;
    
    @Setter
    private String name;
    
    private final String orgName;
    
    private final int columnLength;
    
    private final Integer columnType;
    
    private final int decimals;
    
    public DataHeaderPacket(final int sequenceId, final ResultSetMetaData resultSetMetaData, final int columnIndex) throws SQLException {
        this(sequenceId, resultSetMetaData.getSchemaName(columnIndex), resultSetMetaData.getTableName(columnIndex), resultSetMetaData.getTableName(columnIndex),
            resultSetMetaData.getColumnLabel(columnIndex), resultSetMetaData.getColumnName(columnIndex), resultSetMetaData.getColumnDisplaySize(columnIndex),
            resultSetMetaData.getColumnType(columnIndex), resultSetMetaData.getScale(columnIndex));
    }
    
    public DataHeaderPacket(final int sequenceId, final String schema, final String table, final String orgTable,
                            final String name, final String orgName, final int columnLength, final Integer columnType, final int decimals) {
        this.sequenceId = sequenceId;
        this.schema = schema;
        this.table = table;
        this.orgTable = orgTable;
        this.name = name;
        this.orgName = orgName;
        this.columnLength = columnLength;
        this.columnType = columnType;
        this.decimals = decimals;
    }
}

@@ -1136,16 +1136,35 @@
 yonglun%0A
+ * @author panjuan%0A
  */%0A@Get
@@ -1309,24 +1309,36 @@
 chema;%0A    %0A
+    @Setter%0A
     private 
@@ -1333,30 +1333,24 @@
     private 
-final 
 String table
@@ -1348,32 +1348,44 @@
 ing table;%0A    %0A
+    @Setter%0A
     private fina
@@ -1372,38 +1372,32 @@
 ter%0A    private 
-final 
 String orgTable;

add Setter