Added range type to subject-feature-definition/parameter
[groupbasedpolicy.git] / renderers / opflex / src / main / java / org / opendaylight / groupbasedpolicy / renderer / opflex / mit / PolicyObjectInstance.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.groupbasedpolicy.renderer.opflex.mit;
9
10 import java.math.BigInteger;
11 import java.util.ArrayList;
12 import java.util.HashMap;
13 import java.util.List;
14
15 import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyId;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
18
19 /**
20  * This is a policy object instance, used to provide an abstraction
21  * between OpFlex messaging and the back-end policy.
22  *
23  * @author tbachman
24  *
25  */
26 public class PolicyObjectInstance {
27
28         /**
29          * An object used as a key for the property hash map. It
30          * consists of the tuple: { {@link PolicyPropertyId},
31          * {@link PolicyPropertyInfo.PropertyType},
32          * {@link PolicyPropertyInfo.Propertycardinality} }
33          *
34          * @author tbachman
35          *
36          */
37         public static class PropertyKey {
38                 private final PolicyPropertyId propId;
39                 private final PolicyPropertyInfo.PropertyType type;
40                 private final PolicyPropertyInfo.PropertyCardinality cardinality;
41
42                 public PropertyKey(PolicyPropertyId propId, PolicyPropertyInfo.PropertyType type,
43                                 PolicyPropertyInfo.PropertyCardinality cardinality) {
44                         this.propId = propId;
45                         this.type = type;
46                         this.cardinality = cardinality;
47                 }
48
49                 @Override
50                 public int hashCode() {
51                         final int prime = 31;
52                         int result = 1;
53                         result = prime * result
54                                         + ((cardinality == null) ? 0 : cardinality.hashCode());
55                         result = prime * result
56                                         + ((propId == null) ? 0 : propId.hashCode());
57                         result = prime * result + ((type == null) ? 0 : type.hashCode());
58                         return result;
59                 }
60
61                 @Override
62                 public boolean equals(Object obj) {
63                         if (this == obj)
64                                 return true;
65                         if (obj == null)
66                                 return false;
67                         if (getClass() != obj.getClass())
68                                 return false;
69                         PropertyKey other = (PropertyKey) obj;
70                         if (cardinality != other.cardinality)
71                                 return false;
72                         if (propId == null) {
73                                 if (other.propId != null)
74                                         return false;
75                         } else if (!propId.equals(other.propId))
76                                 return false;
77                         if (type != other.type)
78                                 return false;
79                         return true;
80                 }
81
82         }
83
84         /**
85          * Class that contains a value held by the {@link PolicyObjectInstance}.
86          * The value can be scalar or vector in nature.
87          *
88          * @author tbachman
89          *
90          */
91         public static class Value {
92                 private Object v;
93                 private List<Object> vl;
94                 private PolicyPropertyInfo.PropertyType type;
95                 private PolicyPropertyInfo.PropertyCardinality cardinality;
96                 public void setPropertyType(PolicyPropertyInfo.PropertyType type) {
97                         this.type = type;
98                 }
99
100                 public void setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality cardinality) {
101                         this.cardinality = cardinality;
102                 }
103
104                 public void setValue(Object v) {
105                         this.v = v;
106                 }
107
108                 public void setValue(List<Object> vl) {
109                         this.vl = vl;
110                 }
111
112                 public Object getValue(int index) {
113                         if (this.cardinality == PolicyPropertyInfo.PropertyCardinality.VECTOR) {
114                                 return this.vl.get(index);
115                         }
116                         else {
117                                 return this.v;
118                         }
119                 }
120
121                 public PolicyPropertyInfo.PropertyType getType() {
122                         return this.type;
123                 }
124         }
125
126         /**
127          * Class used as a reference to another PolicyObject.
128          *
129          * @author tbachman
130          *
131          */
132         public static class PolicyReference {
133                 private final Uri uri;
134                 private final long classId;
135
136                 public PolicyReference(long classId, Uri uri) {
137                         this.uri = uri;
138                         this.classId = classId;
139                 }
140
141                 public Uri getUri() {
142                         return this.uri;
143                 }
144
145                 public long getClassId() {
146                         return this.classId;
147                 }
148
149                 @Override
150                 public int hashCode() {
151                         final int prime = 31;
152                         int result = 1;
153                         result = prime * result + (int) (classId ^ (classId >>> 32));
154                         result = prime * result + ((uri == null) ? 0 : uri.hashCode());
155                         return result;
156                 }
157
158                 @Override
159                 public boolean equals(Object obj) {
160                         if (this == obj)
161                                 return true;
162                         if (obj == null)
163                                 return false;
164                         if (getClass() != obj.getClass())
165                                 return false;
166                         PolicyReference other = (PolicyReference) obj;
167                         if (classId != other.classId)
168                                 return false;
169                         if (uri == null) {
170                                 if (other.uri != null)
171                                         return false;
172                         } else if (!uri.equals(other.uri))
173                                 return false;
174                         return true;
175                 }
176
177         }
178
179         private long classId;
180         private Uri uri;
181         private Uri parentUri;
182         private String parentSubject;
183         private String parentRelation;
184         private List<Uri> children;
185         private HashMap<PropertyKey, Value> propertyMap;
186
187         private PolicyPropertyInfo.PropertyType normalize(PolicyPropertyInfo.PropertyType type) {
188                 switch (type) {
189                 case ENUM8:
190                 case ENUM16:
191                 case ENUM32:
192                 case ENUM64:
193                         return PolicyPropertyInfo.PropertyType.U64;
194             default:
195                 return type;
196                 }
197         }
198
199         public PolicyObjectInstance(long classId) {
200                 this.classId = classId;
201                 this.children = new ArrayList<Uri>();
202                 this.propertyMap = new HashMap<PropertyKey, Value>();
203         }
204
205         /**
206          * Get the class ID for this object instance.
207          *
208          * @return the class ID
209          */
210         public long getClassId() {
211                 return this.classId;
212         }
213
214         public Uri getUri() {
215                 return uri;
216         }
217
218         public void setUri(Uri uri) {
219                 this.uri = uri;
220         }
221
222         public void addChild(Uri childUri) {
223                 children.add(childUri);
224         }
225
226         public List<Uri> getChildren() {
227                 return this.children;
228         }
229
230         public void setParent(Uri uri) {
231                 this.parentUri = uri;
232         }
233
234         public Uri getParent() {
235                 return this.parentUri;
236         }
237
238         public void setParentSubject(String subject) {
239                 this.parentSubject = subject;
240         }
241
242         public String getParentSubject() {
243                 return this.parentSubject;
244         }
245
246         public void setParentRelation(String relation) {
247                 this.parentRelation = relation;
248         }
249
250         public String getParentRelation() {
251                 return this.parentRelation;
252         }
253
254         /**
255          * Check whether the given property is set.  If the property is
256          * vector-valued, this will return false if the vector is zero length
257          *
258          * @param propId
259          * @param type
260          * @param cardinality
261          * @return true if set, false if not set or zero length vector
262          */
263         public boolean isSet(PolicyPropertyInfo.PolicyPropertyId propId,
264                         PolicyPropertyInfo.PropertyType type,
265                         PolicyPropertyInfo.PropertyCardinality cardinality) {
266                 type = normalize(type);
267                 PropertyKey key = new PropertyKey(propId, type, cardinality);
268                 return propertyMap.containsKey(key);
269         }
270
271         /**
272          * Unset the given property.  If it's a vector, the vector is
273          * emptied.  If its a scalar, the scalar is unset.
274          *
275          * @param propId
276          * @param type
277          * @param cardinality
278          * @return true if the property was alread set before
279          */
280         public boolean unset(PolicyPropertyInfo.PolicyPropertyId propId,
281                         PolicyPropertyInfo.PropertyType type,
282                         PolicyPropertyInfo.PropertyCardinality cardinality) {
283                 type = normalize(type);
284                 PropertyKey key = new PropertyKey(propId, type, cardinality);
285                 Value v = propertyMap.remove(key);
286                 if (v == null) return false;
287                 return true;
288         }
289
290         // getters
291
292         /**
293          * Get the unsigned 64-bit valued property for prop_name.
294          *
295          * @param id
296          * @return null if not present or {@link BigInteger}
297          */
298         public BigInteger getUint64(PolicyPropertyInfo.PolicyPropertyId id) {
299                 PropertyKey key =
300                                 new PropertyKey(id,
301                                                         PolicyPropertyInfo.PropertyType.U64,
302                                                         PolicyPropertyInfo.PropertyCardinality.SCALAR);
303                 return (BigInteger)propertyMap.get(key).getValue(0);
304         }
305
306         /**
307          * For a vector-valued 64-bit unsigned property, get the specified
308          * property value at the specified index
309          *
310          * @param id
311          * @param index
312          * @return the property value
313          */
314         public BigInteger getUint64(PolicyPropertyInfo.PolicyPropertyId id, int index) {
315                 PropertyKey key =
316                                 new PropertyKey(id,
317                                                         PolicyPropertyInfo.PropertyType.U64,
318                                                         PolicyPropertyInfo.PropertyCardinality.VECTOR);
319                 return (BigInteger)propertyMap.get(key).getValue(index);
320         }
321
322         /**
323          * Get the number of unsigned 64-bit values for the specified
324          * property
325          *
326          * @param id
327          * @return the number of elements
328          */
329         public int getUint64Size(PolicyPropertyInfo.PolicyPropertyId id) {
330                 PropertyKey key =
331                                 new PropertyKey(id,
332                                                         PolicyPropertyInfo.PropertyType.U64,
333                                                         PolicyPropertyInfo.PropertyCardinality.VECTOR);
334                 Value v = propertyMap.get(key);
335                 return v.vl.size();
336         }
337
338         /**
339          * Get the signed 64-bit valued property for prop_name.
340          *
341          * @param id
342          * @return the property value
343          */
344         public long getInt64(PolicyPropertyInfo.PolicyPropertyId id) {
345                 PropertyKey key =
346                                 new PropertyKey(id,
347                                                         PolicyPropertyInfo.PropertyType.S64,
348                                                         PolicyPropertyInfo.PropertyCardinality.SCALAR);
349                 return (long)propertyMap.get(key).getValue(0);
350         }
351
352         /**
353          * For a vector-valued 64-bit signed property, get the specified
354          * property value at the specified index
355          *
356          * @param id
357          * @param index
358          * @return the property value
359          */
360         public long getInt64(PolicyPropertyInfo.PolicyPropertyId id, int index) {
361                 PropertyKey key =
362                                 new PropertyKey(id,
363                                                         PolicyPropertyInfo.PropertyType.S64,
364                                                         PolicyPropertyInfo.PropertyCardinality.VECTOR);
365                 return (long)propertyMap.get(key).getValue(index);
366         }
367
368         /**
369          * Get the number of signed 64-bit values for the specified
370          * property
371          *
372          * @param id
373          * @return the number of elements
374          */
375         public int getInt64Size(PolicyPropertyInfo.PolicyPropertyId id) {
376                 PropertyKey key =
377                                 new PropertyKey(id,
378                                                         PolicyPropertyInfo.PropertyType.S64,
379                                                         PolicyPropertyInfo.PropertyCardinality.VECTOR);
380                 Value v = propertyMap.get(key);
381                 return v.vl.size();
382         }
383
384         /**
385          * Get the string-valued property for prop_name.
386          *
387          * @param id
388          * @return the property value
389          */
390         public String getString(PolicyPropertyInfo.PolicyPropertyId id) {
391                 PropertyKey key =
392                                 new PropertyKey(id,
393                                                         PolicyPropertyInfo.PropertyType.STRING,
394                                                         PolicyPropertyInfo.PropertyCardinality.SCALAR);
395                 return (String)propertyMap.get(key).getValue(0);
396         }
397
398         /**
399          * For a vector-valued string property, get the specified property
400          * value at the specified index
401          *
402          * @param id
403          * @param index
404          * @return the property value
405          */
406         public String getString(PolicyPropertyInfo.PolicyPropertyId id, int index) {
407                 PropertyKey key =
408                                 new PropertyKey(id,
409                                                         PolicyPropertyInfo.PropertyType.STRING,
410                                                         PolicyPropertyInfo.PropertyCardinality.VECTOR);
411                 return (String)propertyMap.get(key).getValue(index);
412         }
413
414         /**
415          * Get the number of string values for the specified property
416          *
417          * @param id
418          * @return the number of elements
419          */
420         public int getStringSize(PolicyPropertyInfo.PolicyPropertyId id) {
421                 PropertyKey key =
422                                 new PropertyKey(id,
423                                                         PolicyPropertyInfo.PropertyType.STRING,
424                                                         PolicyPropertyInfo.PropertyCardinality.VECTOR);
425                 Value v = propertyMap.get(key);
426                 return v.vl.size();
427         }
428
429         /**
430          * Get the reference-valued property for prop_name.
431          * @param id
432          * @return the property value
433          */
434         public PolicyReference getReference(PolicyPropertyInfo.PolicyPropertyId id) {
435                 PropertyKey key =
436                                 new PropertyKey(id,
437                                                         PolicyPropertyInfo.PropertyType.REFERENCE,
438                                                         PolicyPropertyInfo.PropertyCardinality.SCALAR);
439                 return (PolicyReference)propertyMap.get(key).getValue(0);
440         }
441
442         /**
443          * For a vector-valued reference property, get the specified property
444          * value at the specified index
445          *
446          * @param id
447          * @param index
448          * @return the property value
449          */
450         public PolicyReference getReference(PolicyPropertyInfo.PolicyPropertyId id, int index) {
451                 PropertyKey key =
452                                 new PropertyKey(id,
453                                                         PolicyPropertyInfo.PropertyType.REFERENCE,
454                                                         PolicyPropertyInfo.PropertyCardinality.VECTOR);
455                 return (PolicyReference)propertyMap.get(key).getValue(index);
456         }
457
458         /**
459          * Get the number of reference values for the specified property
460          *
461          * @param id
462          * @return the number of elements
463          */
464         public int getReferenceSize(PolicyPropertyInfo.PolicyPropertyId id) {
465                 PropertyKey key =
466                                 new PropertyKey(id,
467                                                         PolicyPropertyInfo.PropertyType.REFERENCE,
468                                                         PolicyPropertyInfo.PropertyCardinality.VECTOR);
469                 Value v = propertyMap.get(key);
470                 return v.vl.size();
471         }
472
473         /**
474          * Get the MAC-address-valued property for prop_name.
475          *
476          * @param id
477          * @return the property value
478          */
479         public MacAddress getMacAddress(PolicyPropertyInfo.PolicyPropertyId id) {
480                 PropertyKey key =
481                                 new PropertyKey(id,
482                                                         PolicyPropertyInfo.PropertyType.MAC,
483                                                         PolicyPropertyInfo.PropertyCardinality.SCALAR);
484                 return (MacAddress)propertyMap.get(key).getValue(0);
485         }
486
487         /**
488          * For a vector-valued MAC address property, get the specified
489          * property value at the specified index
490          *
491          * @param id
492          * @param index
493          * @return the property value
494          */
495         public MacAddress getMacAddress(PolicyPropertyInfo.PolicyPropertyId id, int index) {
496                 PropertyKey key =
497                                 new PropertyKey(id,
498                                                         PolicyPropertyInfo.PropertyType.MAC,
499                                                         PolicyPropertyInfo.PropertyCardinality.VECTOR);
500                 return (MacAddress)propertyMap.get(key).getValue(index);
501         }
502
503         /**
504          * Get the number of MAC address values for the specified
505          * property
506          *
507          * @param id
508          * @return the number of elements
509          */
510         public int getMacAddressSize(PolicyPropertyInfo.PolicyPropertyId id) {
511                 PropertyKey key =
512                                 new PropertyKey(id,
513                                                         PolicyPropertyInfo.PropertyType.MAC,
514                                                         PolicyPropertyInfo.PropertyCardinality.VECTOR);
515                 Value v = propertyMap.get(key);
516                 return v.vl.size();
517         }
518
519         // setters
520         /**
521          * Set the uint64-valued parameter to the specified value.
522          *
523          * @param id
524          * @param bi
525          */
526         public void setUint64(PolicyPropertyInfo.PolicyPropertyId id, BigInteger bi) {
527                 PropertyKey key =
528                                 new PropertyKey(id,
529                                                                 PolicyPropertyInfo.PropertyType.U64,
530                                                                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
531                 Value v = propertyMap.get(key);
532                 if (v == null) v = new Value(); propertyMap.put(key, v);
533
534                 v.setPropertyType(PolicyPropertyInfo.PropertyType.U64);
535                 v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR);
536                 v.setValue(bi);
537         }
538
539         /**
540          * Set the uint64-vector-valued parameter to the specified value.
541          *
542          * @param id
543          * @param bil
544          */
545         public void setUint64(PolicyPropertyInfo.PolicyPropertyId id, List<BigInteger> bil) {
546                 PropertyKey key =
547                                 new PropertyKey(id,
548                                                                 PolicyPropertyInfo.PropertyType.U64,
549                                                                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
550                 Value v = propertyMap.get(key);
551                 if (v == null) v = new Value(); propertyMap.put(key, v);
552
553                 v.setPropertyType(PolicyPropertyInfo.PropertyType.U64);
554                 v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
555                 v.setValue(bil);
556
557         }
558
559         /**
560          * Set the int64-valued parameter to the specified value.
561          *
562          * @param id
563          * @param li
564          */
565         public void setInt64(PolicyPropertyInfo.PolicyPropertyId id, long li) {
566                 PropertyKey key =
567                                 new PropertyKey(id,
568                                                                 PolicyPropertyInfo.PropertyType.S64,
569                                                                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
570                 Value v = propertyMap.get(key);
571                 if (v == null) v = new Value(); propertyMap.put(key, v);
572
573                 v.setPropertyType(PolicyPropertyInfo.PropertyType.S64);
574                 v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR);
575                 v.setValue(li);
576
577         }
578
579         /**
580          * Set the int64-vector-valued parameter to the specified value.
581          *
582          * @param id
583          * @param ll
584          */
585         public void setInt64(PolicyPropertyInfo.PolicyPropertyId id, List<Long> ll) {
586                 PropertyKey key =
587                                 new PropertyKey(id,
588                                                                 PolicyPropertyInfo.PropertyType.S64,
589                                                                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
590                 Value v = propertyMap.get(key);
591                 if (v == null) v = new Value(); propertyMap.put(key, v);
592
593                 v.setPropertyType(PolicyPropertyInfo.PropertyType.S64);
594                 v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
595                 v.setValue(ll);
596
597         }
598
599         /**
600          * Set the string-valued parameter to the specified value.
601          *
602          * @param id
603          * @param s
604          */
605         public void setString(PolicyPropertyInfo.PolicyPropertyId id, String s) {
606                 PropertyKey key =
607                                 new PropertyKey(id,
608                                                                 PolicyPropertyInfo.PropertyType.STRING,
609                                                                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
610                 Value v = propertyMap.get(key);
611                 if (v == null) v = new Value(); propertyMap.put(key, v);
612
613                 v.setPropertyType(PolicyPropertyInfo.PropertyType.STRING);
614                 v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR);
615                 v.setValue(s);
616
617         }
618
619         /**
620          * Set the string-vector-valued parameter to the specified vector.
621          *
622          * @param id
623          * @param sl
624          */
625         public void setString(PolicyPropertyInfo.PolicyPropertyId id, List<String> sl) {
626                 PropertyKey key =
627                                 new PropertyKey(id,
628                                                                 PolicyPropertyInfo.PropertyType.STRING,
629                                                                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
630                 Value v = propertyMap.get(key);
631                 if (v == null) v = new Value(); propertyMap.put(key, v);
632
633                 v.setPropertyType(PolicyPropertyInfo.PropertyType.STRING);
634                 v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
635                 v.setValue(sl);
636
637         }
638
639         /**
640          * Set the reference-valued parameter to the specified value.
641          *
642          * @param id
643          * @param pr
644          */
645         public void setReference(PolicyPropertyInfo.PolicyPropertyId id, PolicyReference pr) {
646                 PropertyKey key =
647                                 new PropertyKey(id,
648                                                                 PolicyPropertyInfo.PropertyType.REFERENCE,
649                                                                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
650                 Value v = propertyMap.get(key);
651                 if (v == null) v = new Value(); propertyMap.put(key, v);
652
653                 v.setPropertyType(PolicyPropertyInfo.PropertyType.REFERENCE);
654                 v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR);
655                 v.setValue(pr);
656
657         }
658
659         /**
660          * Set the reference-vector-valued parameter to the specified
661          * vector.
662          *
663          * @param id
664          * @param prl
665          */
666         public void setReference(PolicyPropertyInfo.PolicyPropertyId id, List<PolicyReference> prl) {
667                 PropertyKey key =
668                                 new PropertyKey(id,
669                                                                 PolicyPropertyInfo.PropertyType.REFERENCE,
670                                                                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
671                 Value v = propertyMap.get(key);
672                 if (v == null) v = new Value(); propertyMap.put(key, v);
673
674                 v.setPropertyType(PolicyPropertyInfo.PropertyType.REFERENCE);
675                 v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
676                 v.setValue(prl);
677
678         }
679
680         /**
681          * Set the MAC address-valued parameter to the specified value.
682          *
683          * @param id
684          * @param mac
685          */
686         public void setMacAddress(PolicyPropertyInfo.PolicyPropertyId id, MacAddress mac) {
687                 PropertyKey key =
688                                 new PropertyKey(id,
689                                                                 PolicyPropertyInfo.PropertyType.MAC,
690                                                                 PolicyPropertyInfo.PropertyCardinality.SCALAR);
691                 Value v = propertyMap.get(key);
692                 if (v == null) v = new Value(); propertyMap.put(key, v);
693
694                 v.setPropertyType(PolicyPropertyInfo.PropertyType.MAC);
695                 v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR);
696                 v.setValue(mac);
697
698         }
699
700         /**
701          * Set the MAC address-vector-valued parameter to the specified value.
702          *
703          * @param id
704          * @param macList
705          */
706         public void setMacAddress(PolicyPropertyInfo.PolicyPropertyId id, List<MacAddress> macList) {
707                 PropertyKey key =
708                                 new PropertyKey(id,
709                                                                 PolicyPropertyInfo.PropertyType.MAC,
710                                                                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
711                 Value v = propertyMap.get(key);
712                 if (v == null) v = new Value(); propertyMap.put(key, v);
713
714                 v.setPropertyType(PolicyPropertyInfo.PropertyType.MAC);
715                 v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
716                 v.setValue(macList);
717
718         }
719
720         /**
721          * Add a value to a the specified unsigned 64-bit vector.
722          *
723          * @param id
724          * @param bi
725          */
726         public void addUint64(PolicyPropertyInfo.PolicyPropertyId id, BigInteger bi) {
727                 PropertyKey key =
728                                 new PropertyKey(id,
729                                                                 PolicyPropertyInfo.PropertyType.U64,
730                                                                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
731                 Value v = propertyMap.get(key);
732                 if (v == null)  {
733                         v = new Value();
734                         v.setPropertyType(PolicyPropertyInfo.PropertyType.U64);
735                         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
736                         List<BigInteger> bil = new ArrayList<BigInteger>();
737                         v.setValue(bil);
738                         propertyMap.put(key, v);
739                 }
740                 v.vl.add(bi);
741         }
742
743         /**
744          * Add a value to a the specified signed 64-bit vector.
745          *
746          * @param id
747          * @param li
748          */
749         public void addInt64(PolicyPropertyInfo.PolicyPropertyId id, long li) {
750                 PropertyKey key =
751                                 new PropertyKey(id,
752                                                                 PolicyPropertyInfo.PropertyType.S64,
753                                                                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
754                 Value v = propertyMap.get(key);
755                 if (v == null)  {
756                         v = new Value();
757                         v.setPropertyType(PolicyPropertyInfo.PropertyType.U64);
758                         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
759                         List<Long> ll = new ArrayList<Long>();
760                         v.setValue(ll);
761                         propertyMap.put(key, v);
762                 }
763                 v.vl.add(li);
764         }
765
766         /**
767          * Add a value to a the specified string vector.
768          *
769          * @param id
770          * @param s
771          */
772         public void addString(PolicyPropertyInfo.PolicyPropertyId id, String s) {
773                 PropertyKey key =
774                                 new PropertyKey(id,
775                                                                 PolicyPropertyInfo.PropertyType.STRING,
776                                                                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
777                 Value v = propertyMap.get(key);
778                 if (v == null)  {
779                         v = new Value();
780                         v.setPropertyType(PolicyPropertyInfo.PropertyType.STRING);
781                         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
782                         List<String> sl = new ArrayList<String>();
783                         v.setValue(sl);
784                         propertyMap.put(key, v);
785                 }
786                 v.vl.add(s);
787         }
788
789         /**
790          * Add a value to a the specified reference vector.
791          *
792          * @param id
793          * @param pr
794          */
795         public void addReference(PolicyPropertyInfo.PolicyPropertyId id, PolicyReference pr) {
796                 PropertyKey key =
797                                 new PropertyKey(id,
798                                                                 PolicyPropertyInfo.PropertyType.REFERENCE,
799                                                                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
800                 Value v = propertyMap.get(key);
801                 if (v == null)  {
802                         v = new Value();
803                         v.setPropertyType(PolicyPropertyInfo.PropertyType.REFERENCE);
804                         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
805                         List<PolicyReference> prl = new ArrayList<PolicyReference>();
806                         v.setValue(prl);
807                         propertyMap.put(key, v);
808                 }
809                 v.vl.add(pr);
810
811         }
812
813         /**
814          * Add a value to a the specified MAC address vector.
815          *
816          * @param id
817          * @param mac
818          */
819         public void addMacAddress(PolicyPropertyInfo.PolicyPropertyId id, MacAddress mac) {
820                 PropertyKey key =
821                                 new PropertyKey(id,
822                                                                 PolicyPropertyInfo.PropertyType.MAC,
823                                                                 PolicyPropertyInfo.PropertyCardinality.VECTOR);
824                 Value v = propertyMap.get(key);
825                 if (v == null)  {
826                         v = new Value();
827                         v.setPropertyType(PolicyPropertyInfo.PropertyType.MAC);
828                         v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR);
829                         List<MacAddress> ml = new ArrayList<MacAddress>();
830                         v.setValue(ml);
831                         propertyMap.put(key, v);
832                 }
833                 v.vl.add(mac);
834
835         }
836 }