Main Page | Class Hierarchy | Class List | File List | Class Members

HunkDel.cs

00001 namespace JLibDiff
00002 {
00003         using System;
00004         
00005         /*
00006         * The <code>HunkDel</code> class represents a bloc of difference that will
00007         * be deleted.
00008         */
00009         [Serializable]
00010         public class HunkDel:Hunk
00011         {
00012                 
00013                 internal int ld1;
00014                 internal int lf1;
00015                 internal int ld2;
00016                 
00017                 internal System.Collections.ArrayList a = new System.Collections.ArrayList();
00018                 
00019                 public override void  accept(HunkVisitor visitor)
00020                 {
00021                         visitor.visitHunkDel(this);
00022                 }
00023                 
00024                 
00025                 /*
00026                 *  Returns string to delete.
00027                 */
00028                 public virtual System.String getOldContents()
00029                 {
00030                         System.String s = new System.String("".ToCharArray());
00031                         //UPGRADE_TODO: The method hasMoreElements has a different behavior in .NET.;
00032                          for (System.Collections.IEnumerator e = a.GetEnumerator(); e.MoveNext(); )
00033                         {
00034                                 //UPGRADE_TODO: The method nextElement has a different behavior in .NET.;
00035                                 s = System.String.Concat(s, (System.String) e.Current);
00036                         }
00037                         return s;
00038                 }
00039                 
00040                 /*
00041                 *  Returns a string representation of the current hunk
00042                 *  with normal format .
00043                 */
00044                 public override System.String convert()
00045                 {
00046                         System.String s = new System.String(System.Convert.ToString(ld1).ToCharArray());
00047                         if (ld1 != lf1)
00048                                 s = System.String.Concat(s, "," + lf1);
00049                         s = System.String.Concat(s, "d" + ld2 + "\n");
00050                         //UPGRADE_TODO: The method hasMoreElements has a different behavior in .NET.;
00051                          for (System.Collections.IEnumerator e = a.GetEnumerator(); e.MoveNext(); )
00052                         {
00053                                 //UPGRADE_TODO: The method nextElement has a different behavior in .NET.;
00054                                 s = System.String.Concat(s, "< " + (System.String) e.Current);
00055                         }
00056                         return s;
00057                 }
00058                 
00059                 /*
00060                 *  Returns a string representation of the current hunk
00061                 *  with ED_script format .
00062                 */
00063                 public override System.String convert_ED()
00064                 {
00065                         System.String s = new System.String(System.Convert.ToString(ld1).ToCharArray());
00066                         if (ld1 != lf1)
00067                                 s = System.String.Concat(s, "," + lf1);
00068                         s = System.String.Concat(s, "d\n");
00069                         return s;
00070                 }
00071                 
00072                 /*
00073                 *  Returns a string representation of the current hunk
00074                 *  with RCS_script format .
00075                 */
00076                 public override System.String convert_RCS()
00077                 {
00078                         System.String s = new System.String(("d" + ld1 + " " + (lf1 - ld1 + 1) + "\n").ToCharArray());
00079                         return s;
00080                 }
00081                 
00082                 /*
00083                 *  Returns the number of low line of file passed in argument .
00084                 *  Lines are inclusif.
00085                 *
00086                 * @param filenum The number of file (the first file '0', or the second '1').
00087                 */
00088                 public override int lowLine(int filenum)
00089                 {
00090                         if (filenum == 0)
00091                                 return ld1;
00092                         else
00093                                 return ld2;
00094                 }
00095                 
00096                 /*
00097                 *  Returns the number of high line of file passed in argument .
00098                 *  Lines are inclusif.
00099                 *
00100                 * @param filenum The number of file (the first file '0', or the second '1').
00101                 */
00102                 public override int highLine(int filenum)
00103                 {
00104                         if (filenum == 0)
00105                                 return lf1;
00106                         else
00107                                 return ld2;
00108                 }
00109                 
00110                 /*
00111                 *  Returns the number of lines consedered in this hunk and which 
00112                 *  came from file passed in argument .
00113                 *
00114                 * @param filenum The number of file (the first file '0', or the second '1').
00115                 */
00116                 public override int numLines(int filenum)
00117                 {
00118                         if (filenum == 0)
00119                                 return (lf1 - ld1 + 1);
00120                         else
00121                                 return 1;
00122                 }
00123                 
00124                 /*
00125                 *  Returns a string representing the line in file and position
00126                 *  passed in argument.
00127                 *
00128                 * @param filenum The number of file (the first file '0', or the second '1').
00129                 * @param linenum the number of line that will be returned.
00130                 */
00131                 public override System.String relNum(int filenum, int linenum)
00132                 {
00133                         if (filenum == 0)
00134                                 return (System.String) a[linenum];
00135                         else
00136                                 return null;
00137                 }
00138         }
00139 }

Generated on Mon May 8 22:07:27 2006 by  doxygen 1.3.9.1