Search in sources :

Example 1 with FastStr

use of org.osgl.util.FastStr in project actframework by actframework.

the class JsonDTOClassGenerator method typeDesc.

private static String typeDesc(BeanSpec spec) {
    String root = classDesc(spec.rawType());
    List<java.lang.reflect.Type> typeParams = spec.typeParams();
    if (typeParams.isEmpty()) {
        return root;
    }
    S.Buffer sb = S.newBuffer("<");
    for (java.lang.reflect.Type type : typeParams) {
        BeanSpec specx = BeanSpec.of(type, null, spec.injector());
        sb.append(typeDesc(specx));
    }
    sb.append(">");
    FastStr str = FastStr.of(root);
    str = str.take(str.length() - 1).append(sb.toString()).append(";");
    return str.toString();
}
Also used : FastStr(org.osgl.util.FastStr) S(org.osgl.util.S) BeanSpec(org.osgl.inject.BeanSpec)

Example 2 with FastStr

use of org.osgl.util.FastStr in project actframework by actframework.

the class DataObjectEnhancer method hashCodeMethodEnd.

static void hashCodeMethodEnd(MethodVisitor mv, int fieldCnt) {
    FastStr signature;
    if (fieldCnt < 6) {
        signature = FastStr.of("Ljava/lang/Object;").times(fieldCnt);
    } else {
        signature = FastStr.of("Ljava/lang/Object;").times(5).append("[Ljava/lang/Object;");
    }
    signature = signature.prepend("(").append(")I");
    mv.visitMethodInsn(INVOKESTATIC, "org/osgl/Osgl", "hc", signature.toString(), false);
    mv.visitInsn(IRETURN);
    // just pass any number and have ASM to calculate
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
Also used : FastStr(org.osgl.util.FastStr)

Example 3 with FastStr

use of org.osgl.util.FastStr in project actframework by actframework.

the class FileGetter method contentType.

static H.Format contentType(String path) {
    H.Format retVal = null;
    if (path.contains(".")) {
        FastStr s = FastStr.unsafeOf(path).afterLast('.');
        retVal = H.Format.of(s.toString());
    }
    return null == retVal ? H.Format.BINARY : retVal;
}
Also used : FastStr(org.osgl.util.FastStr) H(org.osgl.http.H)

Example 4 with FastStr

use of org.osgl.util.FastStr in project actframework by actframework.

the class ActTestBase method root.

public static File root() {
    FastStr fs = FastStr.of(ActTestBase.class.getClassLoader().getResource("routes").getPath());
    FastStr classRoot = fs.beforeLast("/");
    FastStr target = classRoot.beforeLast("/");
    return new File(target.toString());
}
Also used : FastStr(org.osgl.util.FastStr) File(java.io.File)

Example 5 with FastStr

use of org.osgl.util.FastStr in project actframework by actframework.

the class FastJsonPropertyPreFilter method apply.

@Override
public boolean apply(JSONSerializer serializer, Object source, String name) {
    if (source == null) {
        return true;
    }
    // if context path is "$.bar.zee" or "$[0].bar.zee" and name is "foo"
    // then path should be "bar.zee.foo"
    String path;
    FastStr fs = FastStr.of(serializer.getContext().toString()).append('.').append(name);
    // skip the first "."
    path = fs.substring(fs.indexOf('.') + 1);
    return matches(path);
}
Also used : FastStr(org.osgl.util.FastStr)

Aggregations

FastStr (org.osgl.util.FastStr)5 File (java.io.File)1 H (org.osgl.http.H)1 BeanSpec (org.osgl.inject.BeanSpec)1 S (org.osgl.util.S)1