KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.UnsupportedEncodingException JavaDoc;
23 import java.net.URLEncoder JavaDoc;
24
25 import org.apache.avalon.framework.configuration.Configuration;
26 import org.apache.avalon.framework.configuration.ConfigurationException;
27 import org.apache.avalon.framework.logger.AbstractLogEnabled;
28
29 import org.apache.excalibur.instrument.client.Data;
30 import org.apache.excalibur.instrument.client.ElementData;
31
32 /**
33  *
34  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
35  * @version CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:23 $
36  * @since 4.1
37  */

38 abstract class AbstractHTTPElementData
39     extends AbstractHTTPData
40     implements ElementData
41 {
42     /* The parent data object, or null for the root. */
43     private AbstractHTTPData m_parent;
44     
45     /* The name of the data object. */
46     private String JavaDoc m_name;
47     
48     /* Name of the configured flag of the remote object. */
49     private boolean m_configured;
50     
51     /*---------------------------------------------------------------
52      * Static Methods
53      *-------------------------------------------------------------*/

54     /**
55      * Returns the last element of a name separated by '.'s
56      */

57     protected static String JavaDoc lastNameToken( String JavaDoc name )
58     {
59         int pos = name.lastIndexOf( '.' );
60         if ( pos >= 0 )
61         {
62             return name.substring( pos + 1 );
63         }
64         else
65         {
66             return name;
67         }
68     }
69     
70     /*---------------------------------------------------------------
71      * Constructors
72      *-------------------------------------------------------------*/

73     /**
74      * Creates a new AbstractHTTPElementData.
75      *
76      * @param connection The connection used to communicate with the server.
77      * @param parent The parent data element.
78      * @param name The name of the data element.
79      */

80     protected AbstractHTTPElementData( HTTPInstrumentManagerConnection connection,
81                                        AbstractHTTPData parent,
82                                        String JavaDoc name )
83     {
84         super( connection, lastNameToken( name ) );
85         m_parent = parent;
86         m_name = name;
87         m_configured = false;
88     }
89     
90     /*---------------------------------------------------------------
91      * HTTPElementData Methods
92      *-------------------------------------------------------------*/

93     /**
94      * Returns the parent data object.
95      *
96      * @return The parent data object.
97      */

98     public Data getParent()
99     {
100         return m_parent;
101     }
102     
103     /**
104      * Returns the name.
105      *
106      * @return The name.
107      */

108     public String JavaDoc getName()
109     {
110         return m_name;
111     }
112     
113     /**
114      * Returns the configured flag of the remote object.
115      *
116      * @return The configured flag of the remote object.
117      */

118     public boolean isConfigured()
119     {
120         return m_configured;
121     }
122     
123     /*---------------------------------------------------------------
124      * Methods
125      *-------------------------------------------------------------*/

126     /**
127      * Update the contents of the object using values from the Configuration object.
128      *
129      * @param configuration Configuration object to load from.
130      *
131      * @throws ConfigurationException If there are any problems.
132      */

133     protected void update( Configuration configuration )
134         throws ConfigurationException
135     {
136         super.update( configuration );
137         
138         m_configured = configuration.getAttributeAsBoolean( "configured", false );
139     }
140 }
141
Popular Tags