示例#1
0
  /**
   * Parse the style sheet from the given reader.
   *
   * @param reader The reader pointing at the style sheet.
   * @throws IOException For any kind of I/O error or parse error.
   */
  protected void parse(Reader reader) throws IOException {
    StyleSheetParser parser = new StyleSheetParser(this, reader);

    try {
      parser.start();
    } catch (ParseException e) {
      throw new IOException(e.getMessage());
    }
  }
示例#2
0
  /**
   * Parse only one style, create a rule with the given selector, and add this rule.
   *
   * @param select The elements for which this style must apply.
   * @param styleString The style string to parse.
   */
  public void parseStyleFromString(Selector select, String styleString) throws IOException {
    StyleSheetParser parser = new StyleSheetParser(this, new StringReader(styleString));

    Style style = new Style();

    try {
      parser.stylesStart(style);
    } catch (ParseException e) {
      throw new IOException(e.getMessage());
    }

    Rule rule = new Rule(select);

    rule.setStyle(style);
    addRule(rule);
  }