Package org.apache.abdera.util.io

Examples of org.apache.abdera.util.io.CodepointIterator


    String source,
    Form form,
    StringBuffer buf)
      throws IOException {
      StringBuffer internal = new StringBuffer();
      CodepointIterator ci = CodepointIterator.forCharSequence(source);
      boolean canonical = form.isCanonical();
      while (ci.hasNext()) {
        int c = ci.next();
        internal.setLength(0);
        ucd.decompose(c, canonical, internal);
        CodepointIterator ii = CodepointIterator.forCharSequence(internal);
        while(ii.hasNext()) {
          int ch = ii.next();
          int i = findInsertionPoint(ucd, buf, ch);
          buf.insert(i,CharUtils.toString(ch));
        }
      }
   
View Full Code Here


  public static StringBuffer encode(
    char[] chars,
    boolean[] case_flags)
      throws IOException {
    StringBuffer buf = new StringBuffer();
    CodepointIterator ci = CodepointIterator.forCharArray(chars);
    int n, delta, h, b, bias, m, q, k, t;
    n = initial_n;
    delta = 0;
    bias = initial_bias;
    int i = -1;
    while (ci.hasNext()) {
      i = ci.next();
      if (basic(i)) {
        if (case_flags != null) {
        } else {
          buf.append((char)i);
        }
      }
    }
    h = b = buf.length();
    if (b > 0) buf.append((char)delimiter);
    while (h < chars.length) {
      ci.position(0);
      i = -1;
      m = Integer.MAX_VALUE;
      while(ci.hasNext()) {
        i = ci.next();
        if (i >= n && i < m) m = i;
      }
      if (m - n > (Integer.MAX_VALUE - delta) / (h + 1))
        throw new IOException("Overflow");
      delta += (m-n) * (h+1);
      n = m;
      ci.position(0);
      i = -1;
      while (ci.hasNext()) {
        i = ci.next();
        if (i < n) {
          if (++delta == 0) throw new IOException("Overflow");
        }
        if (i == n) {
          for (q = delta, k = base;; k+= base) {
            t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
            if (q < t) break;
            buf.append((char)encode_digit(t+(q-t)%(base-t),false));
            q = (q-t) / (base-t);
          }
          buf.append((char)encode_digit(
            q, (case_flags!=null)?case_flags[ci.position()-1]:false));
          bias = adapt(delta,h+1,h==b);
          delta=0;
          ++h;
        }
      }
View Full Code Here

  public static String prep(String s, boolean allowunassigned) {
    NameprepCodepointIterator r = null;
    try {
      StringBuffer buf = new StringBuffer();
      CodepointIterator ci = CodepointIterator.forCharSequence(s);
      r = new NameprepCodepointIterator(ci,allowunassigned);
      while(r.hasNext()) {
        int i = r.next();
        if (i != -1)
        buf.append((char)i);
View Full Code Here

TOP

Related Classes of org.apache.abdera.util.io.CodepointIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.