Package gnu.java.lang

Examples of gnu.java.lang.CPStringBuilder


  {
    /*
       This follows the algorithm in section 5.2.4. of RFC3986,
       but doesn't modify the input buffer.
    */
    CPStringBuilder input = new CPStringBuilder(relativePath);
    CPStringBuilder output = new CPStringBuilder();
    int start = 0;
    while (start < input.length())
      {
  /* A */
  if (input.indexOf("../",start) == start)
    {
      start += 3;
      continue;
    }
  if (input.indexOf("./",start) == start)
    {
      start += 2;
      continue;
    }
  /* B */
  if (input.indexOf("/./",start) == start)
    {
      start += 2;
      continue;
    }
  if (input.indexOf("/.",start) == start
      && input.charAt(start + 2) != '.')
    {
      start += 1;
      input.setCharAt(start,'/');
      continue;
    }
  /* C */
  if (input.indexOf("/../",start) == start)
    {
      start += 3;
      removeLastSegment(output);
      continue;
    }
  if (input.indexOf("/..",start) == start)
    {
      start += 2;
      input.setCharAt(start,'/');
      removeLastSegment(output);
      continue;
    }
  /* D */
  if (start == input.length() - 1 && input.indexOf(".",start) == start)
    {
      input.delete(0,1);
      continue;
    }
  if (start == input.length() - 2 && input.indexOf("..",start) == start)
    {
      input.delete(0,2);
      continue;
    }
  /* E */
  int indexOfSlash = input.indexOf("/",start);
  while (indexOfSlash == start)
    {
      output.append("/");
      ++start;
      indexOfSlash = input.indexOf("/",start);
    }
  if (indexOfSlash == -1)
    indexOfSlash = input.length();
  output.append(input.substring(start, indexOfSlash));
        start = indexOfSlash;
      }
    return output.toString();
  }
View Full Code Here


   *
   * @return The string.
   */
  public String toString()
  {
    CPStringBuilder str = new CPStringBuilder(X509CRLSelector.class.getName());
    String nl = SystemProperties.getProperty("line.separator");
    String eol = ";" + nl;

    str.append(" {").append(nl);
    if (issuerNames != null)
      str.append("  issuer names = ").append(issuerNames).append(eol);
    if (maxCrlNumber != null)
      str.append("  max CRL = ").append(maxCrlNumber).append(eol);
    if (minCrlNumber != null)
      str.append("  min CRL = ").append(minCrlNumber).append(eol);
    if (date != null)
      str.append("  date = ").append(date).append(eol);
    if (cert != null)
      str.append("  certificate = ").append(cert).append(eol);
    str.append("}").append(nl);
    return str.toString();
  }
View Full Code Here

      authority = this.authority;
      if (path == null)
        path = "";
      if (! (path.startsWith("/")))
        {
    CPStringBuilder basepath = new CPStringBuilder(this.path);
    int i = this.path.lastIndexOf('/');

    if (i >= 0)
      basepath.delete(i + 1, basepath.length());

    basepath.append(path);
    path = normalizePath(basepath.toString());
        }
    }
  return new URI(this.scheme, authority, path, query, fragment);
      }
    catch (URISyntaxException e)
View Full Code Here

   */
  public String toASCIIString()
  {
    String strRep = toString();
    boolean inNonAsciiBlock = false;
    CPStringBuilder buffer = new CPStringBuilder();
    CPStringBuilder encBuffer = null;
    for (int i = 0; i < strRep.length(); i++)
      {
  char c = strRep.charAt(i);
  if (c <= 127)
    {
      if (inNonAsciiBlock)
        {
    buffer.append(escapeCharacters(encBuffer.toString()));
    inNonAsciiBlock = false;
        }
      buffer.append(c);
    }
  else
    {
      if (!inNonAsciiBlock)
        {
    encBuffer = new CPStringBuilder();
    inNonAsciiBlock = true;
        }
      encBuffer.append(c);
    }
      }
    return buffer.toString();
  }
View Full Code Here

   */
  private static String escapeCharacters(String str)
  {
    try
      {
  CPStringBuilder sb = new CPStringBuilder();
  // this is far from optimal, but it works
  byte[] utf8 = str.getBytes("utf-8");
  for (int j = 0; j < utf8.length; j++)
    {
      sb.append('%');
      sb.append(HEX.charAt((utf8[j] & 0xff) / 16));
      sb.append(HEX.charAt((utf8[j] & 0xff) % 16));
    }
  return sb.toString();
      }
    catch (java.io.UnsupportedEncodingException x)
      {
  throw (Error) new InternalError("Escaping error").initCause(x);
      }
View Full Code Here

  protected Package definePackage(String name, Manifest manifest, URL url)
    throws IllegalArgumentException
  {
    // Compute the name of the package as it may appear in the
    // Manifest.
    CPStringBuilder xform = new CPStringBuilder(name);
    for (int i = xform.length () - 1; i >= 0; --i)
      if (xform.charAt(i) == '.')
  xform.setCharAt(i, '/');
    xform.append('/');
    String xformName = xform.toString();

    Attributes entryAttr = manifest.getAttributes(xformName);
    Attributes attr = manifest.getMainAttributes();

    String specTitle
View Full Code Here

  {
    synchronized (this)
      {
  if (thisString == null)
    {
      CPStringBuilder sb = new CPStringBuilder();
      sb.append(this.getClass().getName());
      sb.append("{urls=[" );
      URL[] thisURLs = getURLs();
      for (int i = 0; i < thisURLs.length; i++)
        {
    sb.append(thisURLs[i]);
    if (i < thisURLs.length - 1)
      sb.append(',');
        }
      sb.append(']');
      sb.append(", parent=");
      sb.append(getParent());
      sb.append('}');
      thisString = sb.toString();
    }
  return thisString;
      }
  }
View Full Code Here

     *
     * @return a <code>String</code> representation.
     */
    public String toString()
    {
      CPStringBuilder builder;

      builder = new CPStringBuilder(getClass().getName());
      builder.append("[field=");
      builder.append(field);
      builder.append(", size=");
      builder.append(size);
      builder.append(", character=");
      builder.append(character);
      builder.append("]");

      return builder.toString();
    }
View Full Code Here

   */
  public static String toString(boolean[] v)
  {
    if (v == null)
      return "null";
    CPStringBuilder b = new CPStringBuilder("[");
    for (int i = 0; i < v.length; ++i)
      {
  if (i > 0)
    b.append(", ");
  b.append(v[i]);
      }
    b.append("]");
    return b.toString();
  }
View Full Code Here

   */
  public static String toString(byte[] v)
  {
    if (v == null)
      return "null";
    CPStringBuilder b = new CPStringBuilder("[");
    for (int i = 0; i < v.length; ++i)
      {
  if (i > 0)
    b.append(", ");
  b.append(v[i]);
      }
    b.append("]");
    return b.toString();
  }
View Full Code Here

TOP

Related Classes of gnu.java.lang.CPStringBuilder

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.