Class Util

java.lang.Object
eu.bandm.tools.doctypes.xhtml.Util

public class Util extends Object
Collection of frequently used xhtml construction utilities, plus frequently used HTTP response generation methods.
  • Field Details

  • Constructor Details

    • Util

      public Util()
  • Method Details

    • spanCStyle

      public static Element_span spanCStyle(String text, String styles)
      Create a xhtml "span" element with plain text content and direct "css style" values.
    • spanCC

      public static Element_span spanCC(String cls, String text)
      Create a xhtml "span" element with plain text content and a given "css class".
    • spanNCC

      public static Element_span spanNCC(String xname, String cls, String text)
      Create a xhtml "span" element with an @id, plain text content and a given "css class".
    • anchorNCC

      public static Element_a anchorNCC(String xname, @Opt @Opt String cls, String text)
      Arriving link target with @name/@id, @class and pure text contents.
    • anchorNCCT

      public static Element_a anchorNCCT(String xname, @Opt @Opt String cls, String text, @Opt @Opt String tooltip)
      Arriving link target with @name/@id, @class, pure text contents and a tooltip text.
    • jumpN

      public static Element_a jumpN(String xhref)
      Jump to target with @href, and text content plain link address.
    • jumpNCC

      public static Element_a jumpNCC(String xhref, @Opt @Opt String cls, String text)
      Jump to target with @href, @class and pure text contents. "NCC" means "name, class and contents".
    • jumpNCCT

      public static Element_a jumpNCCT(String xhref, @Opt @Opt String cls, String text, @Opt @Opt String tooltip)
      Jump to target with @href, @class, pure text contents and tooltip.
    • pText

      public static Element_p.Content pText(String cls, String text)
      Create a xhtml "span" element with plain text content and a given "css class" and wraps it for use in a Element_p.
    • pText

      public static Element_p.Content pText(String text)
      Wrap text for use in a Element_p.
    • input_select

      public static Element_select input_select(String id, boolean multiple, boolean active, int displaySize, String[] values, String[] shown, @Opt @Opt String onchange, Set<String> selected)
      FIXME Element_optgroup missing
      Parameters:
      id - used for @id and @name
      multiple - whether more than one input can be selected, copied to @multiple
      active - whether input field is active or grayed out
      displaySize - size of the shown section, use ==1 for a drop-down box
      values - pure text which is returned as value in case of select
      shown - pure text which is SHOWN for the items on the screen; values and shown must be in sync.
      onchange - pure text, what to do in case of value editing; mostly a ecma-script call. (not clear whether an editing action or a real value change triggers this command, may depend on the browser's implementation, see https://developer.mozilla.org/en-US/docs/Web/Events/change (and the html specs(?))
      selected - the item or items which are initially selected.
    • hidden_input

      public static Element_input hidden_input(String key, String value)
      Construct a hidden xhtml "input" element with @name=@id=key parameter, and the given constant value. (Must be contained in a "form" element.
    • text_button

      public static Element_button text_button(String text, String command, boolean submitNotReset, boolean isActive)
      Makes one html-button with simple text as its visible surface. Attributes @id=@name=@value are set by parameter "command". Is of flavor "submit" and is active, as controlled by the boolean arguments.

      In the HTTP request (defined by "form.@action") the submit-button with "@name=XX" will be encoded by appearing in the HTTP-header's parameter list.
      Must be contained (indirectly) in a "form" element.
    • textarea

      public static Element_textarea textarea(@Opt @Opt String contents, int rows, int cols, String id, boolean active, boolean editable)
      Makes one "text area" element. FIXME @wrap fehlt
    • form

      public static Element_form form(Element_form_content[] contents, String actionUrl, @Opt @Opt String encodings, @Opt Element_form.Attr_method.Value method)
      Makes one "form" element.
      "get" is default for method.
      "@target" is not supported, since not allowed in "strict".
      Parameters:
      encodings - is copied to @accept and are the mime types accepted by an upload
    • xhtml_head

      public static Element_head xhtml_head(String title, @Opt @Opt String encoding, @Opt @Opt String favicon, @Opt @Opt List<String> jses, @Opt @Opt List<String> csses, @Opt @Opt List<Element_link> links, @Opt @Opt Map<String,String> metas, @Opt @Opt List<Element_meta> metas2)
      Creates an Xhtml1.0 Element_head according to the syntax <!ELEMENT head ((script | style | meta | link | object)*, ((title, %head.misc;, (base, %head.misc;)?) | (base, %head.misc;, (title, %head.misc;)))) >
      Parameters:
      title - is used as contents of Element_title AND is duplicated to meta "DC.title"
      encoding - ALWAYS a "meta http_equiv content-type" Element_meta is generated. The encoding defaults to utf-8.
      favicon - creates a special Element_link ASSUME that file name extension == mime type!
      jses - make specialized Element_link objects from file position / url only.
      csses - make specialized Element_link objects from file position / url only.
      links - pre-factored Element_link objects to be inserted, with @rel, @type and @href attributes.
      metas - key/value pairs create a Element_meta with
      metas2 - pre-factored Element_meta objects to be inserted.
    • wrap_document

      public static Document_html wrap_document(Element_head head, Element_body body)
    • sendDocumentAsHttpAnswer

      public static void sendDocumentAsHttpAnswer(OutputStream out, Document_html doc)
    • sendDocumentAsHttpAnswer

      public static void sendDocumentAsHttpAnswer(OutputStream out, Document_html doc, String encoding)
    • sendBack_file

      public static void sendBack_file(File data, String mimetype, OutputStream out) throws IOException
      Send a file back to the sockets output channel. Wrap it only into a "OK" http resonse header. This method is needed for "static" files, like ".css", etc.
      Throws:
      IOException