---
title: "java新建类，要重写的4个方法"
author: "bailingeye"
date: "2011-07-19T10:26:21Z"
tags: []
categories: ["Web前端"]
slug: "java-4"
draft: false
lastmod: "2011-07-19T10:27:35Z"
id: 1127615
url: "https://bailingeye.iteye.com/blog/1127615"
---

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\**  
//  
// G2Bシステム  
// クラス名称：G2B2Lgc8310  
// クラスの概要：G2B2Lgc8310 ファイル名でファイルをソートするには  
//  
// &lt;&lt;修正履歴&gt;&gt;  
//    1    2011/07/12  1.00    BFS)BaiLingzhou    VSLP:Issues10)VSLPに関するALL PAGE DL 新規作成  
//  
// All Rights Reserved,  
// Copyright (株) 日立製作所、(株) ピーアンドアイ、富士通 (株)  
//  
//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\**  
package jp.co.nissan.g2b2.util;

/\**  
 * TSVファイルをソート  
 * @version    1.00  
 * @author    BFS)BaiLingzhou  
 *  
 \*/  
public class G2B2UtlTsvFileName implements Comparable&lt;G2B2UtlTsvFileName&gt;  
{  
    private String frontName;  
      
    private String endName;  
      
    private String fileName;  
    /\**  
     * TSVファイルクラスのConstructor  
     * @param fileName    Oldファイル名  
     \*/  
    public G2B2UtlTsvFileName(String fileName)  
    {  
        // the position of "\_Object" or "\_Criteria"  
        int position = fileName.indexOf("\_Object")&gt;0?fileName.indexOf("\_Object"):fileName.indexOf("\_Criteria");  
        this.frontName = fileName.substring(0, position);  
        this.endName   = fileName.substring(position,fileName.length());  
        this.fileName  = fileName;  
    }

      
    public String toString()  
    {  
        return this.fileName;  
    }

    /\**  
     * 比較名前の前,等しい場合,順アレンジメント  
     *             等しくない場合,逆アレンジメント  
     * @param    ファイルの名前  
     * @return    等しいか、等しくないか  
     \*/  
    @Override  
    public int compareTo(G2B2UtlTsvFileName other)  
    {  
        // 名前の前、等しいか、等しくないか  
        if(this.frontName.equals(other.frontName))  
        {  
            // 比較名前の後、等しいか、等しくないか  
            return this.endName.compareTo(other.endName);  
        }  
        else  
        {  
            // 名前の前、等しいか、逆アレンジメント  
            return other.frontName.compareTo(this.frontName);  
        }  
    }  
      
    /\**  
     * equalsはObject定義されたメソッドなので、オーバーライドが必要のメソッドです  
     \*/  
    @Override  
    public boolean equals(Object other)  
    {  
        G2B2UtlTsvFileName o;  
        if(other instanceof G2B2UtlTsvFileName)  
        {  
            o = (G2B2UtlTsvFileName)other;  
        }else{  
            return false;  
        }  
        return this.fileName.equals(o.fileName);  
    }  
      
    /\**  
     * hashCodeはObject定義されたメソッドなので、オーバーライドが必要のメソッドです  
     \*/  
    @Override  
    public int hashCode()  
    {  
        return this.fileName.hashCode();  
    }  
}