Class str

java.lang.Object
fr.formiko.usuel.types.str

public class str extends Object
Types conversions from String
Author:
Hydrolien
  • Constructor Details

    • str

      public str()
  • Method Details

    • split

      public static String[] split(String toSplit, char[] splitChar, char strLimiterChar)
      Split a string in an array.
      Parameters:
      toSplit - String to split
      splitChar - Array of char used to split
      strLimiterChar - char that define the start or the end of a unsecable string
    • stripAccents

      public static String stripAccents(String s)
      Remove all accent & replace special char by latin one.
    • countPointAndThrowExecption

      private static int countPointAndThrowExecption(String s)
      Count '.' & throw an exception if String is malformed.
      String is concider malformed if it have other char than "1234567890.".
    • isVersionOver

      public static boolean isVersionOver(String v1, String v2)
      Return true if version1 > version2.
    • nbrDeX

      public static int nbrDeX(String s, char x)
      get the number of char x in a String
      Parameters:
      s - String were to search.
      x - char to search on s.
      Returns:
      number of char x in s.
    • contient

      public static boolean contient(String s, String subS, byte x)
      is subS on the String
      Parameters:
      s - String were to search.
      subS - String to search on s.
      x - 0=s should starts with subS, 1=s should contain subS, 2=s should end with subsS, 3=s should be equals to subS.
      Returns:
      true if it contain subS
    • contient

      public static boolean contient(String s, String s2, int x)
    • contient

      public static boolean contient(String s, String s2)
    • addALaFinSiNecessaire

      public static String addALaFinSiNecessaire(String s, String fin)
      add fin at the end off s, if s does not arlerdy end by fin.
      Parameters:
      s - main String.
      fin - String to add on s.
      Returns:
      s with fin at the end.
    • filterForbiddenChar

      public static String filterForbiddenChar(String s, char[] t)
      Delete forbidden char in the array t.
      Parameters:
      s - the String were to delete forbidden char.
      t - the array were forbidden char are.
    • filterForbiddenChar

      public static String filterForbiddenChar(String s)
      Delete forbidden char depending of the os.
      if os is not define windows char will be deleted.
      Parameters:
      s - the String were to delete forbidden char.
    • sToFileName

      public static String sToFileName(String s)
    • sToDirectoryName

      public static String sToDirectoryName(String s)
      Transform a String to a directory name aviable on every os.
      If last / is missing it will be add. If there is a 1a / it will be delete. If there is \ they will be transform by /.
      Parameters:
      s - the String to transform to a directory name.
    • sToSMaj

      public static String sToSMaj(String s)
      Transform the first char of a String to the toUpperCase char.
      if s is "" or null nothing will be done.
      Parameters:
      s - the String to transform.
    • toMaj

      public static String toMaj(String s)
      Transform the first char of a String to the toUpperCase char.
      if s is "" or null nothing will be done.
      Parameters:
      s - the String to transform.
    • sToSMin

      public static String sToSMin(String s)
      Transform the first char of a String to the toLowerCase char.
      if s is "" or null nothing will be done.
      Parameters:
      s - the String to transform.
    • isMaj

      public static boolean isMaj(String s)
      Return true if 1a char is an english maj char.
      only A to Z without accent char are ok.
      Parameters:
      s - the String to test.
    • sToI

      public static int sToI(String s)
      From String to int return -1 if conversion fail.
    • sToI

      public static int sToI(String s, int iDefault)
      From String to int return Default value if conversion fail.
    • sToD

      public static double sToD(String s)
      From String to double return -1 if conversion fail.
    • sToD

      public static double sToD(String s, Double dDefault)
      From String to double return Default value if conversion fail.
    • sToLThrows

      public static long sToLThrows(String s) throws Exception
      From String to int Throw a Exception trows if conversion fail.
      Throws:
      Exception
    • sToL

      public static long sToL(String s)
      From String to long return -1 if conversion fail.
    • iToS

      public static String iToS(int x)
      From int to String
    • iToBy

      public static byte iToBy(int x)
      From int to byte return the max or the min if conversion fail.
    • iToB

      public static boolean iToB(int b)
      From int to boolean return true if conversion fail.
    • sToB

      public static boolean sToB(String s)
      From String to boolean boolean can be "true", "false" or "1", "0".
    • sToBy

      public static byte sToBy(String s, int iDefault)
      From String to byte
    • sToBy

      public static byte sToBy(String s)
      From String to byte
    • erreurConversion

      public static void erreurConversion(String xToY, String s)
      special error for conversion return -1 if conversion fail.
    • sToI

      public static int[] sToI(String[] ts)
      From int to String
    • iToS

      public static String[] iToS(int[] ts)
      From String to int file a case with -1 if conversion fail.
    • str

      public static String str(int s)
    • str

      public static String str(String s)
    • str

      public static String str(char c)
    • str

      public static String str(double x)
    • str

      public static String str(float x)