Java Code Examples for org.osgl.util.S#concat()

The following examples show how to use org.osgl.util.S#concat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleBean.java    From actframework with Apache License 2.0 6 votes vote down vote up
private void addSetter(Map.Entry<String, $.T2<String, String>> field) {
    String name = field.getKey();
    if (metaInfo.isSensitive(name) || null != passwordMetaInfo && passwordMetaInfo.isPasswordField(name)) {
        return;
    }
    String desc = field.getValue()._1;
    String signature = field.getValue()._2;

    if (null != signature) {
        signature = S.concat("(", signature, ")V");
    }
    MethodVisitor mv = visitMethod(ACC_PUBLIC, setterName(name), S.concat("(", desc, ")V"), signature, null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitVarInsn(loadCode(desc), 1);
    mv.visitFieldInsn(PUTFIELD, classDesc, name, desc);
    mv.visitInsn(RETURN);
    if (_D == desc.hashCode() || _J == desc.hashCode()) {
        mv.visitMaxs(3, 3);
    } else {
        mv.visitMaxs(2, 2);
    }
    mv.visitEnd();
}
 
Example 2
Source File: MailerConfig.java    From actframework with Apache License 2.0 6 votes vote down vote up
private String getProperty(String key, Map<String, String> properties) {
    String key0 = key;
    key = S.concat("mailer.", id, ".", key);
    String val = properties.get(key);
    if (null != val) {
        return val;
    }
    String key2 = "act." + key;
    val = properties.get(key2);
    if (null != val) {
        return val;
    }
    if (isDefault) {
        key = S.concat("mailer.", key0);
        val = properties.get(key);
        if (null != val) {
            return val;
        }
        return properties.get(S.concat("act.", key));
    } else {
        return null;
    }
}
 
Example 3
Source File: Tags.java    From actframework with Apache License 2.0 6 votes vote down vote up
protected void call(String path) {
    if (path.startsWith("http:") || path.startsWith("//")) {
        // we don't process absolute path
        p(path);
        return;
    }
    if (Act.isDev()) {
        if (!path.startsWith("/")) {
            path = '/' + path;
        }
        path = path + (path.contains("?") ? '&' : '?');
        path = path + "ts=" + $.ms();
    } else {
        String checksum = checksumManager.checksumOf(path);
        if (!path.startsWith("/")) {
            path = '/' + path;
        }
        if (S.notBlank(checksum)) {
            String sep = path.contains("?") ? "&" : "?";
            path = S.concat(path, sep, "checksum=", checksum);
        }
    }
    p(path);
}
 
Example 4
Source File: SimpleBean.java    From actframework with Apache License 2.0 6 votes vote down vote up
private void addGetter(Map.Entry<String, $.T2<String, String>> field) {
    String name = field.getKey();
    if (metaInfo.isSensitive(name)) {
        return;
    }
    String desc = field.getValue()._1;
    String signature = field.getValue()._2;
    if (null != signature) {
        signature = S.concat("()", signature);
    }

    MethodVisitor mv = visitMethod(ACC_PUBLIC, getterName(name, MetaInfo.isBoolean(desc)), S.concat("()", desc), signature, null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, classDesc, name, desc);
    mv.visitInsn(returnCode(desc));
    if (_D == desc.hashCode() || _J == desc.hashCode()) {
        mv.visitMaxs(2, 1);
    } else {
        mv.visitMaxs(1, 1);
    }
    mv.visitEnd();
}
 
Example 5
Source File: StringSecureTicketCodec.java    From actframework with Apache License 2.0 5 votes vote down vote up
private $.T2<String, String> decode(String payloadItem) {
    int pos = payloadItem.indexOf('=');
    if (pos < 0) {
        throw new IllegalArgumentException(S.concat("Invalid payload item: ", payloadItem));
    }
    return $.T2(payloadItem.substring(0, pos), payloadItem.substring(pos + 1, payloadItem.length()));
}
 
Example 6
Source File: RythmView.java    From actframework with Apache License 2.0 5 votes vote down vote up
@Transformer
public static RawData errorLine(String data, int errorColumn) {
    String line = S.string(data);
    if (errorColumn > -1 && errorColumn < line.length()) {
        String a = line.substring(0, errorColumn);
        char c = line.charAt(errorColumn);
        String b = line.substring(errorColumn + 1);
        line = S.concat(a, "<span_class='error-column'>", c, "</span>", b);
        line = S.replace(" ").with("&nbsp;").in(line);
        line = S.replace("span_class").with("span class").in(line);
    } else {
        line = S.replace(" ").with("&nbsp;").in(line);
    }
    return new RawData(line);
}
 
Example 7
Source File: CSRFProtector.java    From actframework with Apache License 2.0 5 votes vote down vote up
@Override
public String generateToken(H.Session session, App app) {
    String id = session.id();
    String username = session.get(app.config().sessionKeyUsername());
    String payload = S.concat(id, username);
    String sign = app.sign(payload);
    return S.concat(payload, "-", sign);
}
 
Example 8
Source File: ActErrorPageRender.java    From actframework with Apache License 2.0 5 votes vote down vote up
private String jsonContent(ErrorResult error, Integer errorCode, String errorMsg) {
    Object payload = error.attachment();
    if (null != payload) {
        return com.alibaba.fastjson.JSON.toJSONString(payload);
    }
    errorMsg = StringEscapeUtils.escapeJson(errorMsg);
    if (null == errorCode) {
        return S.concat("{\"ts\":", $.ms(),  ",\"message\":\"", errorMsg, "\"}");
    } else {
        return S.concat("{\"ts\":", $.ms(), ",\"code\":", S.string(errorCode), ",\"message\":\"", errorMsg, "\"}");
    }
}
 
Example 9
Source File: HMAC.java    From actframework with Apache License 2.0 5 votes vote down vote up
public boolean verifyHash(String content, String hash) {
    int len = hash.length();
    int padding = 4 - len % 4;
    if (padding > 0) {
        hash = S.concat(hash, S.times(Codec.URL_SAFE_BASE64_PADDING_CHAR, padding));
    }
    byte[] yourHash = Codec.decodeUrlSafeBase64(hash);
    return verifyHash(content.getBytes(UTF_8), yourHash);
}
 
Example 10
Source File: ImplicitVariableProvider.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return S.concat("Template variable provider: ", className, "::", methodName);
}
 
Example 11
Source File: JsonParamValueLoader.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return S.concat("json param|", fallBack);
}
 
Example 12
Source File: ParamValueLoader.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return S.concat("nil loader[", bindName(), "]");
}
 
Example 13
Source File: ProvidedValueLoader.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return S.concat("provided loader[", bindName(), "|", beanSpec.rawType().getSimpleName(), "]");
}
 
Example 14
Source File: JobTrigger.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return S.concat("after ", targetId);
}
 
Example 15
Source File: JobTrigger.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return S.concat("delay %ss after ", delayInSeconds, targetId);
}
 
Example 16
Source File: ZaiJianService.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
public String bye(String who) {
    return S.concat(who, " 再见");
}
 
Example 17
Source File: FieldLoader.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return S.concat("field loader|", loader);
}
 
Example 18
Source File: ArithmeticGenerator.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return S.concat(first, o1, second, o2, third, " = ?");
}
 
Example 19
Source File: StringSecureTicketCodec.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
protected String serialize(String id, Map<String, String> payload) {
    String tk = crypto.generateToken(id, encode(payload));
    return S.concat(MARKER, tk);
}
 
Example 20
Source File: UrlProvider.java    From actframework with Apache License 2.0 4 votes vote down vote up
@Override
public String get() {
    return S.concat("https://", hostProvider.get(), "/...");
}