요르딩딩

Vo 만드는 법 본문

[Web]/[Spring]

Vo 만드는 법

요르딩딩 2021. 12. 21. 17:42
728x90
반응형
package com.vo;

import java.nio.ByteBuffer;
import java.nio.charset.Charset;

public class SComVO {
	
	//공통부  
	private byte [] len = new byte[4];  
	private byte [] sys = new byte[3];  

	// DB 정보 
	private String st;       
	private String bank;    
	private   long id = 0;
	private    int dbcount = 0; 

	protected final Charset cs = Charset.forName("ksc5601");
	
	public SComVO() {}

	public byte[] getTelegramTest() {
		byte[] telegram = new byte[200];
		ByteBuffer bf = ByteBuffer.wrap(telegram);
		
		bf.put(this.len);  
		bf.put(this.sys);  
		
		return telegram;
	}
	
	public ByteBuffer setTelegramTest(byte[] inComData) {
		ByteBuffer bf = ByteBuffer.wrap(inComData);
		
		bf.get(this.len);  
		bf.get(this.sys);  
		
		return bf;
	}

	public String fillStrTest(String inString, int len) {
   		
   		if(inString == null) inString ="";
   		
   	    if (inString.length() >= len) {
 	        return inString;
 	    }
 	    StringBuilder sb = new StringBuilder();
 	    sb.append(inString);
 	    while (sb.length() < len - inString.length()) {
 	        sb.append(' ');
 	    }
 	    return sb.toString();
 	}
	
	public String fillNumTest(String inString, int len) {
    	
		if(inString == null) inString ="";
    	 
 	    if (inString.length() >= len) {
 	        return inString;
 	    }
 	    StringBuilder sb = new StringBuilder();
 	    while (sb.length() < len - inString.length()) {
 	        sb.append('0');
 	    }
 	    sb.append(inString);
 	    return sb.toString();
 	}
	
	public String getLen() {
		return new String(len,cs);
	}

	public void setLen(String len) {
		if(len == null) return;
		this.len = len.getBytes(cs);
	}

	public String getSys() {
		return new String(sys,cs);
	}

	public void setSys(String sys) {
		if(sys == null) return;
		this.sys= sys.getBytes(cs);
	}

	public String getSts() {
		return sts;
	}

	public void setSts(String sts) {
		if(sts == null) return;
		this.sts = sts;
	}

	public String getBank() {
		return bank;
	}

	public void setBank(String bank) {
		if(bank == null) return;
		this.bank = bank;
	}
    public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public int getDbcount() {
		return dbcount;
	}

	public void setDbcount(int dbcount) {
		this.dbcount = dbcount;
	}
}
728x90
반응형
Comments