KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > instrument > client > http > AbstractHTTPData


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 package org.apache.excalibur.instrument.client.http;
21
22 import org.apache.avalon.framework.configuration.Configuration;
23 import org.apache.avalon.framework.configuration.ConfigurationException;
24 import org.apache.avalon.framework.logger.AbstractLogEnabled;
25
26 import org.apache.excalibur.instrument.client.Data;
27 import org.apache.excalibur.instrument.client.InstrumentManagerConnection;
28
29 /**
30  *
31  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
32  * @version CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:23 $
33  * @since 4.1
34  */

35 abstract class AbstractHTTPData
36     extends AbstractLogEnabled
37     implements Data
38 {
39     /* Reference to the connection. */
40     private HTTPInstrumentManagerConnection m_connection;
41     
42     /* Description of the remote object. */
43     private String JavaDoc m_description;
44     
45     /** The current state version of the remote object. */
46     private int m_stateVersion;
47     
48     /*---------------------------------------------------------------
49      * Constructors
50      *-------------------------------------------------------------*/

51     /**
52      * Creates a new AbstractHTTPData.
53      *
54      * @param connection The connection used to communicate with the server.
55      * @param description An initial description.
56      */

57     protected AbstractHTTPData( HTTPInstrumentManagerConnection connection,
58                                 String JavaDoc description )
59     {
60         m_connection = connection;
61         m_description = description;
62         m_stateVersion = -1;
63     }
64     
65     /*---------------------------------------------------------------
66      * Data Methods
67      *-------------------------------------------------------------*/

68     /**
69      * Returns the InstrumentManagerConnection that owns the data object.
70      *
71      * @return The InstrumentManagerConnection that owns the data object.
72      */

73     public InstrumentManagerConnection getConnection()
74     {
75         return m_connection;
76     }
77     
78     /**
79      * Returns the description.
80      *
81      * @return The description.
82      */

83     public String JavaDoc getDescription()
84     {
85         return m_description;
86     }
87     
88     /**
89      * Returns the state version.
90      *
91      * @return The state version.
92      */

93     public int getStateVersion()
94     {
95         return m_stateVersion;
96     }
97     
98     /*---------------------------------------------------------------
99      * Methods
100      *-------------------------------------------------------------*/

101     /**
102      * Update the contents of the object using values from the Configuration object.
103      *
104      * @param configuration Configuration object to load from.
105      *
106      * @throws ConfigurationException If there are any problems.
107      */

108     protected void update( Configuration configuration )
109         throws ConfigurationException
110     {
111         m_description = configuration.getAttribute( "description", "" );
112         m_stateVersion = configuration.getAttributeAsInteger( "state-version", 0 );
113     }
114     
115     /**
116      * URL encode the specified string.
117      *
118      * @param val String to be URL encoded.
119      *
120      * @return The URL encoded string.
121      */

122     protected String JavaDoc urlEncode( String JavaDoc val )
123     {
124         return m_connection.urlEncode( val );
125     }
126 }
127
Popular Tags