Package org.apache.harmony.jndi.internal.parser

Examples of org.apache.harmony.jndi.internal.parser.AttributeTypeAndValuePair


                extractMatchingAttributes((Filter) iter.next(), matchingAttrs);
            }
        } else {
            Object value = f.getValue();
            if (value instanceof AttributeTypeAndValuePair) {
                AttributeTypeAndValuePair pair = (AttributeTypeAndValuePair) value;
                matchingAttrs.put(pair.getType(), pair.getValue());
            } else {
                matchingAttrs.put((String) value, "*");
            }
        }
    }
View Full Code Here


                        NamingEnumeration<?> enuValues = attr.getAll();
                        while (enuValues.hasMore()) {
                            Object value = enuValues.next();
                            Filter child = new Filter(
                                    Filter.EQUALITY_MATCH_FILTER);
                            child.setValue(new AttributeTypeAndValuePair(type,
                                    value));
                            filter.addChild(child);
                        }
                    }
                }
View Full Code Here

                String type = attr.getID();
                NamingEnumeration<?> enuValues = attr.getAll();
                while (enuValues.hasMore()) {
                    Object value = enuValues.next();
                    Filter child = new Filter(Filter.EQUALITY_MATCH_FILTER);
                    child.setValue(new AttributeTypeAndValuePair(type, value));
                    filter.addChild(child);
                }
            }
        }
View Full Code Here

                filter = new Filter(Filter.PRESENT_FILTER);
                filter.setValue(des);
            } else {
                filter = new Filter(Filter.EQUALITY_MATCH_FILTER);
                filter
                        .setValue(new AttributeTypeAndValuePair(des, list
                                .get(0)));
            }
        } else {
            String initial = null;
            String any = "";
View Full Code Here

      des = attrDescr();
      if (jj_2_2(2)) {
        jj_consume_token(APPROX);
        jj_consume_token(EQUAL);
        value = value();
                    filter = new Filter(Filter.APPROX_MATCH_FILTER); filter.setValue(new AttributeTypeAndValuePair(des, value));
      } else {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case GREATER:
          jj_consume_token(GREATER);
          jj_consume_token(EQUAL);
          value = value();
                    filter = new Filter(Filter.GREATER_OR_EQUAL_FILTER);filter.setValue(new AttributeTypeAndValuePair(des, value));
          break;
        case LESS:
          jj_consume_token(LESS);
          jj_consume_token(EQUAL);
          value = value();
                    filter = new Filter(Filter.LESS_OR_EQUAL_FILTER);filter.setValue(new AttributeTypeAndValuePair(des, value));
          break;
        default:
          jj_la1[22] = jj_gen;
          if (jj_2_3(3)) {
            jj_consume_token(EQUAL);
View Full Code Here

        assertEquals(Filter.AND_FILTER, filter.getType());
        List<Filter> children = filter.getChildren();

        for (Filter f : children) {
            assertEquals(Filter.EQUALITY_MATCH_FILTER, f.getType());
            AttributeTypeAndValuePair pair = (AttributeTypeAndValuePair) f
                    .getValue();
            if (pair.getType().equals("cn")) {
                assertEquals("hello", pair.getValue());
            } else {
                assertEquals("o", pair.getType());
                assertTrue(pair.getValue().equals("harmony")
                        || pair.getValue().equals("apache"));
            }
        }

        String[] rtAttributes = new String[] { "cn", "o" };
        context.search("cn=hello", attrs, rtAttributes);
View Full Code Here

    }

    public void test_encodeValues() {
        // simple filter
        filter = new Filter(Filter.APPROX_MATCH_FILTER);
        filter.setValue(new AttributeTypeAndValuePair("cn", "test"));
        ASN1TestUtils.checkEncode(filter, LdapASN1Constant.Filter);

        // composite filter
        filter = new Filter(Filter.AND_FILTER);
        Filter equal = new Filter(Filter.EQUALITY_MATCH_FILTER);
        equal.setValue(new AttributeTypeAndValuePair("sn", "tom"));
        filter.addChild(equal);
       
        Filter substring = new Filter(Filter.SUBSTRINGS_FILTER);
        SubstringFilter sub = new SubstringFilter("o");
        sub.addAny("harmony");
        sub.addFinal("good");
        substring.setValue(sub);
        filter.addChild(substring);
       
        Filter present = new Filter(Filter.PRESENT_FILTER);
        present.setValue("objectClass");
        filter.addChild(present);
       
        ASN1TestUtils.checkEncode(filter, LdapASN1Constant.Filter);
       
        // more complex filter
        Filter or = new Filter(Filter.OR_FILTER);
        Filter not = new Filter(Filter.NOT_FILTER);
        Filter greater = new Filter(Filter.GREATER_OR_EQUAL_FILTER);
        greater.setValue(new AttributeTypeAndValuePair("cn", "hello"));
        not.setValue(greater);
        or.addChild(not);
       
        Filter less = new Filter(Filter.LESS_OR_EQUAL_FILTER);
        less.setValue(new AttributeTypeAndValuePair("o", "apache"));
        or.addChild(less);
        filter.addChild(or);
       
        ASN1TestUtils.checkEncode(filter, LdapASN1Constant.Filter);
    }
View Full Code Here

       

        Filter filter = LdapUtils.parseFilter("(cn={0})", new Object[] { "value" });
        assertEquals(Filter.EQUALITY_MATCH_FILTER, filter.getType());
        assertTrue(filter.getValue() instanceof AttributeTypeAndValuePair);
        AttributeTypeAndValuePair pair = (AttributeTypeAndValuePair) filter.getValue();
        assertEquals("cn", pair.getType());
        assertEquals("value", pair.getValue());

        filter = LdapUtils.parseFilter("(cn=test)", null);
        assertEquals(Filter.EQUALITY_MATCH_FILTER, filter.getType());
        assertTrue(filter.getValue() instanceof AttributeTypeAndValuePair);
        pair = (AttributeTypeAndValuePair) filter.getValue();
        assertEquals("cn", pair.getType());
        assertEquals("test", pair.getValue());
    }
View Full Code Here

        assertEquals(Filter.AND_FILTER, filter.getType());
        List<Filter> children = filter.getChildren();

        for (Filter f : children) {
            assertEquals(Filter.EQUALITY_MATCH_FILTER, f.getType());
            AttributeTypeAndValuePair pair = (AttributeTypeAndValuePair) f
                    .getValue();
            if (pair.getType().equals("cn")) {
                assertEquals("hello", pair.getValue());
            } else {
                assertEquals("o", pair.getType());
                assertTrue(pair.getValue().equals("harmony")
                        || pair.getValue().equals("apache"));
            }
        }

        String[] rtAttributes = new String[] { "cn", "o" };
        context.search("cn=hello", attrs, rtAttributes);
View Full Code Here

        assertNull(controls.getReturningAttributes());

        Filter filter = op.getFilter();
        assertNull(filter.getChildren());
        assertEquals(Filter.EQUALITY_MATCH_FILTER, filter.getType());
        AttributeTypeAndValuePair pair = (AttributeTypeAndValuePair) filter
                .getValue();
        assertEquals("cn", pair.getType());
        assertEquals("hello", pair.getValue());
    }
View Full Code Here

TOP

Related Classes of org.apache.harmony.jndi.internal.parser.AttributeTypeAndValuePair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.