本文整理汇总了Java中org.osgl.util.S.newBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java S.newBuffer方法的具体用法?Java S.newBuffer怎么用?Java S.newBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgl.util.S
的用法示例。
在下文中一共展示了S.newBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveWithContextMethodPath
import org.osgl.util.S; //导入方法依赖的package包/类
public final String resolveWithContextMethodPath(ActContext context) {
String methodPath = context.methodPath();
String path = context.templatePath();
String[] sa = path.split("\\.");
int level = sa.length + 1;
S.Buffer sb;
if (S.notBlank(methodPath)) {
while (--level > 0) {
methodPath = S.beforeLast(methodPath, ".");
}
sb = S.newBuffer(methodPath);
} else {
sb = S.newBuffer();
}
if (!path.startsWith("/")) {
sb.append("/");
}
path = sb.append(path).toString().replace('.', '/');
return resolveTemplatePath(path, context);
}
示例2: toStrBuffer
import org.osgl.util.S; //导入方法依赖的package包/类
@Override
protected S.Buffer toStrBuffer(S.Buffer sb) {
S.Buffer prependix = S.newBuffer();
if (0 != priority) {
prependix.append("p[")
.append(priority).append("] ");
}
if (!whiteList.isEmpty()) {
prependix.append("+").append(whiteList).append(" ");
}
if (!blackList.isEmpty()) {
prependix.append("-").append(blackList).append(" ");
}
return super.toStrBuffer(sb).prepend(prependix);
}
示例3: templateContext
import org.osgl.util.S; //导入方法依赖的package包/类
public String templateContext() {
if (null != parent) {
if (S.notBlank(templateContext) && templateContext.length() > 1 && templateContext.startsWith("/")) {
return templateContext;
}
String parentContextPath = parent.templateContext();
if (null == templateContext) {
return parentContextPath;
}
if (null == parentContextPath) {
return templateContext;
}
S.Buffer sb = S.newBuffer(parentContextPath);
if (parentContextPath.endsWith("/")) {
sb.deleteCharAt(sb.length() - 1);
}
if (!templateContext.startsWith("/")) {
sb.append("/");
}
sb.append(templateContext);
return sb.toString();
}
return templateContext;
}
示例4: urlContext
import org.osgl.util.S; //导入方法依赖的package包/类
public String urlContext() {
if (null != parent) {
if (S.notBlank(urlContext) && urlContext.length() > 1 && urlContext.startsWith("/")) {
return urlContext;
}
String parentContextPath = parent.urlContext();
if (null == urlContext) {
return parentContextPath;
}
if (null == parentContextPath) {
return urlContext;
}
S.Buffer sb = S.newBuffer(parentContextPath);
if (parentContextPath.endsWith("/")) {
sb.deleteCharAt(sb.length() - 1);
}
if (!urlContext.startsWith("/")) {
sb.append("/");
}
sb.append(urlContext);
return sb.toString();
}
return urlContext;
}
示例5: typeDesc
import org.osgl.util.S; //导入方法依赖的package包/类
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();
}
示例6: toString
import org.osgl.util.S; //导入方法依赖的package包/类
@Override
public String toString() {
S.Buffer sb = S.newBuffer();
sb.append(_invokeType())
.append(_return())
.append(fullName());
return sb.toString();
}
示例7: resolveFromCookieContent
import org.osgl.util.S; //导入方法依赖的package包/类
private void resolveFromCookieContent(H.KV<?> kv, String content, boolean isSession) {
String data = Codec.decodeUrl(content, Charsets.UTF_8);
if (isSession) {
if (encryptSession) {
try {
data = app.decrypt(data);
} catch (Exception e) {
return;
}
}
int firstDashIndex = data.indexOf("-");
if (firstDashIndex < 0) {
return;
}
String sign = data.substring(0, firstDashIndex);
data = data.substring(firstDashIndex + 1);
String sign1 = app.sign(data);
if (!sign.equals(sign1)) {
return;
}
}
List<char[]> pairs = split(data.toCharArray(), '\u0000');
if (pairs.isEmpty()) return;
for (char[] pair: pairs) {
List<char[]> kAndV = split(pair, '\u0001');
int sz = kAndV.size();
if (sz != 2) {
S.Buffer sb = S.newBuffer();
for (int i = 0; i < sz; ++i) {
if (i > 0) sb.append(":");
sb.append(Arrays.toString(kAndV.get(i)));
}
warn("unexpected KV string: %S", sb.toString());
} else {
kv.put(new String(kAndV.get(0)), new String(kAndV.get(1)));
}
}
}
示例8: toString
import org.osgl.util.S; //导入方法依赖的package包/类
@Override
public String toString() {
S.Buffer sb = S.newBuffer();
sb.append(_invokeType())
.append(_return())
.append(fullName())
.append("(")
.append(_params())
.append(")");
return sb.toString();
}
示例9: registerOnContext
import org.osgl.util.S; //导入方法依赖的package包/类
private void registerOnContext(String ctxPath, String action) {
S.Buffer sb = S.newBuffer();
if (paths.isEmpty()) {
paths.add("");
}
for (Router r : routers) {
for (String urlPath : paths) {
if (!urlPath.startsWith("/")) {
if (!(S.blank(ctxPath) || "/".equals(ctxPath))) {
if (ctxPath.endsWith("/")) {
ctxPath = ctxPath.substring(0, ctxPath.length() - 1);
}
sb.setLength(0);
sb.append(ctxPath);
if (!urlPath.startsWith("/")) {
sb.append("/");
}
sb.append(urlPath);
urlPath = sb.toString();
}
}
for (H.Method m : httpMethods) {
try {
r.addMapping(m, urlPath, action, RouteSource.ACTION_ANNOTATION);
} catch (RuntimeException e) {
logger.error(e, "add router mapping failed: \n\tmethod[%s]\n\turl path: %s\n\taction: %s", m, urlPath, action);
}
}
}
}
}
示例10: base
import org.osgl.util.S; //导入方法依赖的package包/类
private String base(String actionPath) {
S.Buffer buffer = S.newBuffer();
String[] sa = actionPath.split("\\.");
for (String s : sa) {
buffer.append(s.charAt(0));
}
buffer.append(actionPath.hashCode());
return buffer.toString();
}
示例11: apply
import org.osgl.util.S; //导入方法依赖的package包/类
@Override
public String apply(ActionContext context) throws NotAppliedException, Osgl.Break {
TreeMap<String, String> keyValues = keyValues(context);
S.Buffer buffer = S.newBuffer(base);
for (Map.Entry<String, String> entry : keyValues.entrySet()) {
buffer.append("-").append(entry.getKey()).append(":").append(entry.getValue());
}
buffer.append(context.userAgent().isMobile() ? "M" : "B");
return buffer.toString();
}
示例12: Base
import org.osgl.util.S; //导入方法依赖的package包/类
protected Base(App app, boolean noLogger) {
super(noLogger);
E.NPE(app);
this.app = app;
renderArgs = new HashMap<>();
attributes = new HashMap<>();
listenerList = new ArrayList<>();
destroyableList = new ArrayList<>();
strBuf = S.newBuffer();
violations = new HashMap<>();
}
示例13: genId
import org.osgl.util.S; //导入方法依赖的package包/类
/**
* Generate a unique ID across the cluster
* @return generated ID
*/
public String genId() {
S.Buffer sb = S.newBuffer();
sb.a(longEncoder.longToStr(nodeIdProvider.nodeId()))
.a(longEncoder.longToStr(startIdProvider.startId()))
.a(longEncoder.longToStr(sequenceProvider.seqId()));
return sb.toString();
}
示例14: evaluate
import org.osgl.util.S; //导入方法依赖的package包/类
public String evaluate(String s, Map<String, ?> map) {
int n = 0, n0 = 0, len = s.length();
S.Buffer sb = S.newBuffer();
while (n > -1 && n < len) {
n = s.indexOf("${", n);
if (n < 0) {
if (n0 == 0) {
return s;
}
sb.append(s.substring(n0, len));
break;
}
sb.append(s.substring(n0, n));
// now search for "}"
n += 2;
n0 = n;
n = s.indexOf("}", n0 + 1);
if (n < 0) {
logger.warn("Invalid expression found in the configuration value: %s", s);
return s;
}
String expression = s.substring(n0, n);
if (S.notBlank(expression)) {
Object o = getConfiguration(expression, null, map);
if (null != o) {
sb.append(o);
} else {
logger.warn("Cannot find expression value for: %s", expression);
}
}
n += 1;
n0 = n;
}
return sb.toString();
}
示例15: compactHandler
import org.osgl.util.S; //导入方法依赖的package包/类
public static String compactHandler(String handler) {
String[] sa = handler.split("\\.");
int len = sa.length;
if (len == 1) {
return handler;
}
S.Buffer sb = S.newBuffer();
for (int i = 0; i < len - 2; ++i) {
sb.append(sa[i].charAt(0)).append('.');
}
sb.append(sa[len - 2]).append('.').append(sa[len - 1]);
return sb.toString();
}