public static String toString(boolean b)
 {
     return b ? new String("true") : new String("false");
 }
 public int compareTo(boolean b)
 {
     return compare(this.value, b.value);
 }
 public int compareTo(boolean b)
 {
     return(compare(this.value, b.value));
 }
 public void writeBoolean(boolean v)
 {
     @out.write(v ? 1 : 0);
     incCount(1);
 }
 //    private boolean enableResolve;
 //private SerialCallbackContext curContext;
 public ObjectInputStream(InputStream @in)
 {
     //verifySubclass();
     bin = new BlockDataInputStream(@in);
     handles = new HandleTable(10);
     //vlist = new ValidationList();
     enableOverride = false;
     readStreamHeader();
     bin.setBlockDataMode(true);
 }
Exemple #6
0
 public new StringBuilder append(boolean b)
 {
     base.append(b);
     return(this);
 }
 public new StringBuffer insert(int offset, boolean b)
 {
     return(insert(offset, String.valueOf(b)));
 }
 private int readBlockHeader(boolean canBlock)
 {
     //if (defaultDataEnd) {
     //    /*
     //     * Fix for 4360508: stream is currently at the end of a field
     //     * value block written via default serialization; since there
     //     * is no terminating TC_ENDBLOCKDATA tag, simulate
     //     * end-of-custom-data behavior explicitly.
     //     */
     //    return -1;
     //}
     try {
     for (;;) {
         int avail = canBlock ? Integer.MAX_VALUE : @in.available();
         if (avail == 0) {
             return HEADER_BLOCKED;
         }
         int tc = @in.peek();
         switch (tc) {
             case TC_BLOCKDATA:
                 if (avail < 2) {
                     return HEADER_BLOCKED;
                 }
                 @in.readFully(hbuf, 0, 2);
                 return hbuf[1] & 0xFF;
             case TC_BLOCKDATALONG:
                 if (avail < 5) {
                     return HEADER_BLOCKED;
                 }
                 @in.readFully(hbuf, 0, 5);
                 int len = Bits.getInt(hbuf, 1);
                 if (len < 0) {
                     throw new Exception(
                         "illegal block data header length: " +
                         len);
                 }
                 return len;
             /*
              * TC_RESETs may occur @in between data blocks.
              * Unfortunately, this case must be parsed at a lower
              * level than other typecodes, since primitive data
              * reads may span data blocks separated by a TC_RESET.
              */
             case TC_RESET:
                 throw new NotImplementedException();
                 //@in.read();
                 //handleReset();
                 //break;
             default:
                 if (tc >= 0 && (tc < TC_BASE || tc > TC_MAX)) {
                     throw new Exception();
                 }
                 return -1;
         }
     }
     } catch (Exception) {
     throw new Exception(
         "unexpected EOF while reading block data header");
     }
 }
Exemple #9
0
 public virtual AbstractStringBuilder insert(int offset, boolean b)
 {
     return(insert(offset, String.valueOf(b)));
 }
 public new /*synchronized*/ StringBuffer append(boolean b)
 {
     base.append(b);
     return(this);
 }
Exemple #11
0
        public String[] split(String regex, int limit)
        {
            /* fastpath if the regex is a
             * (1)one-char String and this character is not one of the
             *  RegEx's meta characters ".$|()[{^?*+\\", or
             * (2)two-char String and the first char is the backslash and
             *  the second is not the ascii digit or ascii letter.
             */
            char ch = (char)0;

            if (((regex.value.Length == 1 &&
                  new String(".$|()[{^?*+\\").indexOf(ch = regex.charAt(0)) == -1) ||
                 (regex.length() == 2 &&
                  regex.charAt(0) == '\\' &&
                  (((ch = regex.charAt(1)) - '0') | ('9' - ch)) < 0 &&
                  ((ch - 'a') | ('z' - ch)) < 0 &&
                  ((ch - 'A') | ('Z' - ch)) < 0)) &&
                (ch < Character.MIN_HIGH_SURROGATE ||
                 ch > Character.MAX_LOW_SURROGATE))
            {
                int                off     = 0;
                int                next    = 0;
                boolean            limited = limit > 0;
                ArrayList <String> list    = new ArrayList <String>();
                while ((next = indexOf(ch, off)) != -1)
                {
                    if (!limited || list.size() < limit - 1)
                    {
                        list.add(substring(off, next));
                        off = next + 1;
                    }
                    else    // last one
                    //assert (list.size() == limit - 1);
                    {
                        list.add(substring(off, value.Length));
                        off = value.Length;
                        break;
                    }
                }
                // If no match was found, return this
                if (off == 0)
                {
                    return new String[] { this }
                }
                ;

                // Add remaining segment
                if (!limited || list.size() < limit)
                {
                    list.add(substring(off, value.Length));
                }

                // Construct result
                int resultSize = list.size();
                if (limit == 0)
                {
                    while (resultSize > 0 && list.get(resultSize - 1).length() == 0)
                    {
                        resultSize--;
                    }
                }
                String[] result = new String[resultSize];
                return(list.subList(0, resultSize).toArray(result));
            }
            return(Pattern.compile(regex).split(this, limit));
        }
Exemple #12
0
 internal String(char[] value, boolean share)
 {
     this.value = value;
 }
Exemple #13
0
 public new StringBuilder insert(int offset, boolean b)
 {
     base.insert(offset, b);
     return(this);
 }
 public void readFully(byte[] b, int off, int len, boolean copy)
 {
     while (len > 0) {
     int n = read(b, off, len, copy);
     if (n < 0) {
         throw new Exception();
     }
     off += n;
     len -= n;
     }
 }
 protected Throwable(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace)
 {
     throw new RuntimeException("Stub!");
 }
 internal int read(byte[] b, int off, int len, boolean copy)
 {
     if (len == 0) {
     return 0;
     } else if (blkmode) {
     if (pos == end) {
         refill();
     }
     if (end < 0) {
         return -1;
     }
     int nread = Math.min(len, end - pos);
     System.Array.Copy(buf, pos, b, off, nread);
     pos += nread;
     return nread;
     } else if (copy) {
     int nread = @in.read(buf, 0, Math.min(len, MAX_BLOCK_SIZE));
     if (nread > 0) {
         System.Array.Copy(buf, 0, b, off, nread);
     }
     return nread;
     } else {
     return @in.read(b, off, len);
     }
 }
 public PhoneNumber clearNationalNumber()
 {
     _hasNationalNumber = false;
       nationalNumber_ = 0L;
       return this;
 }
 private Object readHandle(boolean unshared)
 {
     if (bin.readByte() != TC_REFERENCE) {
     throw new Exception();
     }
     passHandle = bin.readInt() - baseWireHandle;
     if (passHandle < 0 || passHandle >= handles.size()) {
     throw new Exception();
     }
     if (unshared) {
     // REMIND: what type of exception to throw here?
     throw new Exception(
         "cannot read back reference as unshared");
     }
     Object obj = handles.lookupObject(passHandle);
     if (obj == unsharedMarker) {
     // REMIND: what type of exception to throw here?
     throw new Exception(
         "cannot read back reference to unshared object");
     }
     return obj;
 }
 public PhoneNumber clearPreferredDomesticCarrierCode()
 {
     _hasPreferredDomesticCarrierCode = false;
       preferredDomesticCarrierCode_ = "";
       return this;
 }
 public Matcher useTransparentBounds(boolean b)
 {
     transparentBounds = b;
     return this;
 }
 public PhoneNumber clearRawInput()
 {
     _hasRawInput = false;
       rawInput_ = "";
       return this;
 }
 public static String toString(boolean b)
 {
     return(b ? new String("true") : new String("false"));
 }
 public PhoneNumber setCountryCode(int value)
 {
     _hasCountryCode = true;
       countryCode_ = value;
       return this;
 }
 public static int compare(boolean x, boolean y)
 {
     return((x == y) ? 0 : (x ? 1 : -1));
 }
 public PhoneNumber setCountryCodeSource(CountryCodeSource value)
 {
     //if (value == null) {
       //  throw new NullPointerException();
       //}
       _hasCountryCodeSource = true;
       countryCodeSource_ = value;
       return this;
 }
 public static int compare(boolean x, boolean y)
 {
     return (x == y) ? 0 : (x ? 1 : -1);
 }
 public PhoneNumber setExtension(String value)
 {
     if (value == null) {
     throw new NullPointerException();
       }
       _hasExtension = true;
       extension_ = value;
       return this;
 }
 public static boolean valueOf(boolean b)
 {
     return (b ? TRUE : FALSE);
 }
 public PhoneNumber setItalianLeadingZero(boolean value)
 {
     _hasItalianLeadingZero = true;
       italianLeadingZero_ = value;
       return this;
 }
 protected ObjectInputStream()
 {
     //SecurityManager sm = System.getSecurityManager();
     //if (sm != null) {
     //    sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
     //}
     bin = null;
     handles = null;
     //vlist = null;
     enableOverride = true;
 }
 public PhoneNumber setNationalNumber(long value)
 {
     _hasNationalNumber = true;
       nationalNumber_ = value;
       return this;
 }
 public override void close()
 {
     /*
      * Even if stream already closed, propagate redundant close to
      * underlying stream to stay consistent with previous implementations.
      */
     closed = true;
     if (depth == 0) {
     clear();
     }
     bin.close();
 }
 public PhoneNumber setPreferredDomesticCarrierCode(String value)
 {
     if (value == null) {
     throw new NullPointerException();
       }
       _hasPreferredDomesticCarrierCode = true;
       preferredDomesticCarrierCode_ = value;
       return this;
 }
 internal boolean setBlockDataMode(boolean newmode)
 {
     if (blkmode == newmode) {
     return blkmode;
     }
     if (newmode) {
     pos = 0;
     end = 0;
     unread = 0;
     } else if (pos < end) {
     throw new IllegalStateException("unread block data");
     }
     blkmode = newmode;
     return !blkmode;
 }
 public PhoneNumber setRawInput(String value)
 {
     if (value == null) {
     throw new NullPointerException();
       }
       _hasRawInput = true;
       rawInput_ = value;
       return this;
 }
 //public String readLine() {
 //    return din.readLine();      // deprecated, not worth optimizing
 //}
 /* -------------- primitive data array input methods --------------- */
 /*
  * The following methods read @in spans of primitive data values.
  * Though equivalent to calling the corresponding primitive read
  * methods repeatedly, these methods are optimized for reading groups
  * of primitive data values more efficiently.
  */
 void readBooleans(boolean[] v, int off, int len)
 {
     int stop, endoff = off + len;
     while (off < endoff) {
     if (!blkmode) {
         int span = Math.min(endoff - off, MAX_BLOCK_SIZE);
         @in.readFully(buf, 0, span);
         stop = off + span;
         pos = 0;
     } else if (end - pos < 1) {
         v[off++] = din.readBoolean();
         continue;
     } else {
         stop = Math.min(endoff, off + end - pos);
     }
     while (off < stop) {
         v[off++] = Bits.getBoolean(buf, pos++);
     }
     }
 }
 public virtual AbstractStringBuilder append(boolean b)
 {
     if (b) {
     ensureCapacityInternal(count + 4);
     value[count++] = 't';
     value[count++] = 'r';
     value[count++] = 'u';
     value[count++] = 'e';
     } else {
     ensureCapacityInternal(count + 5);
     value[count++] = 'f';
     value[count++] = 'a';
     value[count++] = 'l';
     value[count++] = 's';
     value[count++] = 'e';
     }
     return this;
 }
 //private Class readClass(boolean unshared) {
 //    if (bin.readByte() != TC_CLASS) {
 //        throw new Exception();
 //    }
 //    ObjectStreamClass desc = readClassDesc(false);
 //    Class cl = desc.forClass();
 //    passHandle = handles.assign(unshared ? unsharedMarker : cl);
 //    Exception resolveEx = desc.getResolveException();
 //    if (resolveEx != null) {
 //        handles.markException(passHandle, resolveEx);
 //    }
 //    handles.finish(passHandle);
 //    return cl;
 //}
 //private ObjectStreamClass readClassDesc(boolean unshared)
 //{
 //    byte tc = bin.peekByte();
 //    switch (tc) {
 //        case TC_NULL:
 //            return (ObjectStreamClass) readNull();
 //        case TC_REFERENCE:
 //            return (ObjectStreamClass) readHandle(unshared);
 //        case TC_PROXYCLASSDESC:
 //            return readProxyDesc(unshared);
 //        case TC_CLASSDESC:
 //            return readNonProxyDesc(unshared);
 //        default:
 //            throw new StreamCorruptedException(
 //                String.format("invalid type code: %02X", tc));
 //    }
 //}
 //private boolean isCustomSubclass() {
 //    // Return true if this class is a custom subclass of ObjectInputStream
 //    return getClass().getClassLoader()
 //                != ObjectInputStream.class.getClassLoader();
 //}
 //private ObjectStreamClass readProxyDesc(boolean unshared)
 //{
 //    if (bin.readByte() != TC_PROXYCLASSDESC) {
 //        throw new Exception();
 //    }
 //    ObjectStreamClass desc = new ObjectStreamClass();
 //    int descHandle = handles.assign(unshared ? unsharedMarker : desc);
 //    passHandle = NULL_HANDLE;
 //    int numIfaces = bin.readInt();
 //    String[] ifaces = new String[numIfaces];
 //    for (int i = 0; i < numIfaces; i++) {
 //        ifaces[i] = bin.readUTF();
 //    }
 //    Class cl = null;
 //    Exception resolveEx = null;
 //    bin.setBlockDataMode(true);
 //    try {
 //        if ((cl = resolveProxyClass(ifaces)) == null) {
 //            resolveEx = new Exception("null class");
 //        } else if (!Proxy.isProxyClass(cl)) {
 //            throw new InvalidClassException("Not a proxy");
 //        } else {
 //            // ReflectUtil.checkProxyPackageAccess makes a test
 //            // equivalent to isCustomSubclass so there's no need
 //            // to condition this call to isCustomSubclass == true here.
 //            ReflectUtil.checkProxyPackageAccess(
 //                    getClass().getClassLoader(),
 //                    cl.getInterfaces());
 //        }
 //    } catch (Exception ex) {
 //        resolveEx = ex;
 //    }
 //    skipCustomData();
 //    desc.initProxy(cl, resolveEx, readClassDesc(false));
 //    handles.finish(descHandle);
 //    passHandle = descHandle;
 //    return desc;
 //}
 //private ObjectStreamClass readNonProxyDesc(boolean unshared)
 //{
 //    if (bin.readByte() != TC_CLASSDESC) {
 //        throw new Exception();
 //    }
 //    ObjectStreamClass desc = new ObjectStreamClass();
 //    int descHandle = handles.assign(unshared ? unsharedMarker : desc);
 //    passHandle = NULL_HANDLE;
 //    ObjectStreamClass readDesc = null;
 //    try {
 //        readDesc = readClassDescriptor();
 //    } catch (Exception ex) {
 //        throw (IOException) new InvalidClassException(
 //            "failed to read class descriptor").initCause(ex);
 //    }
 //    Class cl = null;
 //    Exception resolveEx = null;
 //    bin.setBlockDataMode(true);
 //    readonly boolean checksRequired = isCustomSubclass();
 //    try {
 //        if ((cl = resolveClass(readDesc)) == null) {
 //            resolveEx = new Exception("null class");
 //        } else if (checksRequired) {
 //            ReflectUtil.checkPackageAccess(cl);
 //        }
 //    } catch (Exception ex) {
 //        resolveEx = ex;
 //    }
 //    skipCustomData();
 //    desc.initNonProxy(readDesc, cl, resolveEx, readClassDesc(false));
 //    handles.finish(descHandle);
 //    passHandle = descHandle;
 //    return desc;
 //}
 private String readString(boolean unshared)
 {
     String str;
     byte tc = bin.readByte();
     switch (tc) {
     case TC_STRING:
         str = bin.readUTF();
         break;
     case TC_LONGSTRING:
         throw new NotImplementedException();
         //str = bin.readLongUTF();
         //break;
     default:
         throw new Exception();
     }
     passHandle = handles.assign(unshared ? unsharedMarker : str);
     handles.finish(passHandle);
     return str;
 }
 public virtual AbstractStringBuilder insert(int offset, boolean b)
 {
     return insert(offset, String.valueOf(b));
 }
 public Matcher useAnchoringBounds(boolean b)
 {
     anchoringBounds = b;
     return this;
 }
 public static boolean valueOf(boolean b)
 {
     return(b ? TRUE : FALSE);
 }
 internal boolean search(int from)
 {
     this._hitEnd = false;
     this._requireEnd = false;
     from        = from < 0 ? 0 : from;
     this.first  = from;
     this.oldLast = oldLast < 0 ? from : oldLast;
     for (int i = 0; i < groups.Length; i++)
     groups[i] = -1;
     acceptMode = NOANCHOR;
     boolean result = parentPattern.root.match(this, from, text);
     if (!result)
     this.first = -1;
     this.oldLast = this.last;
     return result;
 }
        public static int parseInt(String s, int radix)
        {
            /*
             * WARNING: This method may be invoked early during VM initialization
             * before IntegerCache is initialized. Care must be taken to not use
             * the valueOf method.
             */
            if (s == null)
            {
                throw new NumberFormatException("null");
            }
            if (radix < Character.MIN_RADIX)
            {
                throw new NumberFormatException("radix " + radix +
                                                " less than Character.MIN_RADIX");
            }
            if (radix > Character.MAX_RADIX)
            {
                throw new NumberFormatException("radix " + radix +
                                                " greater than Character.MAX_RADIX");
            }
            int     result = 0;
            boolean negative = false;
            int     i = 0, len = s.length();
            int     limit = -Integer.MAX_VALUE;
            int     multmin;
            int     digit;

            if (len > 0)
            {
                char firstChar = s.charAt(0);
                if (firstChar < '0') // Possible leading "+" or "-"
                {
                    if (firstChar == '-')
                    {
                        negative = true;
                        limit    = Integer.MIN_VALUE;
                    }
                    else if (firstChar != '+')
                    {
                        throw NumberFormatException.forInputString(s);
                    }
                    if (len == 1) // Cannot have lone "+" or "-"
                    {
                        throw NumberFormatException.forInputString(s);
                    }
                    i++;
                }
                multmin = limit / radix;
                while (i < len)
                {
                    // Accumulating negatively avoids surprises near MAX_VALUE
                    digit = Character.digit(s.charAt(i++), radix);
                    if (digit < 0)
                    {
                        throw NumberFormatException.forInputString(s);
                    }
                    if (result < multmin)
                    {
                        throw NumberFormatException.forInputString(s);
                    }
                    result *= radix;
                    if (result < limit + digit)
                    {
                        throw NumberFormatException.forInputString(s);
                    }
                    result -= digit;
                }
            }
            else
            {
                throw NumberFormatException.forInputString(s);
            }
            return(negative ? result : -result);
        }