package textbender.a.u.transfer; // Copyright 2006-2007, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Textbender Software"), to deal in the Textbender Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Textbender Software, and to permit persons to whom the Textbender Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Textbender Software. THE TEXTBENDER SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE TEXTBENDER SOFTWARE OR THE USE OR OTHER DEALINGS IN THE TEXTBENDER SOFTWARE. import java.io.*; import textbender.a.r.desk.HostServiceRegistry; import textbender.g.lang.ThreadSafe; /** An object of a paired-region transfer. * It defines a contiguous region of the source document. */ public @ThreadSafe final class Transferand implements Serializable { private static final long serialVersionUID = 1L; /** Constructs a Transferand. * * @param origin per {@linkplain #origin() origin}() * @param documentFile per {@linkplain #documentFile() documentFile}() * @param gIndex0 per {@linkplain #gIndex0() gIndex0}() * @param gIndex1 per {@linkplain #gIndex1() gIndex1}() */ public Transferand( HostServiceRegistry.UniqueID origin, File documentFile, int gIndex0, int gIndex1 ) { if( documentFile == null ) throw new NullPointerException(); this.documentFile = documentFile; this.gIndex0 = gIndex0; this.gIndex1 = gIndex1; this.origin = origin; } // ------------------------------------------------------------------------------------ /** A file containing a copy of the source document. */ public File documentFile() { return documentFile; } private final File documentFile; /** Returns the g-index of the first gene of the transferand, * in document order. */ public int gIndex0() { return gIndex0; } private final int gIndex0; /** Returns the g-index of the last gene of the transferand, * in document order. */ public int gIndex1() { return gIndex1; } private final int gIndex1; /** Identifies the program agent that constructed the transferand. */ public final HostServiceRegistry.UniqueID origin() { return origin; } private final HostServiceRegistry.UniqueID origin; // - O b j e c t ---------------------------------------------------------------------- /** Returns true iff o is a transferand from the same document file, * and with the same g-indeces. The origin may differ, however. */ public @Override boolean equals( Object o ) { if( !(o instanceof Transferand )) return false; Transferand that = (Transferand)o; return this.gIndex0 == that.gIndex0 && this.gIndex1 == that.gIndex1 && this.documentFile.equals( that.documentFile ); } }