OpenKeyWord  Build Tag: jenkins-DoxyGen_EN-107, Build ID: 2015-03-08_20-51-06
 All Classes Namespaces Functions Variables Properties Pages
OKW.OKWHelper Class Reference

Class contains OKW-Helpfunctions. More...

Collaboration diagram for OKW.OKWHelper:

Static Public Member Functions

static string Boolean2String (bool fpbTrueOrFalse)
 Converts bool true/false to string "true"/"false". More...
 
static string GetLeftFromDelimiterNumber (string fpsSource, string fpsDelimiter, int fpiCount)
 The String will be cut at the fpiCount-ten delimiter and the left half of the String is returned. More...
 
static string GetRigthFromDelimiterNumber (string fpsSource, string fpsDelimiter, int fpiCount)
 Cuts fpsSource at fpiCount-ten fpsDelimiter and returns the right part of the string. More...
 
static bool ListStringCompare (List< string > ListString1, List< string > ListString2)
 Compares two ListStrings with view to their content. More...
 
static string ListStringConcat (List< string > fps_ListString2Concat, string fps_Separator)
 
static bool MatchStr (string fpsPattern, string fpsStringToMatch)
 Source: http://stackoverflow.com/questions/6907720/need-to-perform-wildcard-etc-search-on-a-string-using-regex. More...
 
static bool MatchStrIgnoreCase (string fpsPattern, string fpsStringToMatch)
 Source: http://stackoverflow.com/questions/6907720/need-to-perform-wildcard-etc-search-on-a-string-using-regex. More...
 
static string RemoveBeginEndQuotations (string fps_StringinQuotations)
 Removes quotation marks " at the beginning and at the end. Quotation marks being internal of the string will not be removed. If there are no quotation marks at the beginning and at the end, then the return is identical to the input. More...
 
static List< string > StrArray2ListStr (string[] fpsStringArray)
 Converts a String-Array to a List-String. More...
 
static bool String2Boolean (string fpsTrueOrFalse)
 Converts string "true"/"false" to bool. More...
 
static List< string > StrSplit (string fpsString2Split, string fpsSeparator)
 Splits a string at the given Separator. The separator can consist of more than one sign. More...
 

Static Private Attributes

static Logger Log = Logger.Instance
 
static LogMessenger LM = new LogMessenger("OKWHelper")
 

Detailed Description

Class contains OKW-Helpfunctions.

This class is and should to be used in project specific classes.

Member Function Documentation

static string OKW.OKWHelper.Boolean2String ( bool  fpbTrueOrFalse)
static

Converts bool true/false to string "true"/"false".

Parameters
fpbTrueOrFalseBoolean value to be converted.
Returns
  • true is to be changed in "true" and
  • falsebecomes "false".
Author
Zoltán Hrabovszki
Date
2013.05.03
109  {
110  string lvsReturn = string.Empty;
111 
112  Logger.Instance.LogFunctionStartDebug("OKWHelper.Boolean2String", "fpbTrueOrFalse", fpbTrueOrFalse.ToString());
113 
114  try
115  {
116  if (fpbTrueOrFalse)
117  {
118  lvsReturn = "true";
119  }
120  else
121  {
122  lvsReturn = "false";
123  }
124  }
125  finally
126  {
127  Logger.Instance.LogFunctionEndDebug(lvsReturn);
128  }
129 
130  return lvsReturn;
131  }
static string OKW.OKWHelper.GetLeftFromDelimiterNumber ( string  fpsSource,
string  fpsDelimiter,
int  fpiCount 
)
static

The String will be cut at the fpiCount-ten delimiter and the left half of the String is returned.

An exception is triggered, if

  • the delimiter is empty: OKW.OKWDelimiterIsEmptyException
  • fpiCount is not in valid parameters(1 >= fpiCount >c= numerb of delimiters): OKW.OKWDelimiterCountOutOfRangeException

Valid examples:

Examples with triggering the exception procedure

Parameters
fpsSourceSignstring to be cut.
fpsDelimiterDelimiter which is cut. Delimiter itself is no part of the return. Delimiter can exist out of more than 1 sign.
fpiCountNumber of delimiter to be cut. fpiCount is out of the multitude of natural numbers, 1, 2, 3, ... sides of the string, viewed from delimiter fpsDelemeter.
Author
Zoltán Hrabovszki
Date
2013.05.03
183  {
184  string lvsReturn = string.Empty;
185  List<string> lvLsSplitedSource = null;
186 
187  bool bOK = false;
188 
189  int RangeMin = 1;
190  int RangeMax = 1;
191 
192  try
193  {
194  Log.LogFunctionStartDebug("OKWHelper.GetLeftFromDelimiterNumber", "fpsSource", fpsSource, "fpsDelimiter", fpsDelimiter, "fpiCount", fpiCount.ToString());
195 
196  if (fpsDelimiter != string.Empty)
197  {
198  lvLsSplitedSource = StrSplit(fpsSource, fpsDelimiter);
199 
200  // Gültigen Werte bereich berechnen:
201  RangeMax = lvLsSplitedSource.Count - 1;
202  RangeMin = 1;
203 
204  // 1. Prüfen ob Split Zahl <= Count, anderefalls Exception auslösen...
205  if ((RangeMin <= fpiCount) & (fpiCount <= RangeMax))
206  {
207  // 2. Dann bauen wir den string auf
208  lvsReturn = lvLsSplitedSource[0];
209 
210  for (int i = 1; i < fpiCount; i++)
211  {
212  lvsReturn = lvsReturn + fpsDelimiter + lvLsSplitedSource[i];
213  }
214  }
215  else
216  {
217  string lvsLM = LM.GetMessage("GetLeftFromDelimiterNumber", "OKWDelimiterCountOutOfRangeException", fpiCount.ToString(), RangeMax.ToString());
218  throw new System.IndexOutOfRangeException(lvsLM);
219  }
220  }
221  else
222  {
223  string lvsLM = LM.GetMessage("GetLeftFromDelimiterNumber", "OKWDelimiterIsEmptyException");
224  throw new System.ArgumentException(lvsLM);
225  }
226 
227  bOK = true;
228  }
229  finally
230  {
231  if (bOK)
232  {
233  Log.LogFunctionEndDebug(lvsReturn);
234  }
235  else
236  {
237  Log.LogFunctionEndDebug();
238  }
239  }
240 
241  return lvsReturn;
242  }
static List< string > StrSplit(string fpsString2Split, string fpsSeparator)
Splits a string at the given Separator. The separator can consist of more than one sign...
Definition: OKWHelper.cs:737

Here is the call graph for this function:

static string OKW.OKWHelper.GetRigthFromDelimiterNumber ( string  fpsSource,
string  fpsDelimiter,
int  fpiCount 
)
static

Cuts fpsSource at fpiCount-ten fpsDelimiter and returns the right part of the string.

Valid examples:

  • "DDD/EEE" = GetRigthFromDelimiterNumber("AAA/BBB/CCC/DDD/EEE", "/", 3)
  • "BBB/CCC/DDD/EEE" = GetRigthFromDelimiterNumber("AAA/BBB/CCC/DDD/EEE", "/", 1)
  • "EEE" = GetRigthFromDelimiterNumber("AAA/BBB/CCC/DDD/EEE", "/", 4)

Examples triggering the exception procedure

Parameters
fpsSourceQuelle
fpsDelimiterDelimiter which is to be cut.
fpiCount
Returns
Todo:

TODO ZH: Rückgabewert beschreiben.

Author
Zoltán Hrabovszki
Date
2013.05.03
285  {
286  string lvsReturn = string.Empty;
287  List<string> lvLsSplitedSource = null;
288  bool bOK = false;
289  int RangeMin = 1;
290  int RangeMax = 1;
291  try
292  {
293  Log.LogFunctionStartDebug("OKWHelper.GetLeftFromDelimiterNumber", "fpsSource", fpsSource, "fpsDelimiter", fpsDelimiter, "fpiCount", fpiCount.ToString());
294  if (fpsDelimiter != string.Empty)
295  {
296  lvLsSplitedSource = StrSplit(fpsSource, fpsDelimiter);
297 
298  // Gültigen Werte bereich berechnen:
299  RangeMax = lvLsSplitedSource.Count - 1;
300  RangeMin = 1;
301 
302  // 1. Prüfen ob Split Zahl <= Count, anderefalls Exception auslösen...
303  if ((RangeMin <= fpiCount) & (fpiCount <= RangeMax))
304  {
305  // 2. Dann bauen wir den string auf
306  lvsReturn = lvLsSplitedSource[fpiCount];
307 
308  for (int i = fpiCount + 1; i < lvLsSplitedSource.Count; i++)
309  {
310  lvsReturn = lvsReturn + fpsDelimiter + lvLsSplitedSource[i];
311  }
312  }
313  else
314  {
315  string lvsLM = LM.GetMessage("GetLeftFromDelimiterNumber", "OKWDelimiterCountOutOfRangeException", fpiCount.ToString(), RangeMax.ToString());
316  throw new System.IndexOutOfRangeException(lvsLM);
317  }
318  }
319  else
320  {
321  string lvsLM = LM.GetMessage("GetLeftFromDelimiterNumber", "OKWDelimiterIsEmptyException");
322  throw new System.ArgumentException(lvsLM);
323  }
324 
325  bOK = true;
326  }
327  finally
328  {
329  if (bOK)
330  {
331  Log.LogFunctionEndDebug(lvsReturn);
332  }
333  else
334  {
335  Log.LogFunctionEndDebug();
336  }
337  }
338 
339  return lvsReturn;
340  }
static List< string > StrSplit(string fpsString2Split, string fpsSeparator)
Splits a string at the given Separator. The separator can consist of more than one sign...
Definition: OKWHelper.cs:737

Here is the call graph for this function:

static bool OKW.OKWHelper.ListStringCompare ( List< string >  ListString1,
List< string >  ListString2 
)
static

Compares two ListStrings with view to their content.

Parameters
ListString1String Nr. 1
ListString2String Nr. 2 if the string content is identical, else false.
Author
Zoltán Hrabovszki
Date
2013.15.11
362  {
363  bool lvbReturn = true;
364  bool bOK = false;
365 
366  Logger.Instance.LogFunctionStartDebug("OKWHelper.ListStringCompare", "ListString1", ListString1.ToString(), "ListString2", ListString2.ToString());
367 
368  try
369  {
370  // HAben beide Listen
371  if (ListString1.Count == ListString2.Count)
372  {
373  for (int i = 0; i < ListString1.Count; i++)
374  {
375  if (ListString1[i] != ListString2[i])
376  {
377  // ungleich daher abbrechen und false zurückliefern.
378  Logger.Instance.LogPrintDebug(ListString1[i] + "<>" + ListString2[i]);
379  lvbReturn = false;
380  break;
381  }
382  else
383  {
384  lvbReturn = true;
385  }
386  }
387  }
388  else
389  {
390  lvbReturn = false;
391  }
392 
393  bOK = true;
394  }
395  finally
396  {
397  if (bOK)
398  {
399  Logger.Instance.LogFunctionEndDebug(lvbReturn);
400  }
401  else
402  {
403  Logger.Instance.LogFunctionEndDebug();
404  }
405  }
406 
407  return lvbReturn;
408  }

Here is the caller graph for this function:

static string OKW.OKWHelper.ListStringConcat ( List< string >  fps_ListString2Concat,
string  fps_Separator 
)
static
Author
Zoltán Hrabovszki
Date
2013.01.03
450  {
451  string lvsReturn = string.Empty;
452  bool bOK = false;
453 
454  Log.LogFunctionStartDebug("OKWHelper.ListStringConcat", "fps_ListString2Concat", fps_ListString2Concat.ToString(), "fps_Separator", fps_Separator);
455 
456  try
457  {
458  lvsReturn = string.Join(fps_Separator, fps_ListString2Concat.ToArray());
459  bOK = true;
460  }
461  finally
462  {
463  if (bOK)
464  {
465  Log.LogFunctionEndDebug(lvsReturn);
466  }
467  else
468  {
469  Log.LogFunctionEndDebug();
470  }
471  }
472 
473  return lvsReturn;
474  }
static bool OKW.OKWHelper.MatchStr ( string  fpsPattern,
string  fpsStringToMatch 
)
static

Source: http://stackoverflow.com/questions/6907720/need-to-perform-wildcard-etc-search-on-a-string-using-regex.

Parameters
fpsPattern
fpsStringToMatch
Returns
Todo:
TODO ZH: Rückgabewert beschreiben.
492  {
493  // Variables:
494  bool lvbReturn = false;
495  bool bOK = false;
496 
497  // Action:
498  try
499  {
500  Logger.Instance.LogFunctionStartDebug("OKWHelper.MatchStr", "String fpsPattern", fpsPattern, "String fpsStringToMatch", fpsStringToMatch);
501 
502  // Replace the * with an .* and the ? with a dot. Put ^ at the
503  // beginning and a $ at the end
504  string pattern = "^" + Regex.Escape(fpsPattern).Replace(@"\*", ".*").Replace(@"\?", ".") + "$";
505 
506  // Now, run the Regex as you already know
507  Regex regex;
508  regex = new Regex(pattern);
509 
510  lvbReturn = regex.IsMatch(fpsStringToMatch);
511  bOK = true;
512  }
513  finally
514  {
515  if (bOK)
516  {
517  Log.LogFunctionEndDebug(lvbReturn);
518  }
519  else
520  {
521  Log.LogFunctionEndDebug();
522  }
523  }
524 
525  return lvbReturn;
526  }

Here is the caller graph for this function:

static bool OKW.OKWHelper.MatchStrIgnoreCase ( string  fpsPattern,
string  fpsStringToMatch 
)
static

Source: http://stackoverflow.com/questions/6907720/need-to-perform-wildcard-etc-search-on-a-string-using-regex.

Parameters
fpsPattern
fpsStringToMatch
Returns
Todo:
TODO ZH: Rückgabewert beschreiben.
544  {
545  // Variables:
546  bool lvb_Return = false;
547  bool bOK = true;
548 
549  // Action:
550  try
551  {
552  Logger.Instance.LogFunctionStartDebug("OKWHelper.MatchStrIgnoreCase", "String fpsPattern", fpsPattern, "String fpsStringToMatch", fpsStringToMatch);
553 
554  // Replace the * with an .* and the ? with a dot. Put ^ at the
555  // beginning and a $ at the end
556  string pattern = "^" + Regex.Escape(fpsPattern).Replace(@"\*", ".*").Replace(@"\?", ".") + "$";
557 
558  // Now, run the Regex as you already know
559  Regex regex;
560  regex = new Regex(pattern, RegexOptions.IgnoreCase);
561 
562  lvb_Return = regex.IsMatch(fpsStringToMatch);
563  bOK = true;
564  }
565  finally
566  {
567  if (bOK)
568  {
569  Logger.Instance.LogFunctionEndDebug(lvb_Return);
570  }
571  else
572  {
573  Logger.Instance.LogFunctionEndDebug();
574  }
575  }
576 
577  return lvb_Return;
578  }
static string OKW.OKWHelper.RemoveBeginEndQuotations ( string  fps_StringinQuotations)
static

Removes quotation marks " at the beginning and at the end. Quotation marks being internal of the string will not be removed. If there are no quotation marks at the beginning and at the end, then the return is identical to the input.

Parameters
fps_StringinQuotationsString, which should be removed from quotation marks. without quotation marks at the beginning an the end.
Author
Zoltán Hrabovszki
Date
2013.05.03
601  {
602  string lvs_Return = Regex.Replace(fps_StringinQuotations, "^\"|\"$", string.Empty);
603  return lvs_Return;
604  }
static List<string> OKW.OKWHelper.StrArray2ListStr ( string[]  fpsStringArray)
static

Converts a String-Array to a List-String.

Parameters
fpsStringArrayArray to be converted. as a List-String.
Author
Zoltán Hrabovszki
Date
2013.05.03
624  {
625  Logger.Instance.LogFunctionStartDebug("OKWHelper.StrArray2ListStr", "fpsStringArray", fpsStringArray.ToString());
626 
627  List<string> lvls_Splited = new List<string>();
628  lvls_Splited.Clear();
629 
630  try
631  {
632  lvls_Splited = new List<string>(fpsStringArray);
633  }
634  finally
635  {
636  Logger.Instance.LogFunctionEndDebug(lvls_Splited);
637  }
638 
639  return lvls_Splited;
640  }

Here is the caller graph for this function:

static bool OKW.OKWHelper.String2Boolean ( string  fpsTrueOrFalse)
static

Converts string "true"/"false" to bool.

true/false.

Exceptions
Theexception OKWNotAllowedValueException is triggerd, if the input Parapere is not "true"/"false".
Parameters
fpbTrueOrFalseBoolean value to be converted.
Returns
  • true is to be changed in "true" and
  • falsebecomes "false".
Author
Zoltán Hrabovszki
Date
2013.05.03
673  {
674  bool lvbReturn = false;
675  bool bOK = false;
676 
677  string lvsTrueOrFalse = fpsTrueOrFalse.ToLower();
678 
679  Logger.Instance.LogFunctionStartDebug("OKWHelper.String2Boolean", "fpsTrueOrFalse", fpsTrueOrFalse);
680 
681  try
682  {
683  if ( lvsTrueOrFalse == "true")
684  {
685  lvbReturn = true;
686  bOK = true;
687  }
688  else if ( lvsTrueOrFalse == "false" )
689  {
690  lvbReturn = false;
691  bOK = true;
692  }
693  else{
694  // alles andere löst ein OKWNotAllowedValueException aus
695  bOK = false;
696 
697  string lvsLM = LM.GetMessage("String2Boolean", "OKWNotAllowedValueException", fpsTrueOrFalse);
698  throw new OKWNotAllowedValueException(lvsLM);
699  }
700  }
701  finally
702  {
703  if (bOK)
704  {
705  Log.LogFunctionEndDebug(lvbReturn);
706  }
707  else
708  {
709  Log.LogFunctionEndDebug();
710  }
711  }
712 
713  return lvbReturn;
714  }
static List<string> OKW.OKWHelper.StrSplit ( string  fpsString2Split,
string  fpsSeparator 
)
static

Splits a string at the given Separator. The separator can consist of more than one sign.

Parameters
fpsString2Splitstring to be splitted.
fpsSeparator
Returns
Todo:
TODO ZH: Rückgabewert beschreiben.
Author
Zoltán Hrabovszki
Date
2013.05.03
738  {
739  bool bOK = false;
740 
741  string[] lvsA_Splited;
742  List<string> lvls_Splited = new List<string>();
743 
744  string[] lvsSeparators = new string[] { fpsSeparator };
745 
746  Log.LogFunctionStartDebug("OKWHelper.StrSplit", "fpsString2Split", fpsString2Split, "fpsSeparator", fpsSeparator);
747 
748  try
749  {
750  lvsA_Splited = fpsString2Split.Split(lvsSeparators, StringSplitOptions.None);
751  lvls_Splited = StrArray2ListStr(lvsA_Splited);
752  bOK = true;
753  }
754  finally
755  {
756  if (bOK)
757  {
758  Log.LogFunctionEndDebug(lvls_Splited);
759  }
760  else
761  {
762  Log.LogFunctionEndDebug();
763  }
764  }
765 
766  return lvls_Splited;
767  }
static List< string > StrArray2ListStr(string[] fpsStringArray)
Converts a String-Array to a List-String.
Definition: OKWHelper.cs:623

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

LogMessenger OKW.OKWHelper.LM = new LogMessenger("OKWHelper")
staticprivate

Todo:
TODO: für JN review
Logger OKW.OKWHelper.Log = Logger.Instance
staticprivate

Todo:
TODO: für JN review

The documentation for this class was generated from the following file: