isValidCodePoint() private méthode

private isValidCodePoint ( int par0 ) : bool
par0 int
Résultat bool
Exemple #1
0
        public String(int[] codePoints, int offset, int count)
        {
            if (offset < 0)
            {
                throw new IndexOutOfRangeException();
            }
            if (count < 0)
            {
                throw new IndexOutOfRangeException();
            }
            // Note: offset or count might be near -1>>>1.
            if (offset > codePoints.Length - count)
            {
                throw new IndexOutOfRangeException();
            }

            int end = offset + count;

            // Pass 1: Compute precise size of char[]
            int n = count;

            for (int i = offset; i < end; i++)
            {
                int c = codePoints[i];
                if (Character.isBmpCodePoint(c))
                {
                    continue;
                }
                else if (Character.isValidCodePoint(c))
                {
                    n++;
                }
                else
                {
                    throw new IllegalArgumentException();
                }
            }

            // Pass 2: Allocate and fill in char[]
            char[] v = new char[n];

            for (int i = offset, j = 0; i < end; i++, j++)
            {
                int c = codePoints[i];
                if (Character.isBmpCodePoint(c))
                {
                    v[j] = (char)c;
                }
                else
                {
                    Character.toSurrogates(c, v, j++);
                }
            }

            this.value = v;
        }
Exemple #2
0
 private int lastIndexOfSupplementary(int ch, int fromIndex)
 {
     if (Character.isValidCodePoint(ch))
     {
         char[] value = this.value;
         char   hi    = Character.highSurrogate(ch);
         char   lo    = Character.lowSurrogate(ch);
         int    i     = Math.min(fromIndex, value.Length - 2);
         for (; i >= 0; i--)
         {
             if (value[i] == hi && value[i + 1] == lo)
             {
                 return(i);
             }
         }
     }
     return(-1);
 }
Exemple #3
0
 private int indexOfSupplementary(int ch, int fromIndex)
 {
     if (Character.isValidCodePoint(ch))
     {
         char[] value = this.value;
         char   hi    = Character.highSurrogate(ch);
         char   lo    = Character.lowSurrogate(ch);
         int    max   = value.Length - 1;
         for (int i = fromIndex; i < max; i++)
         {
             if (value[i] == hi && value[i + 1] == lo)
             {
                 return(i);
             }
         }
     }
     return(-1);
 }
Exemple #4
0
        public virtual AbstractStringBuilder appendCodePoint(int codePoint)
        {
            int count = this.count;

            if (Character.isBmpCodePoint(codePoint))
            {
                ensureCapacityInternal(count + 1);
                value[count] = (char)codePoint;
                this.count   = count + 1;
            }
            else if (Character.isValidCodePoint(codePoint))
            {
                ensureCapacityInternal(count + 2);
                Character.toSurrogates(codePoint, value, count);
                this.count = count + 2;
            }
            else
            {
                throw new IllegalArgumentException();
            }
            return(this);
        }