KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > steadystate > css > dom > CounterImpl


1 /*
2  * CounterImpl.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: CounterImpl.java,v 1.1.1.1 2003/12/28 21:22:44 davidsch Exp $
29  */

30  
31 package com.steadystate.css.dom;
32
33 import java.io.Serializable JavaDoc;
34 import org.w3c.dom.css.*;
35 import org.w3c.css.sac.*;
36
37 /**
38  *
39  * @author David Schweinsberg
40  * @version $Release$
41  */

42 public class CounterImpl implements Counter, Serializable JavaDoc {
43
44     private String JavaDoc _identifier;
45     private String JavaDoc _listStyle;
46     private String JavaDoc _separator;
47     
48     /** Creates new CounterImpl */
49     public CounterImpl(boolean separatorSpecified, LexicalUnit lu) {
50         LexicalUnit next = lu;
51         _identifier = next.getStringValue();
52         next = next.getNextLexicalUnit();
53         if (separatorSpecified && (next != null)) {
54             next = next.getNextLexicalUnit();
55             _separator = next.getStringValue();
56             next = next.getNextLexicalUnit();
57         }
58         if (next != null) {
59             _listStyle = next.getStringValue();
60             next = next.getNextLexicalUnit();
61         }
62     }
63
64     public String JavaDoc getIdentifier() {
65         return _identifier;
66     }
67
68     public String JavaDoc getListStyle() {
69         return _listStyle;
70     }
71
72     public String JavaDoc getSeparator() {
73         return _separator;
74     }
75     
76     public String JavaDoc toString() {
77         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
78         if (_separator == null) {
79             // This is a 'counter()' function
80
sb.append("counter(");
81         } else {
82             // This is a 'counters()' function
83
sb.append("counters(");
84         }
85         sb.append(_identifier);
86         if (_separator != null) {
87             sb.append(", \"").append(_separator).append("\"");
88         }
89         if (_listStyle != null) {
90             sb.append(", ").append(_listStyle);
91         }
92         sb.append(")");
93         return sb.toString();
94     }
95 }
Popular Tags