Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/steadystate/css/dom/CSSRuleListImpl.java


1   /*
2    * CSSRuleListImpl.java
3    *
4    * Steady State CSS2 Parser
5    *
6    * Copyright (C) 1999, 2002 Steady State Software Ltd.  All rights reserved.
7    *
8    * This library is free software; you can redistribute it and/or
9    * modify it under the terms of the GNU Lesser General Public
10   * License as published by the Free Software Foundation; either
11   * version 2 of the License, or (at your option) any later version.
12   *
13   * This library is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16   * Lesser General Public License for more details.
17   *
18   * You should have received a copy of the GNU Lesser General Public
19   * License along with this library; if not, write to the Free Software
20   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21   *
22   * To contact the authors of the library, write to Steady State Software Ltd.,
23   * 49 Littleworth, Wing, Buckinghamshire, LU7 0JX, England
24   *
25   * http://www.steadystate.com/css/
26   * mailto:css@steadystate.co.uk
27   *
28   * $Id: CSSRuleListImpl.java,v 1.1.1.1 2003/12/28 21:22:50 davidsch Exp $
29   */
30  
31  package com.steadystate.css.dom;
32  
33  import java.io.Serializable;
34  import java.util.Vector;
35  import org.w3c.dom.css.*;
36  
37  public class CSSRuleListImpl implements CSSRuleList, Serializable {
38      
39      private Vector _rules = null;
40  
41      public CSSRuleListImpl() {
42      }
43  
44      public int getLength() {
45          return (_rules != null) ? _rules.size() : 0;
46      }
47  
48      public CSSRule item(int index) {
49          return (_rules != null) ? (CSSRule) _rules.elementAt(index) : null;
50      }
51  
52      public void add(CSSRule rule) {
53          if (_rules == null) {
54              _rules = new Vector();
55          }
56          _rules.addElement(rule);
57      }
58      
59      public void insert(CSSRule rule, int index) {
60          if (_rules == null) {
61              _rules = new Vector();
62          }
63          _rules.insertElementAt(rule, index);
64      }
65      
66      public void delete(int index) {
67          if (_rules == null) {
68              _rules = new Vector();
69          }
70          _rules.removeElementAt(index);
71      }
72      
73      public String toString() {
74          StringBuffer sb = new StringBuffer();
75          for (int i = 0; i < getLength(); i++ ) {
76              sb.append(item(i).toString()).append("\r\n");
77          }
78          return sb.toString();
79      }
80  }