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

HunkChange.cs

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

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