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

HunkAdd.cs

00001 namespace JLibDiff
00002 {
00003         using System;
00004         
00005         /*
00006         * The <code>HunkAdd</code> class represents a bloc of difference reliding
00007         * addition(insertion).
00008         */
00009         [Serializable]
00010         public class HunkAdd:Hunk
00011         {
00012                 
00013                 internal int ld1;
00014                 internal int ld2;
00015                 internal int lf2;
00016                 
00017                 internal System.Collections.ArrayList b = new System.Collections.ArrayList();
00018                 
00019                 public override void  accept(HunkVisitor visitor)
00020                 {
00021                         visitor.visitHunkAdd(this);
00022                 }
00023                 
00024                 
00025                 /*
00026                 *  Returns string to append.
00027                 */
00028                 public virtual System.String getNewContents()
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 = b.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((+ ld1 + "a" + ld2).ToCharArray());
00047                         if (ld2 != lf2)
00048                                 s = System.String.Concat(s, "," + lf2);
00049                         s = System.String.Concat(s, "\n");
00050                         //UPGRADE_TODO: The method hasMoreElements has a different behavior in .NET.;
00051                          for (System.Collections.IEnumerator e = b.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((+ ld1 + "a\n").ToCharArray());
00066                         //UPGRADE_TODO: The method hasMoreElements has a different behavior in .NET.;
00067                          for (System.Collections.IEnumerator e = b.GetEnumerator(); e.MoveNext(); )
00068                         {
00069                                 //UPGRADE_TODO: The method nextElement has a different behavior in .NET.;
00070                                 s = System.String.Concat(s, (System.String) e.Current);
00071                         }
00072                         s = System.String.Concat(s, ".\n");
00073                         return s;
00074                 }
00075                 
00076                 /*
00077                 *  Returns a string representation of the current hunk
00078                 *  with RCS_script format .
00079                 */
00080                 public override System.String convert_RCS()
00081                 {
00082                         System.String s = new System.String(("a" + ld1 + " " + (lf2 - ld2 + 1) + "\n").ToCharArray());
00083                         //UPGRADE_TODO: The method hasMoreElements has a different behavior in .NET.;
00084                          for (System.Collections.IEnumerator e = b.GetEnumerator(); e.MoveNext(); )
00085                         {
00086                                 //UPGRADE_TODO: The method nextElement has a different behavior in .NET.;
00087                                 s = System.String.Concat(s, (System.String) e.Current);
00088                         }
00089                         return s;
00090                 }
00091                 
00092                 /*
00093                 *  Returns the number of low line of file passed in argument .
00094                 *  Lines are inclusif.
00095                 *
00096                 * @param filenum The number of file (the first file '0', or the second '1').
00097                 */
00098                 public override int lowLine(int filenum)
00099                 {
00100                         if (filenum == 0)
00101                                 return ld1;
00102                         else
00103                                 return ld2;
00104                 }
00105                 
00106                 /*
00107                 *  Returns the number of high line of file passed in argument .
00108                 *  Lines are inclusif.
00109                 *
00110                 * @param filenum The number of file (the first file '0', or the second '1').
00111                 */
00112                 public override int highLine(int filenum)
00113                 {
00114                         if (filenum == 0)
00115                                 return ld1;
00116                         else
00117                                 return lf2;
00118                 }
00119                 
00120                 /*
00121                 *  Returns the number of lines consedered in this hunk and which 
00122                 *  came from file passed in argument .
00123                 *
00124                 * @param filenum The number of file (the first file '0', or the second '1').
00125                 */
00126                 public override int numLines(int filenum)
00127                 {
00128                         if (filenum == 0)
00129                                 return 1;
00130                         else
00131                                 return (lf2 - ld2 + 1);
00132                 }
00133                 
00134                 /*
00135                 *  Returns a string representing the line in file and position
00136                 *  passed in argument.
00137                 *
00138                 * @param filenum The number of file (the first file '0', or the second '1').
00139                 * @param linenum the number of line that will be returned.
00140                 */
00141                 public override System.String relNum(int filenum, int linenum)
00142                 {
00143                         if (filenum == 0)
00144                                 return null;
00145                         else
00146                                 return (System.String) b[linenum];
00147                 }
00148         }
00149 }

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