Exemplo n.º 1
0
 /**
  * Converts the {@code NumericShaper.Range} enum-based parameters, if any, to the bit mask-based
  * counterparts and writes this object to the {@code stream}. Any enum constants that have no bit
  * mask-based counterparts are ignored in the conversion.
  *
  * @param stream the output stream to write to
  * @throws IOException if an I/O error occurs while writing to {@code stream}
  * @since 1.7
  */
 private void writeObject(ObjectOutputStream stream) throws IOException {
   if (shapingRange != null) {
     int index = Range.toRangeIndex(shapingRange);
     if (index >= 0) {
       key = index;
     }
   }
   if (rangeSet != null) {
     mask |= Range.toRangeMask(rangeSet);
   }
   stream.defaultWriteObject();
 }
Exemplo n.º 2
0
  /**
   * Converts the digits in the text that occur between {@code start} and {@code start + count},
   * using the provided {@code context}. {@code Context} is ignored if the shaper is not a
   * contextual shaper.
   *
   * @param text a {@code char} array
   * @param start the index into {@code text} to start converting
   * @param count the number of {@code char}s in {@code text} to convert
   * @param context the context to which to convert the characters, such as {@code
   *     NumericShaper.Range.EUROPEAN}
   * @throws IndexOutOfBoundsException if {@code start} or {@code start + count} is out of bounds
   * @throws NullPointerException if {@code text} or {@code context} is null
   * @since 1.7
   */
  public void shape(char[] text, int start, int count, Range context) {
    checkParams(text, start, count);
    if (context == null) {
      throw new NullPointerException("context is null");
    }

    if (isContextual()) {
      if (rangeSet != null) {
        shapeContextually(text, start, count, context);
      } else {
        int key = Range.toRangeIndex(context);
        if (key >= 0) {
          shapeContextually(text, start, count, key);
        } else {
          shapeContextually(text, start, count, shapingRange);
        }
      }
    } else {
      shapeNonContextually(text, start, count);
    }
  }