Example usage for io.netty.util AsciiString hashCode

List of usage examples for io.netty.util AsciiString hashCode

Introduction

In this page you can find the example usage for io.netty.util AsciiString hashCode.

Prototype

public static int hashCode(CharSequence value) 

Source Link

Document

Returns the case-insensitive hash code of the specified string.

Usage

From source file:io.vertx.core.http.impl.headers.VertxHttpHeaders.java

License:Open Source License

@Override
public VertxHttpHeaders add(CharSequence name, CharSequence value) {
    int h = AsciiString.hashCode(name);
    int i = index(h);
    add0(h, i, name, value);/* ww  w  .j a va  2  s  .c o  m*/
    return this;
}

From source file:io.vertx.core.http.impl.headers.VertxHttpHeaders.java

License:Open Source License

@Override
public VertxHttpHeaders add(CharSequence name, Iterable values) {
    int h = AsciiString.hashCode(name);
    int i = index(h);
    for (Object vstr : values) {
        add0(h, i, name, (String) vstr);
    }/*  ww w. j a  v a  2 s.  co  m*/
    return this;
}

From source file:io.vertx.core.http.impl.headers.VertxHttpHeaders.java

License:Open Source License

@Override
public VertxHttpHeaders remove(CharSequence name) {
    Objects.requireNonNull(name, "name");
    int h = AsciiString.hashCode(name);
    int i = index(h);
    remove0(h, i, name);/*from   w  w  w.  j  av  a 2  s.c  o m*/
    return this;
}

From source file:io.vertx.core.http.impl.headers.VertxHttpHeaders.java

License:Open Source License

@Override
public VertxHttpHeaders set(CharSequence name, Iterable values) {
    Objects.requireNonNull(values, "values");

    int h = AsciiString.hashCode(name);
    int i = index(h);

    remove0(h, i, name);/* ww  w .  jav a  2s .  c  om*/
    for (Object v : values) {
        if (v == null) {
            break;
        }
        add0(h, i, name, (String) v);
    }

    return this;
}

From source file:io.vertx.core.http.impl.headers.VertxHttpHeaders.java

License:Open Source License

@Override
public boolean contains(CharSequence name, CharSequence value, boolean ignoreCase) {
    int h = AsciiString.hashCode(name);
    int i = index(h);
    VertxHttpHeaders.MapEntry e = entries[i];
    HashingStrategy<CharSequence> strategy = ignoreCase ? CASE_INSENSITIVE_HASHER : CASE_SENSITIVE_HASHER;
    while (e != null) {
        if (e.hash == h && AsciiString.contentEqualsIgnoreCase(name, e.key)) {
            if (strategy.equals(value, e.getValue())) {
                return true;
            }/*www  . j a  v a  2s.co m*/
        }
        e = e.next;
    }
    return false;
}

From source file:io.vertx.core.http.impl.headers.VertxHttpHeaders.java

License:Open Source License

@Override
public List<String> getAll(CharSequence name) {
    Objects.requireNonNull(name, "name");

    LinkedList<String> values = new LinkedList<>();

    int h = AsciiString.hashCode(name);
    int i = index(h);
    VertxHttpHeaders.MapEntry e = entries[i];
    while (e != null) {
        if (e.hash == h && AsciiString.contentEqualsIgnoreCase(name, e.key)) {
            values.addFirst(e.getValue().toString());
        }//from w w w  . j a v  a  2  s. co  m
        e = e.next;
    }
    return values;
}

From source file:io.vertx.core.http.impl.headers.VertxHttpHeaders.java

License:Open Source License

private VertxHttpHeaders set0(final CharSequence name, final CharSequence strVal) {
    int h = AsciiString.hashCode(name);
    int i = index(h);
    remove0(h, i, name);//from w w w .  j  a  v  a  2  s.c  o m
    add0(h, i, name, strVal);
    return this;
}

From source file:io.vertx.core.http.impl.headers.VertxHttpHeaders.java

License:Open Source License

private CharSequence get0(CharSequence name) {
    int h = AsciiString.hashCode(name);
    int i = index(h);
    VertxHttpHeaders.MapEntry e = entries[i];
    while (e != null) {
        if (e.hash == h && AsciiString.contentEqualsIgnoreCase(name, e.key)) {
            return e.getValue();
        }/* w ww  .j  a  va2s  .  c  o  m*/
        e = e.next;
    }
    return null;
}

From source file:io.vertx.core.http.VertxHttpHeadersTest.java

License:Open Source License

@Override
public void checkNameCollision() {
    assertEquals(AsciiString.hashCode(sameHash1), AsciiString.hashCode(sameHash2));
    assertEquals(AsciiString.hashCode(sameBucket1) & 0xF, AsciiString.hashCode(sameBucket2) & 0xF);
    assertNotEquals(AsciiString.hashCode(sameBucket1), AsciiString.hashCode(sameBucket2));
}