Beispiel #1
0
        /*
         * Gets private field value by reflection.
         *
         * @param fieldName the field name to be set @param target the object which
         * field to be gotten
         *
         * internal static Object getInternalField(String fieldName, Object target) {
         *  Object value = AccessController
         *          .doPrivileged(new PrivilegedAction<Object>() {
         *              public Object run() {
         *                  Object result = null;
         *                  java.lang.reflect.Field field = null;
         *                  try {
         *                      field = target.getClass().getDeclaredField(
         *                              fieldName);
         *                      field.setAccessible(true);
         *                      result = field.get(target);
         *                  } catch (Exception e1) {
         *                      return null;
         *                  }
         *                  return result;
         *              }
         *          });
         *  return value;
         * }*/

        protected internal static bool upTo(String s, ParsePosition position,
                                            java.lang.StringBuffer buffer, char stop)
        {
            int  index = position.getIndex(), length = s.length();
            bool lastQuote = false, quote = false;

            while (index < length)
            {
                char ch = s.charAt(index++);
                if (ch == '\'')
                {
                    if (lastQuote)
                    {
                        buffer.append('\'');
                    }
                    quote     = !quote;
                    lastQuote = true;
                }
                else if (ch == stop && !quote)
                {
                    position.setIndex(index);
                    return(true);
                }
                else
                {
                    lastQuote = false;
                    buffer.append(ch);
                }
            }
            position.setIndex(index);
            return(false);
        }
Beispiel #2
0
        protected internal static bool upToWithQuotes(String s, ParsePosition position,
                                                      java.lang.StringBuffer buffer, char stop, char start)
        {
            int  index = position.getIndex(), length = s.length(), count = 1;
            bool quote = false;

            while (index < length)
            {
                char ch = s.charAt(index++);
                if (ch == '\'')
                {
                    quote = !quote;
                }
                if (!quote)
                {
                    if (ch == stop)
                    {
                        count--;
                    }
                    if (count == 0)
                    {
                        position.setIndex(index);
                        return(true);
                    }
                    if (ch == start)
                    {
                        count++;
                    }
                }
                buffer.append(ch);
            }
            // text.07=Unmatched braces in the pattern
            throw new java.lang.IllegalArgumentException("Unmatched braces in the pattern"); //$NON-NLS-1$
        }
Beispiel #3
0
 protected internal static bool upToWithQuotes(String s, ParsePosition position,
         java.lang.StringBuffer buffer, char stop, char start)
 {
     int index = position.getIndex(), length = s.length(), count = 1;
     bool quote = false;
     while (index < length) {
         char ch = s.charAt(index++);
         if (ch == '\'') {
             quote = !quote;
         }
         if (!quote) {
             if (ch == stop) {
                 count--;
             }
             if (count == 0) {
                 position.setIndex(index);
                 return true;
             }
             if (ch == start) {
                 count++;
             }
         }
         buffer.append(ch);
     }
     // text.07=Unmatched braces in the pattern
     throw new java.lang.IllegalArgumentException("Unmatched braces in the pattern"); //$NON-NLS-1$
 }
Beispiel #4
0
 /*
  * Gets private field value by reflection.
  *
  * @param fieldName the field name to be set @param target the object which
  * field to be gotten
  *
 internal static Object getInternalField(String fieldName, Object target) {
     Object value = AccessController
             .doPrivileged(new PrivilegedAction<Object>() {
                 public Object run() {
                     Object result = null;
                     java.lang.reflect.Field field = null;
                     try {
                         field = target.getClass().getDeclaredField(
                                 fieldName);
                         field.setAccessible(true);
                         result = field.get(target);
                     } catch (Exception e1) {
                         return null;
                     }
                     return result;
                 }
             });
     return value;
 }*/
 protected internal static bool upTo(String s, ParsePosition position,
         java.lang.StringBuffer buffer, char stop)
 {
     int index = position.getIndex(), length = s.length();
     bool lastQuote = false, quote = false;
     while (index < length) {
         char ch = s.charAt(index++);
         if (ch == '\'') {
             if (lastQuote) {
                 buffer.append('\'');
             }
             quote = !quote;
             lastQuote = true;
         } else if (ch == stop && !quote) {
             position.setIndex(index);
             return true;
         } else {
             lastQuote = false;
             buffer.append(ch);
         }
     }
     position.setIndex(index);
     return false;
 }