Class CSSURI

java.lang.Object
com.helger.css.decl.CSSURI
All Implemented Interfaces:
ICSSSourceLocationAware, ICSSWriteable

@NotThreadSafe public class CSSURI extends Object implements ICSSWriteable, ICSSSourceLocationAware
Represents a single CSS URI. The contained URI might be modified using setURI(String).
Author:
Philip Helger
  • Constructor Details

  • Method Details

    • getURI

      @Nonnull public final String getURI()
      Returns:
      The URI string (without the leading "url(" and the closing ")")
    • setURI

      @Nonnull public final CSSURI setURI(@Nonnull String sURI)
      Set the URI string of this object. This may either be a regular URI or a data URL string (starting with "data:"). The passed string may not start with the prefix "url(" and end with ")".
      Parameters:
      sURI - The URI to be set. May not be null but may be empty (even though an empty URL usually does not make sense).
      Returns:
      this
    • isDataURL

      public boolean isDataURL()
      Check if this URI is a data URL (starting with "data:")
      Returns:
      true if the URI is a data URL, false otherwise.
    • getAsDataURL

      @Nullable public CSSDataURL getAsDataURL()
      Try to convert the contained URI to a Data URL object.
      Returns:
      null if conversion to a data URL failed, the CSSDataURL object otherwise.
    • getAsCSSString

      @Nonnull @Nonempty public String getAsCSSString(@Nonnull ICSSWriterSettings aSettings, @Nonnegative int nIndentLevel)
      Description copied from interface: ICSSWriteable
      Get the contents of this object as a serialized CSS string for writing to an output.
      Specified by:
      getAsCSSString in interface ICSSWriteable
      Parameters:
      aSettings - The settings to be used to format the output. May not be null.
      nIndentLevel - The current indentation level
      Returns:
      The content of this object as CSS string. Never null.
    • getSourceLocation

      @Nullable public final CSSSourceLocation getSourceLocation()
      Specified by:
      getSourceLocation in interface ICSSSourceLocationAware
      Returns:
      The source location of this object when it was read by the parser. May be null if an object was not read but manually created.
    • setSourceLocation

      public final void setSourceLocation(@Nullable CSSSourceLocation aSourceLocation)
      Description copied from interface: ICSSSourceLocationAware
      Set the source location of the object, determined while parsing.
      Specified by:
      setSourceLocation in interface ICSSSourceLocationAware
      Parameters:
      aSourceLocation - The source location to use. May be null.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object