Пример #1
0
 protected internal void replace0(int start, int end, String s)
 {
     if (start >= 0)
     {
         if (end > count)
         {
             end = count;
         }
         if (end > start)
         {
             int stringLength = s.length();
             int diff         = end - start - stringLength;
             if (diff > 0)   // replacing with fewer characters
             {
                 if (!shared)
                 {
                     // index == count case is no-op
                     java.lang.SystemJ.arraycopy(value, end, value, start
                                                 + stringLength, count - end);
                 }
                 else
                 {
                     char[] newData = new char[value.Length];
                     java.lang.SystemJ.arraycopy(value, 0, newData, 0, start);
                     // index == count case is no-op
                     java.lang.SystemJ.arraycopy(value, end, newData, start
                                                 + stringLength, count - end);
                     value  = newData;
                     shared = false;
                 }
             }
             else if (diff < 0)
             {
                 // replacing with more characters...need some room
                 move(-diff, end);
             }
             else if (shared)
             {
                 char[] clone = new char[value.Length];
                 SystemJ.arraycopy(value, 0, clone, 0, value.Length);
                 value  = clone;
                 shared = false;
             }
             s.getChars(0, stringLength, value, start);
             count -= diff;
             return;
         }
         if (start == end)
         {
             if (s == null)
             {
                 throw new java.lang.NullPointerException();
             }
             insert0(start, s);
             return;
         }
     }
     throw new StringIndexOutOfBoundsException();
 }
Пример #2
0
 /*
  * Returns the {@code boolean} value of the system property identified by
  * {@code string}.
  *
  * @param string
  *            the name of the requested system property.
  * @return {@code true} if the system property named by {@code string}
  *         exists and it is equal to "true" using case insensitive
  *         comparison, {@code false} otherwise.
  * @see System#getProperty(String)
  */
 public static bool getBoolean(String s)
 {
     if (s == null || s.length() == 0)
     {
         return(false);
     }
     return(parseBoolean(SystemJ.getProperty(s)));
 }
Пример #3
0
 /**
  * Sets the character at the {@code index}.
  *
  * @param index
  *            the zero-based index of the character to replace.
  * @param ch
  *            the character to set.
  * @throws IndexOutOfBoundsException
  *             if {@code index} is negative or greater than or equal to the
  *             current {@link #length()}.
  */
 public virtual void setCharAt(int index, char ch)
 {
     if (0 > index || index >= count)
     {
         throw new StringIndexOutOfBoundsException(index);
     }
     if (shared)
     {
         char[] clone = new char[value.Length];
         SystemJ.arraycopy(value, 0, clone, 0, value.Length);
         value  = clone;
         shared = false;
     }
     value[index] = ch;
 }
Пример #4
0
 public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
 {
     if (srcBegin < 0)
     {
         throw new StringIndexOutOfBoundsException(srcBegin);
     }
     if (srcEnd > this.delegateInstance.Length)
     {
         throw new StringIndexOutOfBoundsException(srcEnd);
     }
     if (srcBegin > srcEnd)
     {
         throw new StringIndexOutOfBoundsException(srcEnd - srcBegin);
     }
     SystemJ.arraycopy(this.delegateInstance.ToCharArray(), 0 + srcBegin, dst, dstBegin,
                       srcEnd - srcBegin);
 }
Пример #5
0
        public Process exec(String[] cmdArray, String[] env, java.io.File dir)
        {
            Process p = new Process();

            p.StartInfo.WorkingDirectory = (null != dir) ? dir.toString() : SystemJ.getProperty("user.dir");
            p.StartInfo.FileName         = cmdArray[0];
            for (int i = 0; i < env.Length; i++)
            {
                String [] keyValue = env [i].Split('=');
                p.StartInfo.EnvironmentVariables.Add(keyValue[0], keyValue[1]);
            }
            for (int i = 1; i < cmdArray.Length; i++)
            {
                p.StartInfo.Arguments.Insert(i - 1, cmdArray[i]);
            }
            p.StartInfo.UseShellExecute = true;
            p.Start();
            return(p);
        }