# Class Stylesheet

java.lang.Object
javafx.css.Stylesheet

public class Stylesheet extends Object
A stylesheet which can apply properties to a tree of objects. A stylesheet is a collection of zero or more `Rules`, each of which is applied to each object in the tree. Typically the selector will examine the object to determine whether or not it is applicable, and if so it will apply certain property values to the object.

Since:
  9

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `convertToBinary(File source, File destination)`
  Converts the css file referenced by `source` to binary format and writes it to `destination`.
  `boolean`
  `equals(Object obj)`
  Indicates whether this `Stylesheet` is "equal to" some other object.
  `List<FontFace>`
  `getFontFaces()`
  Returns the font faces used by this `Stylesheet`.
  `StyleOrigin`
  `getOrigin()`
  Returns the origin of this `Stylesheet`.
  `List<Rule>`
  `getRules()`
  Returns the rules that are defined in this `Stylesheet`.
  `String`
  `getUrl()`
  The URL from which this `Stylesheet` was loaded.
  `static Stylesheet`
  `loadBinary(InputStream stream)`
  Loads a binary stylesheet from a stream.
  `static Stylesheet`
  `loadBinary(URL url)`
  Loads a binary stylesheet from a `URL`.
  `void`
  `setOrigin(StyleOrigin origin)`
  Sets the origin of this `Stylesheet`.
  `String`
  `toString()`
  Returns a string representation of this object.

  ### Methods declared in class java.lang.Object

  `clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Method Details

  - ### getUrl

    public String getUrl()
    The URL from which this `Stylesheet` was loaded.
    Returns:
      A `String` representation of the URL from which the stylesheet was loaded, or `null` if the stylesheet was created from an inline style.

  - ### getOrigin

    public StyleOrigin getOrigin()
    Returns the origin of this `Stylesheet`.
    Returns:
      the origin of this `Stylesheet`

  - ### setOrigin

    public void setOrigin(StyleOrigin origin)
    Sets the origin of this `Stylesheet`.
    Parameters:
      `origin` - the origin of this `Stylesheet`

  - ### getRules

    public List<Rule> getRules()
    Returns the rules that are defined in this `Stylesheet`.
    Returns:
      a list of rules used by this `Stylesheet`

  - ### getFontFaces

    public List<FontFace> getFontFaces()
    Returns the font faces used by this `Stylesheet`.
    Returns:
      a list of font faces used by this `Stylesheet`

  - ### equals

    public boolean equals(Object obj)
    Indicates whether this `Stylesheet` is "equal to" some other object. Equality of two `Stylesheet`s is based on the equality of their URL as defined by `getUrl()`.
    Overrides:
      `equals` in class `Object`

  - ### toString

    public String toString()
    Returns a string representation of this object.
    Overrides:
      `toString` in class `Object`

  - ### loadBinary

    public static Stylesheet loadBinary(URL url) throws IOException
    Loads a binary stylesheet from a `URL`.
    Parameters:
      `url` - the `URL` from which the `Stylesheet` will be loaded
    Returns:
      the loaded `Stylesheet`
    Throws:
      `IOException` - if the binary stream corresponds to a more recent binary css version or if an I/O error occurs while reading from the stream

  - ### loadBinary

    public static Stylesheet loadBinary(InputStream stream) throws IOException
    Loads a binary stylesheet from a stream.
    Parameters:
      `stream` - the input stream
    Returns:
      the loaded `Stylesheet`
    Throws:
      `IOException` - if the binary stream corresponds to a more recent binary css version or if an I/O error occurs while reading from the stream
    Since:
      17

  - ### convertToBinary

    public static void convertToBinary(File source, File destination) throws IOException
    Converts the css file referenced by `source` to binary format and writes it to `destination`.
    Parameters:
      `source` - the JavaFX compliant css file to convert
      `destination` - the file to which the binary formatted data is written
    Throws:
      `IOException` - if the destination file can not be created or if an I/O error occurs
      `IllegalArgumentException` - if either parameter is `null`, if `source` and `destination` are the same, if `source` cannot be read, or if `destination` cannot be written