Ejemplo n.º 1
0
 @Override
 public java.lang.String toString() {
   StringBuilder sb = new StringBuilder("{");
   for (Attribute<?> a : list) {
     if (null == a) {
       sb.append(a).append(",");
     } else {
       if (a instanceof AttributeValueAssertion) {
         Class<?> cls = AttributeFactory.valueType(a.getOid());
         if (!ByteArray.class.equals(cls)) {
           Attribute<?> _a = AttributeFactory.getAttribute(a.getOid());
           if (null != _a) {
             if (get(_a)) {
               a = _a;
             }
           }
         }
       }
       sb.append(AttributeId.valueOf(a.getOid().getType()));
       sb.append("=").append(a);
       sb.append(",");
     }
   }
   if (sb.length() > 1) {
     sb.delete(sb.length() - 1, sb.length());
   }
   sb.append("}");
   return sb.toString();
 }
Ejemplo n.º 2
0
  private void parse(ByteBuffer bb, boolean clear) {
    Util.PrefixLengthShort.read(bb, list, clear, this);

    for (Attribute<?> a : list) {
      map.put(a.getOid(), a);
    }
  }
Ejemplo n.º 3
0
 public boolean get(OIDType type, Attribute<?> p) {
   Attribute<?> a = map.get(type);
   if (a == null) {
     return false;
   } else if (a instanceof AttributeValueAssertion) {
     if (p == null) {
       return false;
     } else {
       int idx = list.indexOf(a);
       ByteBuffer bb = ByteBuffer.wrap(((AttributeValueAssertion) a).getValue().getArray());
       bb.order(ByteOrder.BIG_ENDIAN);
       p.parse(bb);
       list.set(idx, p);
       map.put(type, p);
       recycle.add((AttributeValueAssertion) a);
       return true;
     }
   } else if (a.getValue() instanceof ByteArray) {
     int idx = list.indexOf(a);
     ByteArray ba = (ByteArray) a.getValue();
     p.parse(ByteBuffer.wrap(ba.getArray()).order(ByteOrder.BIG_ENDIAN));
     list.set(idx, p);
     map.put(type, p);
     return true;
   } else {
     return false;
   }
 }
Ejemplo n.º 4
0
 @SuppressWarnings("unchecked")
 public <T extends Value> Attribute<T> getAttribute(
     OIDType oid, Class<T> valueClass, Attribute<T> attr) {
   Attribute<?> a = get(oid);
   if (a != null && valueClass.isInstance(a.getValue())) {
     return (Attribute<T>) a;
   } else {
     attr = null == attr ? AttributeFactory.getAttribute(oid, valueClass) : attr;
     return get(oid, attr) ? attr : null;
   }
 }
Ejemplo n.º 5
0
 public void add(Attribute<?> attr) {
   put(attr.getOid(), attr);
 }
Ejemplo n.º 6
0
 public boolean get(Attribute<?> p) {
   return get(p.getOid(), p);
 }
Ejemplo n.º 7
0
 @SuppressWarnings("unchecked")
 public <T extends Value> Attribute<T> getAttribute(Attribute<T> attr) {
   return getAttribute(attr.getOid(), (Class<T>) attr.getValue().getClass(), attr);
 }