public final class CSSFactory extends Object
cz.vutbr.web.csskit.TermFactoryImpl
cz.vutbr.web.domassign.SupportedCSS3
cz.vutbr.web.csskit.RuleFactoryImpl
cz.vutbr.web.domassign.SingleMapNodeData
cz.vutbr.web.csskit.ElementMatcherSafeStd
Other usage of this factory is to parse either string or file into
StyleSheet.
Whole conversion between DOM tree and mapping of CSS to DOM tree elements
could be done by invoking method assignDOM()| Constructor and Description |
|---|
CSSFactory() |
| Modifier and Type | Method and Description |
|---|---|
static StyleMap |
assignDOM(Document doc,
String encoding,
NetworkProcessor network,
URL base,
MediaSpec media,
boolean useInheritance,
MatchCondition matchCond)
This is the same as
assignDOM(Document, String, URL, MediaSpec, boolean)
with the possibility of specifying a custom network processor for obtaining data from URL
resources. |
static StyleMap |
assignDOM(Document doc,
String encoding,
URL base,
MediaSpec media,
boolean useInheritance)
Goes through a DOM tree and assigns the CSS declarations to the DOM elements.
|
static StyleMap |
assignDOM(Document doc,
String encoding,
URL base,
MediaSpec media,
boolean useInheritance,
MatchCondition matchCond)
Goes through a DOM tree and assigns the CSS declarations to the DOM elements.
|
static StyleMap |
assignDOM(Document doc,
String encoding,
URL base,
String media,
boolean useInheritance)
This is the same as
assignDOM(Document, String, URL, MediaSpec, boolean) but only the
media type is provided instead of the complete media specification. |
static StyleMap |
assignDOM(Document doc,
String encoding,
URL base,
String media,
boolean useInheritance,
MatchCondition matchCond)
This is the same as
assignDOM(Document, String, URL, MediaSpec, boolean) but only the
media type is provided instead of the complete media specification. |
static StyleMap |
assignDOM(Document doc,
URL base,
String media,
boolean useInheritance)
Deprecated.
|
static NodeData |
createNodeData()
Creates instance of NodeData
|
static MediaSpec |
getAutoImportMedia()
Obtains the media specification used for automatical style import.
|
static DeclarationTransformer |
getDeclarationTransformer()
Returns the registered DeclarationTransformer
|
static MatchCondition |
getDefaultMatchCondition()
Obtains the default match condition to be used for matching the elements and selector parts.
|
static ElementMatcher |
getElementMatcher() |
static boolean |
getImplyPixelLength()
Says whether to allow lengths with no units and interpret them as pixels.
|
static NetworkProcessor |
getNetworkProcessor() |
static RuleFactory |
getRuleFactory()
Returns registered RuleFactory
|
static SupportedCSS |
getSupportedCSS()
Returns registered SupportedCSS
|
static TermFactory |
getTermFactory()
Returns TermFactory registered in step above
|
static StyleSheet |
getUsedStyles(Document doc,
String encoding,
URL base,
MediaSpec media)
This is the same as
getUsedStyles(Document, String, URL, MediaSpec) with
the possibility of specifying a custom network processor. |
static StyleSheet |
getUsedStyles(Document doc,
String encoding,
URL base,
MediaSpec media,
NetworkProcessor network)
Loads all the style sheets used from the specified DOM tree.
|
static StyleSheet |
getUsedStyles(Document doc,
String encoding,
URL base,
String media)
This is the same as
getUsedStyles(Document, String, URL, MediaSpec) but only the
media type is provided instead of the complete media specification. |
static StyleSheet |
getUsedStyles(Document doc,
URL base,
String media)
Deprecated.
|
static StyleSheet |
parse(String css)
Deprecated.
This function does not specify the base URL.
parseString(String, URL)
should be used instead. |
static StyleSheet |
parse(String fileName,
String encoding)
Parses file into StyleSheet.
|
static StyleSheet |
parse(URL url,
NetworkProcessor network,
String encoding)
Parses URL into StyleSheet
|
static StyleSheet |
parse(URL url,
String encoding)
Parses URL into StyleSheet
|
static StyleSheet |
parseString(String css,
URL base)
Parses text into a StyleSheet
|
static StyleSheet |
parseString(String css,
URL base,
NetworkProcessor network)
Parses text into a StyleSheet
|
static void |
registerCSSParserFactory(CSSParserFactory factory)
Registers new CSSParserFactory instance
|
static void |
registerDeclarationTransformer(DeclarationTransformer newDeclarationTransformer)
Registers new DeclarationTransformer
|
static void |
registerDefaultMatchCondition(MatchCondition newMatchCondition)
Registers a new default match condition to be used for matching the elements and selector parts.
|
static void |
registerElementMatcher(ElementMatcher newElementMatcher) |
static void |
registerNodeDataInstance(Class<? extends NodeData> clazz)
Registers node data instance.
|
static void |
registerRuleFactory(RuleFactory newRuleFactory)
Registers new RuleFactory
|
static void |
registerSupportedCSS(SupportedCSS newCSS)
Registers new SupportedCSS instance
|
static void |
registerTermFactory(TermFactory newFactory)
Registers new TermFactory instance
|
static void |
setAutoImportMedia(MediaSpec autoImportMedia)
Sets the media specification used for automatical style import.
|
static void |
setImplyPixelLength(boolean b)
Sets whether to allow lengths with no units and interpret them as pixels.
|
static void |
setNetworkProcessor(NetworkProcessor networkProcessor) |
public static final void setImplyPixelLength(boolean b)
false.b - true when the lengths with no units should be allowed.public static final boolean getImplyPixelLength()
true if the lengths with no units are allowedpublic static MediaSpec getAutoImportMedia()
@import rules
when they corespond to the given media specification.public static void setAutoImportMedia(MediaSpec autoImportMedia)
@import rules
when they corespond to the given media specification. The default is "all" i.e.
all the imported style sheets are automatically parsed.autoImportMedia - The media specification for checking the imports.public static NetworkProcessor getNetworkProcessor()
public static void setNetworkProcessor(NetworkProcessor networkProcessor)
public static final void registerCSSParserFactory(CSSParserFactory factory)
factory - New CSSParserFactorypublic static final void registerTermFactory(TermFactory newFactory)
newFactory - New TermFactorypublic static final TermFactory getTermFactory()
public static final void registerSupportedCSS(SupportedCSS newCSS)
newCSS - new SupportedCSSpublic static final SupportedCSS getSupportedCSS()
public static final void registerRuleFactory(RuleFactory newRuleFactory)
newRuleFactory - New RuleFactory instancepublic static final RuleFactory getRuleFactory()
public static final void registerDeclarationTransformer(DeclarationTransformer newDeclarationTransformer)
newDeclarationTransformer - New DeclarationTransformer instancepublic static final DeclarationTransformer getDeclarationTransformer()
public static final void registerElementMatcher(ElementMatcher newElementMatcher)
public static final ElementMatcher getElementMatcher()
public static final void registerDefaultMatchCondition(MatchCondition newMatchCondition)
newMatchCondition - the new match conditionpublic static final MatchCondition getDefaultMatchCondition()
public static final void registerNodeDataInstance(Class<? extends NodeData> clazz)
clazz - Instance classpublic static final NodeData createNodeData()
public static final StyleSheet parse(URL url, String encoding) throws CSSException, IOException
url - URL of file to be parsedencoding - Encoding of fileCSSException - When exception during parse occursIOException - When file not foundpublic static final StyleSheet parse(URL url, NetworkProcessor network, String encoding) throws CSSException, IOException
url - URL of file to be parsednetwork - Network processor used for handling the URL connectionsencoding - Encoding of fileCSSException - When exception during parse occursIOException - When file not foundpublic static final StyleSheet parse(String fileName, String encoding) throws CSSException, IOException
fileName - Name of fileencoding - Encoding used to parse inputCSSException - In case that parsing error occursIOException - If file is not found or not readable@Deprecated public static final StyleSheet parse(String css) throws IOException, CSSException
parseString(String, URL)
should be used instead.css - Text with CSS declarationsIOException - When exception during read occursCSSException - When exception during parse occurspublic static final StyleSheet parseString(String css, URL base) throws IOException, CSSException
css - Text with CSS declarationsbase - The URL to be used as a base for loading external resources. Base URL may
be null if there are no external resources in the CSS string
referenced by relative URLs.IOException - When exception during read occursCSSException - When exception during parse occurspublic static final StyleSheet parseString(String css, URL base, NetworkProcessor network) throws IOException, CSSException
css - Text with CSS declarationsbase - The URL to be used as a base for loading external resources. Base URL may
be null if there are no external resources in the CSS string
referenced by relative URLs.network - Network processor for retrieving the URL resourcesIOException - When exception during read occursCSSException - When exception during parse occurspublic static final StyleSheet getUsedStyles(Document doc, String encoding, URL base, MediaSpec media, NetworkProcessor network)
link and style tags.
style element attribute.
XDefaultStyle
element attribute. These styles behave the same way as the inline styles but they have the lowest priority
(the values are used only when not redefined by any other way)
doc - DOM treeencoding - The default encoding used for the referenced style sheetsbase - Base URL against which all files are searchedmedia - Selected media for style sheetpublic static final StyleSheet getUsedStyles(Document doc, String encoding, URL base, MediaSpec media)
getUsedStyles(Document, String, URL, MediaSpec) with
the possibility of specifying a custom network processor.doc - DOM treeencoding - The default encoding used for the referenced style sheetsbase - Base URL against which all files are searchedmedia - Selected media for style sheetpublic static final StyleSheet getUsedStyles(Document doc, String encoding, URL base, String media)
getUsedStyles(Document, String, URL, MediaSpec) but only the
media type is provided instead of the complete media specification.doc - DOM treeencoding - The default encoding used for the referenced style sheetsbase - Base URL against which all files are searchedmedia - Selected media for style sheet@Deprecated public static final StyleSheet getUsedStyles(Document doc, URL base, String media)
public static final StyleMap assignDOM(Document doc, String encoding, URL base, MediaSpec media, boolean useInheritance)
link and style tags.
style element attribute.
XDefaultStyle
element attribute. These styles behave the same way as the inline styles but they have the lowest priority
(the values are used only when not redefined by any other way)
doc - DOM treeencoding - The default encoding used for the referenced style sheetsbase - Base URL against which all files are searchedmedia - Current media specification used for evaluating the media queriesuseInheritance - Whether inheritance will be used to determine valuespublic static final StyleMap assignDOM(Document doc, String encoding, URL base, String media, boolean useInheritance)
assignDOM(Document, String, URL, MediaSpec, boolean) but only the
media type is provided instead of the complete media specification.doc - DOM treeencoding - The default encoding used for the referenced style sheetsbase - Base URL against which all files are searchedmedia - Selected media type for style sheetuseInheritance - Whether inheritance will be used to determine valuespublic static final StyleMap assignDOM(Document doc, String encoding, URL base, MediaSpec media, boolean useInheritance, MatchCondition matchCond)
link and style tags.
style element attribute.
XDefaultStyle
element attribute. These styles behave the same way as the inline styles but they have the lowest priority
(the values are used only when not redefined by any other way)
doc - DOM treeencoding - The default encoding used for the referenced style sheetsbase - Base URL against which all files are searchedmedia - Current media specification used for evaluating the media queriesuseInheritance - Whether inheritance will be used to determine valuesmatchCond - The match condition to match the against.public static final StyleMap assignDOM(Document doc, String encoding, NetworkProcessor network, URL base, MediaSpec media, boolean useInheritance, MatchCondition matchCond)
assignDOM(Document, String, URL, MediaSpec, boolean)
with the possibility of specifying a custom network processor for obtaining data from URL
resources.doc - DOM treeencoding - The default encoding used for the referenced style sheetsnetwork - Custom network processorbase - Base URL against which all files are searchedmedia - Current media specification used for evaluating the media queriesuseInheritance - Whether inheritance will be used to determine valuesmatchCond - The match condition to match the against.public static final StyleMap assignDOM(Document doc, String encoding, URL base, String media, boolean useInheritance, MatchCondition matchCond)
assignDOM(Document, String, URL, MediaSpec, boolean) but only the
media type is provided instead of the complete media specification.doc - DOM treeencoding - The default encoding used for the referenced style sheetsbase - Base URL against which all files are searchedmedia - Selected media type for style sheetuseInheritance - Whether inheritance will be used to determine valuesmatchCond - The match condition to match the against.@Deprecated public static final StyleMap assignDOM(Document doc, URL base, String media, boolean useInheritance)
Copyright © 2019. All rights reserved.