a077deb457d9cd48b0ab98a50136609af31a3cee
[public/netxms.git] / src / java / client / netxms-client / src / main / java / org / netxms / client / datacollection / DciSummaryTableColumn.java
1 /**
2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2013 Victor Kirhenshtein
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 package org.netxms.client.datacollection;
20
21 import org.netxms.base.NXCPMessage;
22
23 /**
24 * Column definition for DCI summary table
25 */
26 public class DciSummaryTableColumn
27 {
28 public static int REGEXP_MATCH = 0x0001;
29 public static int MULTIVALUED = 0x0002;
30
31 private String name;
32 private String dciName;
33 private int flags;
34 private String separator;
35
36 /**
37 * @param name The column name
38 * @param dciName The dci name
39 * @param flags The flags
40 * @param separator Separator for multivalued columns
41 */
42 public DciSummaryTableColumn(String name, String dciName, int flags, String separator)
43 {
44 this.name = name;
45 this.dciName = dciName;
46 this.flags = flags;
47 this.separator = separator;
48 }
49
50 /**
51 * Copy constructor.
52 *
53 * @param src The source object
54 */
55 public DciSummaryTableColumn(DciSummaryTableColumn src)
56 {
57 name = src.name;
58 dciName = src.dciName;
59 flags = src.flags;
60 separator = src.separator;
61 }
62
63 /**
64 * @param msg The NXCPMessage
65 * @param baseId The base ID
66 */
67 public void fillMessage(NXCPMessage msg, long baseId)
68 {
69 msg.setField(baseId, name);
70 msg.setField(baseId + 1, dciName);
71 msg.setFieldInt32(baseId + 2, flags);
72 msg.setField(baseId + 3, separator);
73 }
74
75 /**
76 * @return the name
77 */
78 public String getName()
79 {
80 return name;
81 }
82
83 /**
84 * @return the dciName
85 */
86 public String getDciName()
87 {
88 return dciName;
89 }
90
91 /**
92 * @param name the name to set
93 */
94 public void setName(String name)
95 {
96 this.name = name;
97 }
98
99 /**
100 * @param dciName the dciName to set
101 */
102 public void setDciName(String dciName)
103 {
104 this.dciName = dciName;
105 }
106
107 /**
108 * Get separator for multivalued column
109 *
110 * @return separator for multivalued column
111 */
112 public String getSeparator()
113 {
114 return separator;
115 }
116
117 /**
118 * Set separator for multivalued column
119 *
120 * @param separator new separator for multivalued column
121 */
122 public void setSeparator(String separator)
123 {
124 this.separator = ((separator != null) && !separator.isEmpty()) ? separator : ";";
125 }
126
127 /**
128 * @return true if match
129 */
130 public boolean isRegexpMatch()
131 {
132 return (flags & REGEXP_MATCH) != 0;
133 }
134
135 /**
136 * @param enable true to enable
137 */
138 public void setRegexpMatch(boolean enable)
139 {
140 if (enable)
141 flags |= REGEXP_MATCH;
142 else
143 flags &= ~REGEXP_MATCH;
144 }
145
146 /**
147 * @return true if column is multivalued
148 */
149 public boolean isMultivalued()
150 {
151 return (flags & MULTIVALUED) != 0;
152 }
153
154 /**
155 * @param enable true to set column as multivalued
156 */
157 public void setMultivalued(boolean enable)
158 {
159 if (enable)
160 flags |= MULTIVALUED;
161 else
162 flags &= ~MULTIVALUED;
163 }
164
165 /**
166 * @return the flags
167 */
168 public int getFlags()
169 {
170 return flags;
171 }
172
173 /* (non-Javadoc)
174 * @see java.lang.Object#toString()
175 */
176 @Override
177 public String toString()
178 {
179 return "DciSummaryTableColumn [name=" + name + ", dciName=" + dciName + ", flags=" + flags + ", separator=" + separator + "]";
180 }
181 }