KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > core > config > GraphConfig


1 /**
2  * Copyright 2004-2005 jManage.org
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.jmanage.core.config;
17
18 import org.jmanage.core.util.Expression;
19
20 import java.util.List JavaDoc;
21 import java.util.Iterator JavaDoc;
22
23 /**
24  *
25  * Date: Jun 12, 2005
26  * @author Rakesh Kalra
27  */

28 public class GraphConfig {
29
30     private String JavaDoc id;
31     private String JavaDoc name;
32     private long pollingInterval;
33     // optional attributes
34
private String JavaDoc yAxisLabel;
35     private Double JavaDoc scaleFactor;
36     private Boolean JavaDoc scaleUp;
37
38     // list of GraphAttrbuteConfig objects
39
private List JavaDoc attributes;
40     private ApplicationConfig appConfig;
41
42     public static String JavaDoc getNextGraphId(){
43         return String.valueOf(System.currentTimeMillis());
44     }
45
46     public GraphConfig(String JavaDoc id,
47                        String JavaDoc name,
48                        long pollingInterval,
49                        ApplicationConfig appConfig,
50                        List JavaDoc attributes){
51         this.id = id;
52         this.name = name;
53         this.pollingInterval = pollingInterval;
54         this.appConfig = appConfig;
55         this.attributes = attributes;
56     }
57
58     public String JavaDoc getId() {
59         return id;
60     }
61
62     public String JavaDoc getName() {
63         return name;
64     }
65
66     public long getPollingInterval() {
67         return pollingInterval;
68     }
69
70     public List JavaDoc getAttributes() {
71         return attributes;
72     }
73
74     public ApplicationConfig getAppConfig() {
75         return appConfig;
76     }
77
78     /**
79      * Output is of the format:
80      * <p>
81      * [applicationId/jmanage:name=Configuration/AppUptime],
82      * [testApp2/jmanage:name=Configuration/AppUptime]
83      * @return
84      */

85     public String JavaDoc getAttributesAsString() {
86         StringBuffer JavaDoc graphAttributes = new StringBuffer JavaDoc();
87         for(Iterator JavaDoc it=attributes.iterator(); it.hasNext();){
88             if(graphAttributes.length() > 0){
89                 graphAttributes.append(",");
90             }
91             GraphAttributeConfig attrConfig = (GraphAttributeConfig)it.next();
92
93             // todo: it will be good to bring in a concept of ExpressionList
94
// todo: object which parses an expression into multiple
95
// todo: Expression objects - RK
96
graphAttributes.append("[");
97             Expression expr = new Expression(appConfig.getName(),
98                     attrConfig.getMBean(),
99                     attrConfig.getAttribute());
100             graphAttributes.append(expr.toString());
101             graphAttributes.append("]");
102         }
103         return graphAttributes.toString();
104     }
105
106     /**
107      * output if of the form
108      * @return
109      */

110     public String JavaDoc getAttributeDisplayNames(){
111         StringBuffer JavaDoc displayNames = new StringBuffer JavaDoc();
112         for(Iterator JavaDoc it=attributes.iterator(); it.hasNext();){
113             if(displayNames.length() > 0){
114                 displayNames.append("|");
115             }
116             GraphAttributeConfig attrConfig = (GraphAttributeConfig)it.next();
117             displayNames.append(attrConfig.getDisplayName());
118         }
119         return displayNames.toString();
120     }
121
122     public void setName(String JavaDoc name) {
123         this.name = name;
124     }
125
126     public void setPollingInterval(long pollingInterval) {
127         this.pollingInterval = pollingInterval;
128     }
129
130     public void setAttributes(List JavaDoc attributes) {
131         this.attributes = attributes;
132     }
133
134     public void setAppConfig(ApplicationConfig appConfig) {
135         this.appConfig = appConfig;
136     }
137
138     public String JavaDoc getYAxisLabel() {
139         return this.yAxisLabel;
140     }
141
142     public Double JavaDoc getScaleFactor() {
143         return this.scaleFactor;
144     }
145
146     public Boolean JavaDoc isScaleUp() {
147         return this.scaleUp;
148     }
149
150     public void setYAxisLabel(String JavaDoc yAxisLabel) {
151         this.yAxisLabel = yAxisLabel;
152     }
153
154     public void setScaleFactor(Double JavaDoc scaleFactor) {
155         this.scaleFactor = scaleFactor;
156     }
157
158     public void setScaleUp(Boolean JavaDoc scaleUp) {
159         this.scaleUp = scaleUp;
160     }
161 }
162
Popular Tags