public void characters(char[] ch, int offset, int length) throws SAXException {
    if (_size >= _textArray.length) {
      String[] newTextArray = new String[_textArray.length * 2];
      System.arraycopy(_textArray, 0, newTextArray, 0, _textArray.length);
      _textArray = newTextArray;
    }

    if (!_escaping) {
      if (_dontEscape == null) {
        _dontEscape = new BitArray(8);
      }

      if (_size >= _dontEscape.size()) _dontEscape.resize(_dontEscape.size() * 2);

      _dontEscape.setBit(_size);
    }

    _textArray[_size++] = new String(ch, offset, length);
  }
Ejemplo n.º 2
0
 @Override
 public <T> void put(T object, Funnel<? super T> funnel, int numHashFunctions, BitArray bits) {
   // TODO(user): when the murmur's shortcuts are implemented, update this code
   long hash64 = Hashing.murmur3_128().newHasher().putObject(object, funnel).hash().asLong();
   int hash1 = (int) hash64;
   int hash2 = (int) (hash64 >>> 32);
   for (int i = 1; i <= numHashFunctions; i++) {
     int nextHash = hash1 + i * hash2;
     if (nextHash < 0) {
       nextHash = ~nextHash;
     }
     // up to here, the code is identical with the next method
     bits.set(nextHash % bits.size());
   }
 }
  public void characters(String str) throws SAXException {
    // Resize the text array if necessary
    if (_size >= _textArray.length) {
      String[] newTextArray = new String[_textArray.length * 2];
      System.arraycopy(_textArray, 0, newTextArray, 0, _textArray.length);
      _textArray = newTextArray;
    }

    // If the escape setting is false, set the corresponding bit in
    // the _dontEscape BitArray.
    if (!_escaping) {
      // The _dontEscape array is only created when needed.
      if (_dontEscape == null) {
        _dontEscape = new BitArray(8);
      }

      // Resize the _dontEscape array if necessary
      if (_size >= _dontEscape.size()) _dontEscape.resize(_dontEscape.size() * 2);

      _dontEscape.setBit(_size);
    }

    _textArray[_size++] = str;
  }
Ejemplo n.º 4
0
 @Override
 public <T> boolean mightContain(
     T object, Funnel<? super T> funnel, int numHashFunctions, BitArray bits) {
   long hash64 = Hashing.murmur3_128().newHasher().putObject(object, funnel).hash().asLong();
   int hash1 = (int) hash64;
   int hash2 = (int) (hash64 >>> 32);
   for (int i = 1; i <= numHashFunctions; i++) {
     int nextHash = hash1 + i * hash2;
     if (nextHash < 0) {
       nextHash = ~nextHash;
     }
     // up to here, the code is identical with the previous method
     if (!bits.get(nextHash % bits.size())) {
       return false;
     }
   }
   return true;
 }