View Javadoc

1   /*
2    * File:    AbstractModelBuilder.java
3    * Created: 28.05.2007 17:33:19 
4    *
5    * Copyright 2007 Michal Burda.
6    *
7    * This program is free software; you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation; either version 2 of the License, or
10   * (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, write to the Free Software
19   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20   */
21  
22  package net.sf.webmancer.model;
23  
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  
28  
29  /**
30   * @author Michal Burda
31   *
32   */
33  public abstract class AbstractModelBuilder implements IModelBuilder {
34  
35      /**
36       * 
37       */
38      private static final Map<String, String> EMPTY_ATTRIBUTES = new HashMap<String, String>();
39  
40      /**
41       * Constructs the AbstractModelBuilder.
42       *
43       */
44      public AbstractModelBuilder() {
45      }
46  
47      /**
48       * @see net.sf.webmancer.model.IModelBuilder#startElement(java.lang.String, java.lang.String, java.util.Map)
49       */
50      public abstract void startElement(String uri, String elementName, Map<String, String> attributes);
51  
52      /**
53       * @see net.sf.webmancer.model.IModelBuilder#text(java.lang.String)
54       */
55      public abstract void text(String text);
56  
57      /**
58       * @see net.sf.webmancer.model.IModelBuilder#endElement()
59       */
60      public abstract void endElement();
61  
62      /**
63       * @see net.sf.webmancer.model.IModelBuilder#element(java.lang.String, java.lang.String, java.util.Map, java.lang.String)
64       */
65      public void element(String uri, String elementName, Map<String, String> attributes, String text) {
66          this.startElement(uri, elementName, attributes);
67          this.text(text);
68          this.endElement();
69      }
70  
71      /**
72       * @see net.sf.webmancer.model.IModelBuilder#element(java.lang.String, java.lang.String, java.lang.String)
73       */
74      public void element(String uri, String elementName, String text) {
75          this.startElement(uri, elementName);
76          this.text(text);
77          this.endElement();
78      }
79  
80      /**
81       * @see net.sf.webmancer.model.IModelBuilder#element(java.lang.String, java.lang.String, java.util.Map)
82       */
83      public void element(String uri, String elementName, Map<String, String> attributes) {
84          this.startElement(uri, elementName, attributes);
85          this.endElement();
86      }
87  
88      /**
89       * @see net.sf.webmancer.model.IModelBuilder#element(java.lang.String, java.lang.String)
90       */
91      public void element(String uri, String elementName) {
92          this.startElement(uri, elementName);
93          this.endElement();
94      }
95  
96      /**
97       * @see net.sf.webmancer.model.IModelBuilder#startElement(java.lang.String, java.lang.String)
98       */
99      public void startElement(String uri, String elementName) {
100         this.startElement(uri, elementName, EMPTY_ATTRIBUTES);
101     }
102 
103 }