本文整理汇总了Java中org.xembly.Directive类的典型用法代码示例。如果您正苦于以下问题:Java Directive类的具体用法?Java Directive怎么用?Java Directive使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Directive类属于org.xembly包,在下文中一共展示了Directive类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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)
);
}
示例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)
);
}
示例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()
)
)
)
)
)
);
}
示例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")
)
);
}
示例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);
}
}
示例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();
}
示例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")
);
}
示例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")
);
}
示例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()
)
);
}
示例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;
}
}
);
}
示例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;
}
示例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);
}
}
);
}
示例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()
)
);
}
}
);
}
示例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())
);
}
}
);
}