Examples of FastStringBuffer


Examples of net.sf.saxon.om.FastStringBuffer

        }
        SequenceIterator iter = select.iterate(context);
        if (!isAtomic) {
            iter = Atomizer.getAtomizingIterator(iter);
        }
        FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.SMALL);
        boolean first = true;
        String sep = " ";
        while (true) {
            Item item = iter.next();
            if (item==null) {
                break;
            }
            if (!first) {
                sb.append(sep);
            }
            first = false;
            sb.append(item.getStringValueCS());
        }
        if (first && noNodeIfEmpty) {
            return null;
        }
        return StringValue.makeStringValue(sb.condense());
    }
View Full Code Here

Examples of org.apache.xml.utils.FastStringBuffer

  {

    int s = v.size();

    // Just an initial guess at reasonable tuning parameters
    FastStringBuffer fsb = new FastStringBuffer(9,9);

    for (int i = 0; i < s; i++)
    {
      QName qname = (QName) v.elementAt(i);

      fsb.append(qname.toNamespacedString());
      // Don't append space after last value
      if (i < s-1)
        fsb.append(' ');
    }

    m_properties.put(key, fsb.toString());
  }
View Full Code Here

Examples of org.apache.xml.utils.FastStringBuffer

    if (null != s)
    {
      Vector v = new Vector();
      int l = s.length();
      boolean inCurly = false;
      FastStringBuffer buf = new FastStringBuffer();

      // parse through string, breaking on whitespaces.  I do this instead
      // of a tokenizer so I can track whitespace inside of curly brackets,
      // which theoretically shouldn't happen if they contain legal URLs.
      for (int i = 0; i < l; i++)
      {
        char c = s.charAt(i);

        if (Character.isWhitespace(c))
        {
          if (!inCurly)
          {
            if (buf.length() > 0)
            {
              QName qname = QName.getQNameFromString(buf.toString());
              v.addElement(qname);
              buf.reset();
            }
            continue;
          }
        }
        else if ('{' == c)
          inCurly = true;
        else if ('}' == c)
          inCurly = false;

        buf.append(c);
      }

      if (buf.length() > 0)
      {
        QName qname = QName.getQNameFromString(buf.toString());
        v.addElement(qname);
        buf.reset();
      }

      return v;
    }
    else
View Full Code Here

Examples of org.apache.xml.utils.FastStringBuffer

   *
   */
  public static String getNodeData(Node node)
  {

    FastStringBuffer buf = StringBufferPool.get();
    String s;

    try
    {
      getNodeData(node, buf);

      s = (buf.length() > 0) ? buf.toString() : "";
    }
    finally
    {
      StringBufferPool.free(buf);
    }
View Full Code Here

Examples of org.apache.xml.utils.FastStringBuffer

    if (DEBUG) System.out.println("getStringValue(" + nodeIdx + ")");

      Object o = m_ObjectArray.getAt(nodeIdx);
    if ( o == S_ELEMENT_NODE )
      {
        FastStringBuffer buf = StringBufferPool.get();
        String s;

        try
        {
          getNodeData(nodeIdx, buf);

          s = (buf.length() > 0) ? buf.toString() : "";
        }
        finally
        {
          StringBufferPool.free(buf);
        }
View Full Code Here

Examples of org.apache.xml.utils.FastStringBuffer

    // %TBD% If an element only has one text node, we should just use it
    // directly.
    if(DTM.ELEMENT_NODE == type || DTM.DOCUMENT_NODE == type
    || DTM.DOCUMENT_FRAGMENT_NODE == type)
    {
      FastStringBuffer buf = StringBufferPool.get();
      String s;
 
      try
      {
        getNodeData(node, buf);
 
        s = (buf.length() > 0) ? buf.toString() : "";
      }
      finally
      {
        StringBufferPool.free(buf);
      }
 
      return m_xstrf.newstr( s );
    }
    else if(TEXT_NODE == type || CDATA_SECTION_NODE == type)
    {
      // If this is a DTM text node, it may be made of multiple DOM text
      // nodes -- including navigating into Entity References. DOM2DTM
      // records the first node in the sequence and requires that we
      // pick up the others when we retrieve the DTM node's value.
      //
      // %REVIEW% DOM Level 3 is expected to add a "whole text"
      // retrieval method which performs this function for us.
      FastStringBuffer buf = StringBufferPool.get();
      while(node!=null)
      {
        buf.append(node.getNodeValue());
        node=logicalNextDOMTextNode(node);
      }
      String s=(buf.length() > 0) ? buf.toString() : "";
      StringBufferPool.free(buf);
      return m_xstrf.newstr( s );
    }
    else
      return m_xstrf.newstr( node.getNodeValue() );
View Full Code Here

Examples of org.exist.util.FastStringBuffer

        if (scale == 0) {
            return value.toString();
        } else if (scale < 0) {
            final String s = value.abs().unscaledValue().toString();

            final FastStringBuffer sb = new FastStringBuffer(s.length() + (-scale) + 2);
            if (value.signum() < 0) {
                sb.append('-');
            }
            sb.append(s);
            //Provisional hack : 10.0 mod 10.0 to trigger the bug
            if (!"0".equals(s)){
              for (int i=0; i<(-scale); i++) {
                  sb.append('0');
              }
            }
            return sb.toString();
        } else {
            final String s = value.abs().unscaledValue().toString();
            if ("0".equals(s)) {
                return s;
            }
            final int len = s.length();
            final FastStringBuffer sb = new FastStringBuffer(len+1);
            if (value.signum() < 0) {
                sb.append('-');
            }
            if (scale >= len) {
                sb.append("0.");
                for (int i=len; i<scale; i++) {
                    sb.append('0');
                }
                sb.append(s);
            } else {
                sb.append(s.substring(0, len-scale));
                sb.append('.');
                sb.append(s.substring(len-scale));
            }
            return sb.toString();
        }
        //End of copy
  }
View Full Code Here

Examples of org.pdf4j.saxon.om.FastStringBuffer

        }
        SequenceIterator iter = select.iterate(context);
        if (!isAtomic) {
            iter = Atomizer.getAtomizingIterator(iter);
        }
        FastStringBuffer sb = new FastStringBuffer(1024);
        boolean first = true;
        String sep = " ";
        while (true) {
            Item item = iter.next();
            if (item==null) {
                break;
            }
            if (!first) {
                sb.append(sep);
            }
            first = false;
            sb.append(item.getStringValueCS());
        }
        if (first && noNodeIfEmpty) {
            return null;
        }
        return StringValue.makeStringValue(sb.condense());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.