本文整理汇总了Java中org.xembly.Directive类的典型用法代码示例。如果您正苦于以下问题:Java Directive类的具体用法?Java Directive怎么用?Java Directive使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Directive类属于org.xembly包,在下文中一共展示了Directive类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: details
import org.xembly.Directive; //导入依赖的package包/类
@Override
public Iterable<Directive> details(final long time) throws IOException {
final Iterator<Item> items = this.table()
.frame()
.through(
new QueryValve()
.withSelect(Select.ALL_ATTRIBUTES)
.withLimit(1)
)
.where("url", Conditions.equalTo(this.url))
.where("time", Conditions.equalTo(time))
.iterator();
if (!items.hasNext()) {
throw new IllegalArgumentException(
String.format(
"Request at %d for %s not found",
time, this.url
)
);
}
return DyStatus.xembly(items.next(), true);
}
开发者ID:yegor256,项目名称:rehttp,代码行数:23,代码来源:DyStatus.java
示例2: scripts
import org.xembly.Directive; //导入依赖的package包/类
@Override
public Iterable<Iterable<Directive>> scripts() {
return new Mapped<Item, Iterable<Directive>>(
item -> new Directives()
.add("script")
.add("name").set(item.get("name").getS()).up()
.add("bash").set(item.get("bash").getS()).up()
.add("paid").set(item.get("paid").getN()).up()
.add("used").set(item.get("used").getN()).up()
.add("hour").set(item.get("hour").getN()).up()
.add("day").set(item.get("day").getN()).up()
.add("week").set(item.get("week").getN()).up()
.up(),
this.region.table("scripts")
.frame()
.through(
new QueryValve()
// @checkstyle MagicNumber (1 line)
.withLimit(10)
.withSelect(Select.ALL_ATTRIBUTES)
)
.where("login", this.login)
);
}
开发者ID:yegor256,项目名称:threecopies,代码行数:25,代码来源:DyUser.java
示例3: logs
import org.xembly.Directive; //导入依赖的package包/类
@Override
public Iterable<Iterable<Directive>> logs() {
return new Mapped<Item, Iterable<Directive>>(
item -> new Directives()
.add("log")
.add("group").set(item.get("group").getS()).up()
.add("start").set(item.get("start").getN()).up()
.add("finish").set(item.get("finish").getN()).up()
.add("period").set(item.get("period").getS()).up()
.add("ocket").set(item.get("ocket").getS()).up()
.add("exit").set(item.get("exit").getN()).up()
.up(),
this.region.table("logs")
.frame()
.through(
new QueryValve()
.withIndexName("mine")
// @checkstyle MagicNumber (1 line)
.withLimit(20)
.withConsistentRead(false)
.withScanIndexForward(false)
.withSelect(Select.ALL_ATTRIBUTES)
)
.where("login", this.login)
);
}
开发者ID:yegor256,项目名称:threecopies,代码行数:27,代码来源:DyUser.java
示例4: act
import org.xembly.Directive; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
return new RsPage(
"/xsl/logs.xsl",
request,
() -> new StickyList<>(
new XeAppend("menu", "logs"),
new XeDirectives(
new Directives().add("logs").append(
new Joined<>(
new Limited<Iterable<Directive>>(
Tv.TWENTY,
new RqUser(this.base, request).logs()
)
)
)
)
)
);
}
开发者ID:yegor256,项目名称:threecopies,代码行数:21,代码来源:TkLogs.java
示例5: recent
import org.xembly.Directive; //导入依赖的package包/类
/**
* Recent artifacts..
* @return List of them
*/
public Iterable<Iterable<Directive>> recent() {
return new Mapped<>(
item -> {
final String[] parts = item.get("artifact").getS().split(":");
return new Directives()
.add("repo")
.add("group").set(parts[0]).up()
.add("artifact").set(parts[1]).up()
.up();
},
this.table.frame()
.where("good", "true")
.through(
new QueryValve()
.withScanIndexForward(false)
.withIndexName("recent")
.withConsistentRead(false)
// @checkstyle MagicNumber (1 line)
.withLimit(25)
.withAttributesToGet("artifact")
)
);
}
开发者ID:yegor256,项目名称:jpeek,代码行数:28,代码来源:Results.java
示例6: iterator
import org.xembly.Directive; //导入依赖的package包/类
@Override
public Iterator<Directive> iterator() {
try {
return new Directives()
.attr(
"date",
ZonedDateTime.now().format(
DateTimeFormatter.ISO_INSTANT
)
)
.attr("version", new Version().value())
.iterator();
} catch (final IOException ex) {
throw new IllegalStateException(ex);
}
}
开发者ID:yegor256,项目名称:jpeek,代码行数:17,代码来源:Header.java
示例7: iterator
import org.xembly.Directive; //导入依赖的package包/类
@Override
public Iterator<Directive> iterator() {
return new Directives()
.add("index")
.attr("artifact", "unknown")
.append(new Header())
.append(
new Joined<Directive>(
new Mapped<>(
Index::metric,
new Filtered<Path>(
path -> path.getFileName().toString().matches(
"^[A-Z].+\\.xml$"
),
new Directory(this.output)
)
)
)
)
.iterator();
}
开发者ID:yegor256,项目名称:jpeek,代码行数:22,代码来源:Index.java
示例8: acceptsAndRenders
import org.xembly.Directive; //导入依赖的package包/类
@Test
public void acceptsAndRenders() throws Exception {
final Path output = Files.createTempDirectory("").resolve("x2");
final Path input = Paths.get(".");
new App(input, output).analyze();
final Mistakes mistakes = new Mistakes();
mistakes.add(output);
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new Xembler(
new Directives().add("metrics").append(
new Joined<Directive>(mistakes.worst())
)
).xmlQuietly()
),
XhtmlMatchers.hasXPath("/metrics/metric[@id='LCOM']/avg")
);
}
开发者ID:yegor256,项目名称:jpeek,代码行数:19,代码来源:MistakesTest.java
示例9: acceptsAndRenders
import org.xembly.Directive; //导入依赖的package包/类
@Test
public void acceptsAndRenders() throws Exception {
final Path output = Files.createTempDirectory("").resolve("x2");
final Path input = Paths.get(".");
new App(input, output).analyze();
final Results results = new Results();
results.add("org.takes:takes", output);
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new Xembler(
new Directives().add("repos").append(
new Joined<Directive>(results.recent())
)
).xmlQuietly()
),
XhtmlMatchers.hasXPath("/repos")
);
}
开发者ID:yegor256,项目名称:jpeek,代码行数:19,代码来源:ResultsTest.java
示例10: source
import org.xembly.Directive; //导入依赖的package包/类
/**
* Convert event to Xembly.
* @param event The event
* @return Xembly
* @throws IOException If fails
*/
private static XeSource source(final Event event) throws IOException {
final Iterable<Directive> dirs = event.asXembly();
final String title = new XePrint(dirs).text("{/event/title/text()}");
return new XeDirectives(
new Directives()
.append(dirs)
.append(
new XeLink(
"delete",
new Href("/event-delete").with("title", title)
).toXembly()
)
.append(
new XeLink(
"down",
new Href("/event-down").with("title", title)
).toXembly()
)
);
}
开发者ID:yegor256,项目名称:wring,代码行数:27,代码来源:TkEvents.java
示例11: XeIdentity
import org.xembly.Directive; //导入依赖的package包/类
/**
* Ctor.
* @param req Request
*/
public XeIdentity(final Request req) {
super(
new XeSource() {
@Override
public Iterable<Directive> toXembly() throws IOException {
final Identity identity = new RqAuth(req).identity();
final Directives dirs = new Directives();
if (!identity.equals(Identity.ANONYMOUS)) {
dirs.add("identity")
.add("urn").set(identity.urn()).up();
for (final Map.Entry<String, String> prop
: identity.properties().entrySet()) {
dirs.add(prop.getKey()).set(prop.getValue()).up();
}
}
return dirs;
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:25,代码来源:XeIdentity.java
示例12: toXembly
import org.xembly.Directive; //导入依赖的package包/类
@Override
public Iterable<Directive> toXembly() throws IOException {
final Iterator<String> cookies =
new RqCookies.Base(this.req).cookie(this.cookie).iterator();
final Directives dirs = new Directives();
if (cookies.hasNext()) {
final Matcher matcher = XeFlash.PTN.matcher(cookies.next());
if (matcher.find()) {
dirs.add("flash")
.add("message").set(
URLDecoder.decode(
matcher.group(1),
Charset.defaultCharset().name()
)
).up()
.add("level").set(matcher.group(2));
}
}
return dirs;
}
开发者ID:yegor256,项目名称:takes,代码行数:21,代码来源:XeFlash.java
示例13: XeLocalhost
import org.xembly.Directive; //导入依赖的package包/类
/**
* Ctor.
* @param attr Attribute name
*/
@SuppressWarnings
(
{
"PMD.CallSuperInConstructor",
"PMD.ConstructorOnlyInitializesOrCallOtherConstructors"
}
)
public XeLocalhost(final CharSequence attr) {
super(
new XeSource() {
@Override
public Iterable<Directive> toXembly() {
String addr;
try {
addr = InetAddress.getLocalHost().getHostAddress();
} catch (final UnknownHostException ex) {
addr = ex.getClass().getCanonicalName();
}
return new Directives().attr(attr.toString(), addr);
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:28,代码来源:XeLocalhost.java
示例14: XeSla
import org.xembly.Directive; //导入依赖的package包/类
/**
* Ctor.
* @param attr Attribute name
*/
public XeSla(final CharSequence attr) {
super(
new XeSource() {
@Override
public Iterable<Directive> toXembly() {
return new Directives().attr(
attr.toString(),
String.format(
"%.3f",
ManagementFactory.getOperatingSystemMXBean()
.getSystemLoadAverage()
)
);
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:22,代码来源:XeSla.java
示例15: XeDate
import org.xembly.Directive; //导入依赖的package包/类
/**
* Ctor.
* @param attr Attribute name
*/
public XeDate(final CharSequence attr) {
super(
new XeSource() {
@Override
public Iterable<Directive> toXembly() {
final DateFormat fmt = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH
);
fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
return new Directives().attr(
attr.toString(), fmt.format(new Date())
);
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:21,代码来源:XeDate.java
示例16: XeWhen
import org.xembly.Directive; //导入依赖的package包/类
/**
* Ctor.
* @param condition Condition
* @param positive Xembly source when condition is positive
* @param negative Xembly source when condition is negative
* @since 1.5
*/
@SuppressWarnings
(
{
"PMD.CallSuperInConstructor",
"PMD.ConstructorOnlyInitializesOrCallOtherConstructors"
}
)
public XeWhen(final Scalar<Boolean> condition,
final Scalar<XeSource> positive,
final Scalar<XeSource> negative) {
super(
new XeSource() {
@Override
public Iterable<Directive> toXembly() throws IOException {
final Iterable<Directive> dirs;
if (condition.get()) {
dirs = positive.get().toXembly();
} else {
dirs = negative.get().toXembly();
}
return dirs;
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:33,代码来源:XeWhen.java
示例17: XeLifetime
import org.xembly.Directive; //导入依赖的package包/类
/**
* Ctor.
* @param elm Element name
*/
public XeLifetime(final CharSequence elm) {
super(
new XeSource() {
@Override
public Iterable<Directive> toXembly() {
return new Directives().attr(
elm.toString(),
Long.toString(
System.currentTimeMillis() - XeLifetime.START
)
);
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:20,代码来源:XeLifetime.java
示例18: XeLink
import org.xembly.Directive; //导入依赖的package包/类
/**
* Ctor.
* @param rel Related
* @param href HREF
* @param type Content type
*/
public XeLink(final CharSequence rel, final CharSequence href,
final CharSequence type) {
super(
new XeSource() {
@Override
public Iterable<Directive> toXembly() {
return new Directives()
.addIf("links")
.add("link")
.attr("rel", rel.toString())
.attr("href", href.toString())
.attr("type", type.toString())
.up()
.up();
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:25,代码来源:XeLink.java
示例19: toXembly
import org.xembly.Directive; //导入依赖的package包/类
@Override
public Iterable<Directive> toXembly() {
final Directives dirs = new Directives();
if (this.finish) {
dirs.xpath(this.name.toString())
.strict(1)
.xset(
String.format(
"%d - number(text())",
System.currentTimeMillis()
)
);
} else {
dirs.add(this.name.toString())
.set(Long.toString(System.currentTimeMillis()));
}
return dirs;
}
开发者ID:yegor256,项目名称:takes,代码行数:19,代码来源:XeMillis.java
示例20: XeMemory
import org.xembly.Directive; //导入依赖的package包/类
/**
* Ctor.
* @param node Node name
*/
public XeMemory(final CharSequence node) {
super(
new XeSource() {
@Override
public Iterable<Directive> toXembly() {
return new Directives().add(node.toString())
.attr(
"total",
XeMemory.mbs(Runtime.getRuntime().totalMemory())
)
.attr(
"free",
XeMemory.mbs(Runtime.getRuntime().freeMemory())
)
.attr(
"max",
XeMemory.mbs(Runtime.getRuntime().maxMemory())
);
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:27,代码来源:XeMemory.java
注:本文中的org.xembly.Directive类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论