KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > webdav > WebDAVProperty


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.webdav;
18
19 /**
20  * Class to represent a WebDAV property
21  *
22  * @author gavinc
23  */

24 public class WebDAVProperty
25 {
26    private String JavaDoc m_strName = null;
27    private String JavaDoc m_strNamespaceUri = WebDAV.DEFAULT_NAMESPACE_URI;
28    private String JavaDoc m_strNamespaceName = null;
29    private String JavaDoc m_strValue = null;
30    
31    /**
32     * Constructs a WebDAVProperty
33     *
34     * @param strName
35     * @param strNamespaceUri
36     * @param strNamespaceName
37     * @param strValue
38     */

39    public WebDAVProperty(String JavaDoc strName, String JavaDoc strNamespaceUri, String JavaDoc strNamespaceName, String JavaDoc strValue)
40    {
41       this(strName, strNamespaceUri, strNamespaceName);
42       m_strValue = strValue;
43    }
44    
45    /**
46     * Constructs a WebDAVProperty
47     *
48     * @param strName
49     * @param strNamespaceUri
50     * @param strNamespaceName
51     * @param strValue
52     */

53    public WebDAVProperty(String JavaDoc strName, String JavaDoc strNamespaceUri, String JavaDoc strNamespaceName)
54    {
55       this(strName);
56       
57       m_strNamespaceUri = strNamespaceUri;
58       m_strNamespaceName = strNamespaceName;
59    }
60    
61    /**
62     * Constructs a WebDAVProperty with the default namespace details
63     *
64     * @param strName
65     */

66    public WebDAVProperty(String JavaDoc strName)
67    {
68       m_strName = strName;
69    }
70    
71    /**
72     * Returns the name of the property
73     *
74     * @return The name of the property
75     */

76    public String JavaDoc getName()
77    {
78       return m_strName;
79    }
80    
81    /**
82     * Returns the namespace URI for this property
83     *
84     * @return The namespace URI for this property
85     */

86    public String JavaDoc getNamespaceUri()
87    {
88       return m_strNamespaceUri;
89    }
90    
91    /**
92     * Determine if the property has a namespace
93     *
94     * @return boolean
95     */

96    public final boolean hasNamespaceName()
97    {
98        return m_strNamespaceName != null ? true : false;
99    }
100    
101    /**
102     * Returns the namespace name for this property
103     *
104     * @return The namespace name for this property
105     */

106    public String JavaDoc getNamespaceName()
107    {
108       return m_strNamespaceName;
109    }
110    
111    /**
112     * Returns the value of this property
113     *
114     * @return The value of this property
115     */

116    public String JavaDoc getValue()
117    {
118       return m_strValue;
119    }
120    
121    /**
122     * Sets the property's value
123     *
124     * @param strValue The new value
125     */

126    public void setValue(String JavaDoc strValue)
127    {
128       m_strValue = strValue;
129    }
130    
131    /**
132     * Return the property as a string
133     *
134     * @return String
135     */

136    public String JavaDoc toString()
137    {
138        StringBuilder JavaDoc str = new StringBuilder JavaDoc();
139        
140        str.append("[");
141        
142        str.append(getName());
143        str.append("=");
144        str.append(getValue());
145        str.append(",URI=");
146        str.append(getNamespaceUri());
147        
148        if ( hasNamespaceName())
149        {
150            str.append(",");
151            str.append(getNamespaceName());
152        }
153        
154        return str.toString();
155    }
156 }
157
Popular Tags