@Override public String visitSectionNumber( final SASectionNumber sn) throws Exception { final OptionType<SASection> s = document.getSection(sn); if (s.isSome()) { final Some<SASection> some = (Some<SASection>) s; final StringBuilder sb = new StringBuilder(); sb.append(sn.sectionNumberFormat()); sb.append(". "); sb.append(some.get().getTitle().getActual()); return sb.toString(); } throw new UnreachableCodeException(); } });
@Override protected Calendar getModificationTimeActual( final FileReference<ArchiveZipKind> r) { final ArchiveZipReference ra = (ArchiveZipReference) r; final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC")); return ra.getZipEntryOption().accept( new OptionVisitorType<ZipEntry, Calendar>() { @SuppressWarnings("synthetic-access") @Override public Calendar none( final None<ZipEntry> n) { final File file = new File(ArchiveZip.this.real.toString()); c.setTimeInMillis(file.lastModified()); return c; } @Override public Calendar some( final Some<ZipEntry> s) { c.setTimeInMillis(s.get().getTime()); return c; } }); }
.acceptPartial(new OptionPartialVisitorType<T, Boolean, FilesystemError>() { @Override public Boolean none( final None<T> n)
Filesystem.lookupDirectInArchive(a, a_path); if (r.isSome()) { .mapPartial(new PartialFunctionType<FileReference<?>, T, FilesystemError>() { @Override public T call( final FileReference<?> x)
static Element elementWithClasses( final String name, final OptionType<String> type, final String[] classes) { final StringBuilder cs = new StringBuilder(); for (int index = 0; index < classes.length; ++index) { cs.append(SXHTML.cssName(classes[index])); if ((index + 1) < classes.length) { cs.append(" "); } } type.map( new FunctionType<String, Unit>() { @Override public Unit call( final String x) { cs.append(" "); cs.append(x); return Unit.unit(); } }); final Element e = new Element(name, SXHTML.XHTML_URI.toString()); e.addAttribute(new Attribute("class", null, cs.toString())); return e; }
@Override public void onBodyEnd( final Element body) { if (inserts.getBodyEnd().isSome()) { final Some<Element> some = (Some<Element>) inserts.getBodyEnd(); body.appendChild(some.get().copy()); } }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element verbatim( final SVerbatim s) { NullCheck.notNull(s, "Verbatim"); final Element e = new Element("s:verbatim", SXML.XML_URI.toString()); s.getType().map(new TypeAdder(e)); e.appendChild(s.getText()); return e; }
.acceptPartial(new OptionPartialVisitorType<T, Boolean, FilesystemError>() { @Override public Boolean none( final None<T> n)
@Override public boolean exists( final PathVirtual path) throws FilesystemError { NullCheck.notNull(path, "Path"); final Boolean r = this.lookup(path).accept( new OptionVisitorType<Filesystem.FSReference, Boolean>() { @SuppressWarnings("null") @Override public Boolean none( final None<FSReference> n) { return Boolean.FALSE; } @SuppressWarnings("null") @Override public Boolean some( final Some<FSReference> s) { return Boolean.TRUE; } }); return r.booleanValue(); }
@Override public @Nullable Element onBodyStart( final Element body) { if (inserts.getBodyStart().isSome()) { final Some<Element> some = (Some<Element>) inserts.getBodyStart(); body.appendChild(some.get().copy()); } return null; }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element paragraph( final SParagraph s) { NullCheck.notNull(s, "Paragraph"); final Element e = new Element("s:paragraph", SXML.XML_URI.toString()); s.getType().map(new TypeAdder(e)); s.getID().map(new IDAdder(e)); for (final SParagraphContent c : s.getContent().getElements()) { e.appendChild(SDocumentSerializer.paragraphContent(c)); } return e; }
.acceptPartial(new OptionPartialVisitorType<FileReference<T>, Calendar, FilesystemError>() { @Override public Calendar none( final None<FileReference<T>> n)
.accept(new OptionVisitorType<ZipEntry, Long>() { @Override public Long none( final None<ZipEntry> n)
private static Element navigationBarTitleRowCellUp( final SADocument document, final OptionType<SASegmentNumber> current) throws Exception { final String[] c = new String[1]; c[0] = "navbar_up_title_cell"; final Element etc = SXHTML.elementWithClasses("td", SXHTML.NO_TYPE, c); if (current.isSome()) { final Some<SASegmentNumber> current_some = (Some<SASegmentNumber>) current; final OptionType<SASegmentNumber> up = document.segmentGetUp(current_some.get()); if (up.isSome()) { final Some<SASegmentNumber> up_some = (Some<SASegmentNumber>) up; etc.appendChild(SDocumentXHTMLWriterMulti .navigationBarTitleForSegment(document, up_some.get())); } else { etc.appendChild(document.getTitle().getActual()); } } return etc; }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element term( final STerm s) { NullCheck.notNull(s, "Term"); final Element e = new Element("s:term", SXML.XML_URI.toString()); s.getType().map(new TypeAdder(e)); e.appendChild(s.getText().getText()); return e; }
.acceptPartial(new OptionPartialVisitorType<FileReference<ArchiveZipKind>, SortedSet<String>, FilesystemError>() { @Override public SortedSet<String> none( final None<FileReference<ArchiveZipKind>> n)
name_o.accept(new OptionVisitorType<String, Unit>() { @Override public Unit none( final None<String> n)
private static Element navigationBarTitleRowCellPrevious( final SADocument document, final OptionType<SASegmentNumber> current) throws Exception { final String[] c = new String[1]; c[0] = "navbar_prev_title_cell"; final Element etc = SXHTML.elementWithClasses("td", SXHTML.NO_TYPE, c); if (current.isSome()) { final Some<SASegmentNumber> current_some = (Some<SASegmentNumber>) current; final OptionType<SASegmentNumber> previous = document.segmentGetPrevious(current_some.get()); if (previous.isSome()) { final Some<SASegmentNumber> previous_some = (Some<SASegmentNumber>) previous; etc.appendChild(SDocumentXHTMLWriterMulti .navigationBarTitleForSegment(document, previous_some.get())); } else { etc.appendChild(document.getTitle().getActual()); } } return etc; }
static Element head( final String title, final OptionType<SDocumentStyle> style) { final Element e = new Element("head", SXHTML.XHTML_URI.toString()); final Element e_title = new Element("title", SXHTML.XHTML_URI.toString()); e_title.appendChild(title); e.appendChild(e_title); e.appendChild(SXHTML.stylesheetLink(SResources.CSS_LAYOUT_NAME)); e.appendChild(SXHTML.stylesheetLink(SResources.CSS_COLOUR_NAME)); style.map(new FunctionType<SDocumentStyle, Unit>() { @Override public Unit call( final SDocumentStyle x) { e.appendChild(SXHTML.stylesheetLink(x.getActual().toString())); return Unit.unit(); } }); return e; }