KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > dav > server > property > ranges > DAVRange


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19
20 package org.openharmonise.dav.server.property.ranges;
21
22 import org.openharmonise.commons.dsi.*;
23 import org.openharmonise.commons.xml.namespace.*;
24 import org.openharmonise.rm.resources.metadata.properties.ranges.*;
25 import org.w3c.dom.*;
26
27 import com.ibm.webdav.*;
28
29 /**
30  * This class wraps up the functionality for publishing Harmonise ranges to DAV XML and
31  * vice versa.
32  *
33  * @author Michael Bell
34  * @version $Revision: 1.1 $
35  * @since November 19, 2003
36  */

37 abstract public class DAVRange {
38
39
40     public static final String JavaDoc TYPE_STRING =
41     NamespaceType.XML_SCHEMA.getPrefix() + ":string";
42     public static final String JavaDoc TYPE_DATE =
43         NamespaceType.XML_SCHEMA.getPrefix() + ":date";
44     public static final String JavaDoc TYPE_DATETIME =
45         NamespaceType.XML_SCHEMA.getPrefix() + ":dateTime";
46     public static final String JavaDoc TYPE_INTEGER =
47         NamespaceType.XML_SCHEMA.getPrefix() + ":integer";
48     public static final String JavaDoc TYPE_FLOAT =
49         NamespaceType.XML_SCHEMA.getPrefix() + ":float";
50     public static final String JavaDoc TYPE_BOOLEAN =
51         NamespaceType.XML_SCHEMA.getPrefix() + ":boolean";
52     public static final String JavaDoc TYPE_URI =
53         NamespaceType.XML_SCHEMA.getPrefix() + ":anyURI";
54
55     protected AbstractDataStoreInterface m_dsi = null;
56     public static final String JavaDoc TAG_RANGE = "range";
57     public static final String JavaDoc TAG_VALUE = "value";
58     public static final String JavaDoc TAG_MINLENGTH = "minLength";
59     public static final String JavaDoc TAG_MAXLENGTH = "maxLength";
60     public static final String JavaDoc TAG_MININCLUSIVE = "minInclusive";
61     public static final String JavaDoc TAG_MAXINCLUSIVE = "maxInclusive";
62     public static final String JavaDoc TAG_MINEXCLUSIVE = "minExclusive";
63     public static final String JavaDoc TAG_MAXEXCLUSIVE = "maxExclusive";
64     public static final String JavaDoc TAG_RESTRICTION = "restriction";
65     public static final String JavaDoc TAG_LABELS = "labels";
66     public static final String JavaDoc ATTRIB_PREFIXED_BASE =
67         NamespaceType.XML_SCHEMA.getPrefix() + ":base";
68
69     protected Range m_range = null;
70
71     /**
72      * Creates an object with an interface to the data store.
73      */

74     public DAVRange(AbstractDataStoreInterface dsi) {
75         m_dsi = dsi;
76     }
77
78     /**
79      * Creates an object with an interface to the data store and a Harmonise range
80      * to be published.
81      */

82     public DAVRange(AbstractDataStoreInterface dsi, Range range) {
83         m_range = range;
84         m_dsi = dsi;
85     }
86     
87
88     /**
89      * @param dsi
90      * @param range
91      * @param davPropEl
92      */

93     public DAVRange(AbstractDataStoreInterface dsi, Range range, Element davPropEl) throws WebDAVException {
94         
95         m_range = range;
96         m_dsi = dsi;
97         populate(davPropEl);
98     }
99
100     /**
101      * Returns this range representation as DAV XML.
102      *
103      * @param doc
104      * @return
105      * @throws WebDAVException
106      */

107     public Element asXML(Document doc) throws WebDAVException {
108         Element rangeEl =
109             doc.createElementNS(NamespaceType.DAV.getURI(), TAG_RANGE);
110         rangeEl.setPrefix(NamespaceType.DAV.getPrefix());
111
112         addRangeDetails(rangeEl, m_range, doc);
113
114         return rangeEl;
115
116     }
117
118     /**
119      * Adds range details to the given range element.
120      *
121      * <p>Note: should never get called as this method is overridden by methods
122      * dealing with specific Harmonise ranges.</p>
123      *
124      * @param rangeEl
125      * @param range
126      * @param doc
127      * @throws WebDAVException
128      */

129     abstract protected void addRangeDetails(Element rangeEl, Range range, Document doc) throws WebDAVException ;
130
131
132     /**
133      * Returns the Harmonise range for this DAV range.
134      *
135      * @return
136      */

137     public Range getHarmoniseRange() {
138         return m_range;
139     }
140     
141     /**
142      * Populates this range object from the given XML element.
143      *
144      * @param propEl
145      * @throws WebDAVException
146      */

147     abstract public void populate(Element propEl) throws WebDAVException;
148
149 }
150
Popular Tags