Class BaseCSSStyleSheetFactory

java.lang.Object
io.sf.carte.doc.style.css.om.AbstractCSSStyleSheetFactory
io.sf.carte.doc.style.css.om.BaseCSSStyleSheetFactory
All Implemented Interfaces:
CSSStyleSheetFactory, Serializable
Direct Known Subclasses:
CSSDOMImplementation, DOMCSSStyleSheetFactory

public abstract class BaseCSSStyleSheetFactory extends AbstractCSSStyleSheetFactory
Base class for CSS style sheet factories.
See Also:
  • Constructor Details

    • BaseCSSStyleSheetFactory

      protected BaseCSSStyleSheetFactory()
    • BaseCSSStyleSheetFactory

      protected BaseCSSStyleSheetFactory(EnumSet<Parser.Flag> parserFlags)
  • Method Details

    • createDefaultStyleFormattingFactory

      protected StyleFormattingFactory createDefaultStyleFormattingFactory()
    • createDocumentStyleSheet

      protected abstract BaseDocumentCSSStyleSheet createDocumentStyleSheet(byte origin)
      Creates a Document CSS style sheet for all media.

      Parameters:
      origin - the origin of the sheet (like author, user agent, etc.)
      Returns:
      the style sheet.
    • createStyleSheet

      public AbstractCSSStyleSheet createStyleSheet(String title, MediaQueryList media)
      Creates a stand-alone author style sheet.

      Specified by:
      createStyleSheet in interface CSSStyleSheetFactory
      Specified by:
      createStyleSheet in class AbstractCSSStyleSheetFactory
      Parameters:
      title - the advisory title.
      media - the target media for the style sheet.
      Returns:
      the style sheet.
    • createRuleStyleSheet

      protected abstract AbstractCSSStyleSheet createRuleStyleSheet(AbstractCSSRule ownerRule, String title, MediaQueryList mediaList)
      Creates a CSS style sheet owned by a CSS rule.

      Specified by:
      createRuleStyleSheet in class AbstractCSSStyleSheetFactory
      Parameters:
      ownerRule - the owner rule.
      title - the advisory title.
      mediaList - the list of target media for style.
      Returns:
      the style sheet.
    • setClassLoader

      public void setClassLoader(ClassLoader loader)
      Sets the class loader to be used when loading internal style sheets.
      Parameters:
      loader - the class loader.
    • createPropertyDefinition

      public CSSPropertyDefinition createPropertyDefinition(String name, CSSValueSyntax syntax, boolean inherited, CSSLexicalValue initialValue) throws DOMException
      Description copied from interface: CSSStyleSheetFactory
      Create a property definition.

      To parse the syntax, use a parser like SyntaxParser.

      Parameters:
      name - the property name (unescaped).
      syntax - the syntax.
      inherited - whether the property is inherited or not.
      initialValue - the initial value.
      Returns:
      the property definition.
      Throws:
      DOMException - INVALID_ACCESS_ERR if the initial value does not match the syntax.
    • getStyleFormattingFactory

      public StyleFormattingFactory getStyleFormattingFactory()
      Description copied from interface: CSSStyleSheetFactory
      Get the style formatting factory to be used with this sheet factory.
      Returns:
      the style formatting factory.
    • setStyleFormattingFactory

      public void setStyleFormattingFactory(StyleFormattingFactory factory)
      Description copied from interface: CSSStyleSheetFactory
      Set a style formatting factory to format style serializations made with sheets created by this sheet factory.
      Parameters:
      factory - the style formatting factory.
    • setUserStyleSheet

      public void setUserStyleSheet(String url, Reader re) throws DOMException, IOException
      Sets the CSS style sheet defined by the end user.

      The sheet in the supplied reader should contain user preferences, and will be appropriately merged with the other style sheets.

      Parameters:
      url - the URL of the style sheet. If null, the call is equivalent to setUserStyleSheet(Reader).
      re - the reader with the user style sheet. If null, a connection to the URL shall be opened. If both arguments are null, the user style sheet shall be cleared.
      Throws:
      DOMException - if a problem is found parsing the sheet.
      IOException - if there is a problem opening the URL or reading the reader.
    • setUserStyleSheet

      public void setUserStyleSheet(Reader re) throws DOMException, IOException
      Sets the CSS style sheet defined by the end user.

      The sheet in the supplied reader should contain user preferences, and will be appropriately merged with the other style sheets.

      Parameters:
      re - the reader with the user style sheet. If null, the user style sheet shall be cleared.
      Throws:
      DOMException - if a problem is found parsing the sheet.
      IOException - if there is a problem retrieving the reader.
    • getUserImportantStyleSheet

      protected AbstractCSSStyleSheet getUserImportantStyleSheet()
      Description copied from class: AbstractCSSStyleSheetFactory
      Get the priority-important part of the user style sheet, i.e. the style sheet with the declarations of important priority.
      Specified by:
      getUserImportantStyleSheet in class AbstractCSSStyleSheetFactory
      Returns:
      the important part of the user style sheet.
    • getUserNormalStyleSheet

      protected AbstractCSSStyleSheet getUserNormalStyleSheet()
      Description copied from class: AbstractCSSStyleSheetFactory
      Get the normal part of the user style sheet, i.e. the style sheet with the declarations of normal priority.
      Specified by:
      getUserNormalStyleSheet in class AbstractCSSStyleSheetFactory
      Returns:
      the normal part of the user style sheet.
    • htmlDefaultSheet

      protected BaseDocumentCSSStyleSheet htmlDefaultSheet() throws IllegalStateException
      Returns a default user agent style sheet for (X)HTML documents, strict mode.
      Returns:
      the default style sheet for HTML.
      Throws:
      IllegalStateException - if a problem arose when reading the default sheet.
    • htmlQuirksDefaultSheet

      protected BaseDocumentCSSStyleSheet htmlQuirksDefaultSheet() throws IllegalStateException
      Returns a default user agent style sheet for (X)HTML documents, quirks mode.
      Returns:
      the default style sheet for HTML.
      Throws:
      IllegalStateException - if a problem arose when reading the default sheet.
    • getValueFactory

      protected ValueFactory getValueFactory()
      Description copied from class: AbstractCSSStyleSheetFactory
      Get a value factory set to the appropriate flags.
      Specified by:
      getValueFactory in class AbstractCSSStyleSheetFactory
      Returns:
      the value factory.
    • setFactoryFlag

      public void setFactoryFlag(byte flag)
      Description copied from interface: CSSStyleSheetFactory
      Set a configuration flag. Do not confuse with NSAC flags, which must be set at this object's creation time (see the documentation for implementation's constructors).

      The flags are implementation-dependent.

      Parameters:
      flag - the flag to set.
    • setLenientSystemValues

      public void setLenientSystemValues(boolean lenient)

      The style sheet factories provide system default values, and its behaviour depends on a lenientSystemValues flag. The lenient flag allows to compute values by giving reasonable defaults to properties with system-dependent initial values: '#000000' for color and 'serif' for font-family.

      If you work with style databases you do not need lenientSystemValues.

      Default value is true.

      Parameters:
      lenient - true or false to enable/disable the lenientSystemValues flag.
    • getSystemDefaultValue

      public TypedValue getSystemDefaultValue(String propertyName)
      Get a system default value for the given property.

      If the lenientSystemValues flag is set, returns a reasonable default for the property. Otherwise, it returns a system default meta-value.

      Specified by:
      getSystemDefaultValue in interface CSSStyleSheetFactory
      Specified by:
      getSystemDefaultValue in class AbstractCSSStyleSheetFactory
      Parameters:
      propertyName - the property name.
      Returns:
      the system default css primitive value.
    • createSACParser

      protected Parser createSACParser()
      Description copied from class: AbstractCSSStyleSheetFactory
      Create a NSAC Parser with the proper flags enabled.
      Specified by:
      createSACParser in class AbstractCSSStyleSheetFactory
      Returns:
      the NSAC parser.
    • getParserFlags

      protected EnumSet<Parser.Flag> getParserFlags()
      Get the parser flags that should be used by NSAC parsers.
      Specified by:
      getParserFlags in class AbstractCSSStyleSheetFactory
      Returns:
      the NSAC parser flags.
    • hasCompatValueFlags

      protected boolean hasCompatValueFlags()
      Description copied from class: AbstractCSSStyleSheetFactory
      Check for compat value flags.
      Specified by:
      hasCompatValueFlags in class AbstractCSSStyleSheetFactory
      Returns:
      true if the factory has compat value flags set.
    • createInlineStyleErrorHandler

      public StyleDeclarationErrorHandler createInlineStyleErrorHandler(CSSElement owner)
      Description copied from interface: CSSStyleSheetFactory
      Create a new StyleDeclarationErrorHandler for the given style rule.
      Parameters:
      owner - the element owner of the inline style.
      Returns:
      the StyleDeclarationErrorHandler.
    • createStyleDeclarationErrorHandler

      public StyleDeclarationErrorHandler createStyleDeclarationErrorHandler(CSSDeclarationRule rule)
      Create a new StyleDeclarationErrorHandler for the given style rule.
      Parameters:
      rule - the declaration rule the handler is for.
      Returns:
      the StyleDeclarationErrorHandler.
    • createSheetErrorHandler

      public SheetErrorHandler createSheetErrorHandler(CSSStyleSheet<? extends CSSRule> sheet)
      Creates a style sheet error handler.
      Parameters:
      sheet - the sheet that will be handled.
      Returns:
      the error handler.
    • createMediaQueryList

      public MediaQueryList createMediaQueryList(String mediaQueryString, Node owner) throws CSSBudgetException
      Parses mediaQueryString and creates a new media query list.
      Parameters:
      mediaQueryString - the media query string.
      owner - the node that would handle errors, if any.
      Returns:
      a new media list for mediaQueryString.
      Throws:
      CSSBudgetException - if a hard-coded limit in nested expressions was reached.
    • createImmutableMediaQueryList

      public MediaQueryList createImmutableMediaQueryList(String media, Node owner) throws CSSBudgetException
      Parses and creates an unmodifiable media query list for the given media.
      Parameters:
      media - the comma-separated list of media. If null, the media list will be for all media.
      owner - the node that would handle errors, if any.
      Returns:
      the unmodifiable media list.
      Throws:
      CSSBudgetException - if a hard-coded limit in nested expressions was reached.
    • getDeviceFactory

      public DeviceFactory getDeviceFactory()
      Gets the device factory.
      Returns:
      the device factory.
    • setDeviceFactory

      public void setDeviceFactory(DeviceFactory deviceFactory)
      Sets the device factory.
      Parameters:
      deviceFactory - the device factory.